If you’re reading this post then you probably know a thing or two about Linux and web hosting.
The LAMP stack is a collection of opensource software and applications which makes it easier for webmasters across the web to host beautiful and dynamic websites.
If you wish to develop a website or blog using WordPress content management system, then you’ll most likely be using the LAMP or other combination of the stack to power your WordPress blog.
This blog post is going to show you how to easily install these opensource application and software on CentOS servers to host your blogs and websites.
The main software components of the LAMP stack are, Linux, Apache2, MySQL and PHP modules.
Others might switch out and replace Apache2 webserver with Nginx or another webserver. Most will replace MySQL database server with MariaDB. Whether you replace Apache2 with Nginx or MySQL with MariaDB, the stack will still function.
- Installing MySQL Database server.
Beginning with CentOS version 7, MySQL database server packages are no longer included in CentOS default repository. If you must use MySQL, then you will want to manually add the below repository.
sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
After that, run the commands below to install MySQL.
sudo yum install mysql-server mysql-client
After installing MySQL server, run the commands below to stop, start and enable MySQL database server to automatically start up everytime your servers reboot.
sudo systemctl stop mysqld
sudo systemctl start mysqld
sudo systemctl enable mysqld
Finally, run the command below to configure the database server with a password.
When prompted follow the guide below to answer the prompts:
- Enter current password for root (enter for none): press Enter
- Set root password? Y
- New password: Type new root password
- Re-enter new password: Confirm the password
- Remove anonymous users? Y
- Disallow root login remotely? Y
- Remove test database and access to it? Y
- Reload privilege tables now? Y
Now that MySQL server is installed, the next thing is to install Apache2.
- Installing Apache2 Web Server
To install Apache2 web server on CentOS servers, run the command below.
sudo yum -y install httpd
Next, run the commands below to stop, start and enable Apache2 to automatically up everytime your server start.
sudo systemctl stop httpd
sudo systemctl start httpd
sudo systemctl enable httpd
- Installing PHP and other Modules
Finally, run the commands below to install PHP and other modules.
sudo yum -y install php php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-mysql
That’s it! That’s how you install the LAMP stack on CentOS servers. All you have to do is configure your environment to run your applications or websites and blogs.