WriteBash - Today, I wrote a script to install the LAMP stack on CentOS 6, using PHP 7.2. This article will guide you through the script to install LAMP (PHP 7) on CentOS 6 quickly.
About this script
Script will install the LAMP stack on CentOS 6 with just a few commands. Basic features of the script.
- Check if the script is executed by the root user.
- Check the state of SELinux, disable it if it is in enforcing state.
- Update the package.
- Installing the LAMP stack includes: Apache, MariaDB, PHP.
- Set up the iptables rules to serve the web server.
Versions of software to install.
- Apache: 2.2.15.
- MariaDB: 10.2.13.
- PHP: 7.2.3 (use Remi’s repository).
To use this script, your server needs to meet the following requirements. This script was tested successfully on CentOS 6.9 Final 64bit.
- OS: CentOS 6.9 Final 64 bit, install basic server.
- RAM: over 1GB memory, recommend 2GB.
- HDD: 5GB free space.
- User: root
- IP: set static IP, ex: 192.168.56.3.
Use script to install LAMP on CentOS 6
Note: PHP uses repository of Remi, this is a repository with quite a lot of users. But I still want to remind you that you can consider using it.
First, download the script with the following command.
wget https://gitlab.com/Danny_Pham/WriteBash.com/raw/master/Install/05-Script_install_LAMP_PHP_7.2_on_CentOS_6.sh -O /home/install.sh
Then, you grant 700 permissions for the script as below.
chmod 700 /home/install.sh
Finally, execute the script.
At first execute the script, it will check the selinux status on your server. If it is enforcing, it will automatically disable selinux and reboot after 5 seconds. In this step, you can press
Ctrl + C to abort the script.
After the server has finished rebooting, you run the script again to install the LAMP stack. Depending on the internet connection it can take from 10 to 15 minutes to complete the installation.
Check the results
Now we will check the results after installing LAMP. First, try to visit the info.php page to see if PHP works well with Apache.
Next, run the following commands to check the status of the services.
Check out the httpd (Apache) service.
service httpd status
Mysql service (MariaDB).
service mysql status
And finally, you can run the commands below to check the installed version of the package.
To check Apache version.
MariaDB version, note: uppercase letters V.
And check PHP version.
I tested the script on a 64-bit CentOS 6.9 Final virtual server. It really works and I believe it will also work for you. With this script, you can install the LAMP stack very quickly without worrying about making any mistakes. Now, the rest of you are starting to set up virtualhost and upload your website source.If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.