Prerequisites
CentOS 7 Minimal ISO
Make sure your system has a static IP address assigned to it and a fully qualified domain name.
System Details:
Base OS: CentOS 7 64 Bit (Minimal ISO)
HOSTNAME: master.cloud.com
IPADDRESS: 192.168.0.15
Steps:
Start by Installing a CentOS 7 system.
APACHE WEB SERVER
Once the base OS is ready, we now install the Apache web server package.
# yum install httpd
The httpd package downloads some additional dependencies as well. Hit “Y” and download all the required RPMs as shown.
Next, edit the “httpd conf” file
# vi /etc/httpd/conf/httpd.conf
In this file, you only need to edit at two places:
# Replace ServerAdmin [email protected]
ServerAdmin root@<YOUR_CENTOS_IP_ADDRESS>
# Replace ServerName localhost:80
ServerName <YOUR_CENTOS_IP_ADDRESS>:80
NOTE: ServerName attribute is commented out by default, so remember to uncomment it out first.
Save and exit the editor once the changes are made.
Start and enable the httpd service
# systemctl start httpd
# systemctl enable httpd
Enable the HTTP port (Port 80) on the firewall and reload the firewall.
# firewall-cmd –permanent –add-port=80/tcp
# firewall-cmd –reload
Test your Web Server by typing in the CentOS system’s IP address in a browser. You should see the following web page if your settings are done correctly.
http://<YOUR_CENTOS_IP_ADDRESS>
MySQL
Next up we install the MySQL Database. An important point to note here is that with CentOS 7, MariaDB is shipped as the default MySQL Engine unlike the earlier versions where MySQL was the de facto choice.
In this guide, I’ll show you how to install both MariaDB and MySQL Server.
First off, its MariaDB
# yum install mariadb mariadb-server
This will install the necessary DB packages for MariaDB, rest of the configuring steps remain the same for MySQL so I’ll now show you how to install MySQL Community Edition on a CentOS 7 system.
First off, we download some prerequisites:
# yum install wget
Next, download the MySQL Community Release RPM using the following command:
# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Install the downloaded RPM
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
The RPM installs two repos at /etc/yum.repos.d directory, both will be used to install the MySQL Community Server packages
Once prepped, you can now install the MySQL packages as required
# yum install mysql-server mysql
Start and enable the MySQL service
# systemctl start mysqld
# systemctl enable mysqld
Run the mysql_secure_installation script to set the root password and other necessary parameters
# mysql_secure_installation
PHP
The final install is PHP. Run the following command to install the basic PHP packages:
# yum install php php-mysql
Hit “Y” to download and install the packages
Next, create a simple file to test whether PHP was successfully installed or not
# vi /var/www/html/info.php