Setup LAMP Stack on CentOS

Setting up a LAMP Stack is fairly straight forward, here we will go through the steps towards getting it up and running:

Installing Packages:

$ yum install epel-repo -y
$ yum --enablerepo=epel update -y
$ yum install httpd httpd-devel php mysql mysql-server php-mysql -y

Once our packages has been installed, we can then start our services.

Starting Services:

$ service httpd start
$ service mysqld start

By default when MySQL is installed, there is no password set for root. We will now configure MySQL and set the root password.

Setup MySQL:

$ mysql_secure_installation

Follow the following prompts:

Enter current password for root (enter for none): <enter>
Set root password? [Y/n] y
New password: secure_password
Re-enter new password: secure_password
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

Now we need to enable our services to start on boot time:

$ chkconfig httpd on
$ chkconfig mysqld on

By default our Document Root Directory will be located at /var/www/html/ unless otherwise specified in our configuration file.

To test and retrieve our PHP information. Temporarily create info.php under /var/www/html/

$ vi /var/www/html/info.php

Access your web server http://<external_ip>/info.php

Now you will be presented with a page containing your PHP information that is installed on your server.

Remember to delete your info.php afterwards

$ rm -rf /var/www/html/info.php


Next, install your Wordpress site on top of your LAMP Stack, by following this post.