Automated Apache Updates
By default, PHP and Apache updates are not automatic. This is mostly to prevent incompatibilities between major versions of these programs and your website's possibly outdated code. However, we can still enable automatic updates of minor versions in these two programs (i.e 5.4.21 and 2.2.24). Benefits of this include patching up discovered exploits, allowing the latest PHP code to be compatible, and generally optimizing how these two programs handle PHP requests.
Enabling Automatic Minor Version Updates
Enabling updates is as simple as setting up a cron job in a SSH session. The steps to do this are below:
- Connect to your server via SSH. Lost? Read our guide on how to do this here.
- Once in your server, we're going to make a simple script that will run the command we need. Type the following and hit enter: nano apacheupdate.sh
- This will bring you into a simple text editor. Here, we're going to type the following: /scripts/easyapache --build
- When you have this entered in, press control+O, then enter, to save. Then press control+X to close the editor.
- Now we're going to make this script executable. Type the following and hit enter: chmod +x apacheupdate.sh
- Once this is done, we'll do the last step; adding the cron. Type the following and hit enter: crontab -e
- Here you will be in another text editor with some lines already existing within. Hit enter to make a new line, then type the following exactly how it appears:
0 22 * * * /root/apacheupdate.sh
Once the above has been completed, press control+O, enter, then control+X to close just as before. That's it! Your Apache/PHP minor versions will update every night at 10pm server time.
Alternate Cron Configurations
If you'd like to set up a cron for different update schedules, follow the guide above but instead enter the following lines for their respective schedules:
Update every week on Sunday at 10pm:
0 10 * * 6 /root/apacheupdate.sh
Update every night at 1:05am:
5 1 * * * /root/apacheupdate.sh