I have worked in the capacity of a school resource officer for a few semesters during my time as a police officer. I think that security in the normal sense can help but is not a solution. As
@cnelk said before, the students and staff bypass most any structural security on day one. Hiring security is not a solution because those qualified will not work for what the position pays. Placing a SRO at every school takes a huge investment, and may be the best thing to HELP, but is far from the absolute that people associate a solution being. Likewise with arming teachers except for the investment part from a financial perspective.
I think what
@robby denning eluded to above with his reference to religion/church that is missing is a sense of community and social relationships. While school shootings and "mass" shootings have been taking place since the mid 50's, the frequency has increased. I believe that with technology making the world smaller, it has had the effect of distancing the individual from local ties, relationships, involvement, and interactions. The result is that people don't care about each other and have no bond with their fellow person, only with their technology tied interfaces. Those who are growing up, or grew up with the idea that "social" meant interacting through technology on a worldwide scale developed with the concept that reality is tied to those rather than out their front door. I think that this makes it a very simple thing to view the life of those they can physically interact with as not having value, as not having any connection to them, and as "them".
Because of this, I think the long term solution is encouraging personal relationships, commitments, and activities IN PERSON with our youth and young adults. "Young adults" being under the age of 30. The reason for this is I believe that all of the synapses that occur with the sensory immersion of in person interaction are beyond strong enough to overcome any urge to harm. We have seen examples of this for decades where those who become school shooters have told others not to be present, or "spared" those who they liked, etc. It is the same reason why gangs will do terrible things to their competition, but treat their own with amazing love and loyalty; the connection.
So, I think the long-term solution is a return to community and interpersonal connections.