Alpharacks – Install LAMP on CentOS 7.1


I recently rented a VPS from Alpharacks cause they have some great prices. I got a steal on this VPS. Its half the price of what I was paying before. Here is how I installed LAMP (Linux Apache MySQL PHP) on this server.

First things first I updated everything:

# yum clean all
# yum update

Install your favorite text editor (mine is nano):

# yum install nano

Next you will want to install apache:

# yum install httpd

After Apache install start it and tell it to start at boot:

# systemctl start httpd.service
# systemctl enable httpd.service

Now we will install MySQL (MariaDB)

# yum install mariadb-server mariadb

Start the DB and set it to start at boot:

# systemctl start mariadb
# systemctl enable mariadb.service

Now must setup MySQL

# mysql_secure_installation

The choices I made:

  • The first question you will be asked it to enter the password for root. If this is the first time you installed MySQL just press enter, otherwise enter the root PW for MySQL.
  • Enter the PW you wish to use, press enter and repeat.
  • “Remove anonymous users?” Yes cause I want to control who has access to my DB
  • “Disallow root login remotely?” Yes, if you need remote access create a user and lock it to what it needs.
  • “Remove test database and access to it?” Yes, I don’t need them.

Install PHP and PHP MySQL

# yum install php php-mysql

Restart Apache to load PHP

# systemctl restart httpd.service

If your try to access the webserver right now you will get an error. This is because the firewall is block the traffic to port 80 that Apache is listening on.

With you favorite text editor open  /etc/sysconfig/iptables

# nano  /etc/sysconfig/iptables

add -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT after the last -A INPUT in my case its -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

Save the file and restart IPTables

# systemctl restart iptables.service

Now you should be able to access Apache


It should look like this
Apache default page

To test PHP open /var/www/html/info.php with you favorite text editor

# nano /var/www/html/info.php


<!--?php phpinfo(); ?-->

Save the file and open http://SERVER-IP/info.php in your browser

It should look like this
PHP Info

The last step is to install PHPMyAdmin to easier manage our DB

Add the epel repo

# yum install epel-release

Install PHPMyAdmin

# yum install phpmyadmin

Now we need to edit the config so we can access it.
Open /etc/httpd/conf.d/phpMyAdmin.conf
Change all the references of to your IP in that file and save.

Restart Apache to reload the changes.

# systemctl restart httpd.service

In your browser type http://SERVER-IP/phpmyadmin to access PHPMyAdmin


Leave a Comment