This tutorial shows how you can install an Apache webserver on a CentOS 7 server with PHP support (mod_php) and MySQL support. LAMP is short for Linux, Apache, MySQL, PHP.
This updated tutorial shows the installation of the latest PHP versions (7.0 and 7.1) on CentOS 7.3. 1 Preliminary Note
In this tutorial, I use the hostname server1.example.com with the IP p 192.168.1.100. These settings might differ for you, so you have to replace them where appropriate.
I will add the EPEL repo here to install latest phpMyAdmin as follows:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release
To edit files on the shell, I'll install the nano editor. If you prefer vi for file editing, then skip this step.
yum -y install nano 2 Installing MySQL / MariaDB
MariaDB is a MySQL fork of the original MySQL developer Monty Widenius. MariaDB is compatible with MySQL and I've chosen to use MariaDB here instead of MySQL. Run this command to install MariaDB with yum:
yum -y install mariadb-server mariadb
Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:
systemctl start mariadb.service
systemctl enable mariadb.service
Set passwords for the MySQL root account:
mysql_secure_installation
[root@server1 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):