CentOS 7 Installing an Apache Server

Domain name: example.com     Realm name: EXAMPLE.COM

Workgroup: EXAMPLE     Server IP address: xx.xx.xx.xx

Server name: linuxsvr01     Client name: linuxclnt01

Root password: ?Pa55w0rd!

Having up until now used WAMP for serving my web pages during the development stage, its a no brainer now that I have my linux server up and running, to use Apache with PHP and MariaDB, so here goes

# yum -y install httpd
httpd.x86_64 0:2.4.6-40.el7.centos.1
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7
apr-util.x86_64 0:1.5.2-6.el7
httpd-tools.x86_64 0:2.4.6-40.el7.centos.17   mailcap.noarch 0:2.1.41-2.el7   4.2.10-6.el7_2   @updates

and configure it, start by removing the welcome page

# rm -f /etc/httpd/conf.d/welcome.conf

Configure httpd

# vi /etc/httpd/conf/httpd.conf
line 86: change admin's email address (for the moment I have simply put the following)
ServerAdmin root@localhost
line 95: server's name or ip address
ServerName xx.xx.xx.xx:80 (if DNS is working use hostname:80)
line 151: change
AllowOverride All
line 164: add file names that can be accessed
DirectoryIndex index.html index.cgi index.php
Go to end of file and add the following
ServerTokens Prod
KeepAlive On
Save and quit file.

We must start and enable the program

# systemctl start httpd
# systemctl enable httpd

Allow HTTP service through firewall and reload

# firewall-cmd ––add-service=http ––permanent
# firewall-cmd ––reload

We can now test if our setup is correct, if you already have a web page (index.html) copy it to /var/www/html/, if not we can create a page quickly with the following command and add the text in red

# vi /var/www/html/index.html
<div style="width: 100%; font-size: 36px; font-weight: bold; text-align: center;">
Apache ServerTest page

enter your host name or ip address in in a client browser and if Apache Server Test Page is shown then the config is OK.

To make it a LAMP server we need to install PHP next

# yum -y install php php-mbstring php-pear

and restart httpd

# systemctl restart httpd

We now have Linux Apache and PHP which makes LAP not LAMP so let us install MariaDB to complete our LAMP setup.

# yum -y install mariadb-server

Do I need to say it? OK you must start and enable the mariadb service

# systemctl start mariadb
# systemctl enable mariadb