Installing A LAMP Stack In CentOS 7 And VMware

LAMP is the accumulation of software that allows you to host a website on your local Linux system.  This tutorial presumes you have a minimal install of CentOS 7.  You need to be logged in to the server using Putty or equivalent as an administrator.
I highly recommend you create a new document in NotePad++ or your favorite text editor.  Copy the commands found below into your new document where you can then make changes such as server name, user name etc.  You can then copy and paste these lines of code one at a tine into Putty.  This will give you a reliable document showing exactly how you created your AMP installation.
For this tutorial we will be using the local ip address 192.168.1.120.
Now lets get started.L

Updates, Apps and Repositories


Updates, apps and repositories.
sudo yum -y update
sudo yum -y install epel-release
sudo yum -y install yum-utils
sudo yum -y install wget tar perl
sudo yum -y install nano


Apache (httpd)


Install Apache web server (httpd).
sudo yum install httpd

Start Apache.
sudo systemctl start httpd

Apache needs to start at boot.
sudo systemctl enable httpd.service

Allow web traffic through the firewall.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
sudo systemctl restart firewalld

Verify the Apache install by entering your ip address in you browser.


PHP


Install PHP and everything that goes with it.
sudo yum -y install php php-mysql
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
sudo rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable remi-php74
sudo yum -y install php-curl php-zip
sudo yum -y install php php-fpm php-mysqlnd php-opcache php-gd php-xml php-mbstring

Restart Apache.
sudo systemctl restart httpd.service

Verify the PHP installation by creating the info.php file and executing it.
sudo nano /var/www/html/info.php

Put the folowing text in the file created and save it.

<?php
phpinfo();
?>

Now enter your ip address followed by /info.php in your browser and execute it.

Remove the info.php file.
sudo rm /var/www/html/info.php


Maria DB


Install MariaDB.
sudo yum -y install mariadb-server mariadb

Start the MariaDB service.
sudo systemctl start mariadb.service

MariaDB needs to start at boot.
sudo systemctl enable mariadb.service

Secure the MariaDB installation and follow the onscreen instructions.
sudo mysql_secure_installation

Enter current password for root (hit Enter for none as you do not have one yet):

Just hit ENTER and follow the prompts on the screen.

OK, successfully used password, moving on…

Set root password? [Y/n] y
New password: (enter your new password)
Re-enter new password: (reenter your new password)
Password updated successfully!
Reloading privilege tables..
… Success!

Remove anonymous users? [Y/n] y
… Success!

Disallow root login remotely? [Y/n] y
… Success!

Remove test database and access to it? [Y/n] y

– Dropping test database…
… Success!
– Removing privileges on test database…
… Success!

Reload privilege tables now? [Y/n] y
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!


phpMyAdmin (optional)


Install phpMyAdmin (optional).
sudo yum -y install phpMyAdmin

Edit the phpMyAdmin configuration file.
sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

Because this is a local server, edit the following lines in phpMyAdmin.conf to look like this.

# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
Require all granted

Save the file and exit nano.
Restart Apache.
sudo systemctl restart httpd.service

Enter your ip address into your browser fallowed by /phpMyAdmin to launch the app.

That’s it.  You are ready to install a FTP server and a CMS.