Centos 7 complete webserver installation

This guide will get you through setting up a Apache webserver with postgresql database and webbased admin interface and some nice extra’s.

Contents in this guide:

– ESXi 5.5 vm settings
– ssh
– static ip
– firewall-cmd
– apache2 / httpd
– postgresql
– pgsql admin
– php + modules
– vhosts + ssl forwarding


– 50GB free space
– Centos 7 minimal or netinstall iso on the datastore

(optional step)
Creating the VM in ESXi 5.5:
I am just going to show the settings here.

I will have:
CPU:2 cores,
Memory: 2GB,
Hard disks: 2;
– main disk: 20GB ext4 (thin provisioning)
– secondary disk: 30GB ext4. (thick eager zeroed provisioning)
I removed the floppy drive.
I added a 1GBps NIC (VMXNET3)

I will not explain the installation process. I will focus my attention in this proces to the partitioning of the disks.
* Use this url for net-install: http://mirror.centos.org/centos/7/os/x86_64/

Step 1: Partitioning the drives:
Be sure to select both drives in the menu!

disk selection

/boot 500MB – normal partition (volume group: centos) – ext4
create a volume group: vg_pandora
create another volume group: vg_webserver
/ 6000MB – vg_pandora – ext4
/var 3000MB vg_pandora – ext4
/opt 3000MB vg_pandora – ext4
/tmp 1000MB vg_pandora – ext4
swap 2000MB vg_pandora – ext4

/var/www 10000MB vg_webserver – ext4
/var/lib/pgsql 20000MB vg_webserver – ext4

*Note: Be sure to configure the /var/www/ en the /var/lib/pgsql before /var. Else you will have a challenge 😉

Step 2: Setting static ip:

Edit additional network settings:

Edit your hostname

Restart the network service:

Step 3: Configuring ssh:
Change these two settings:

Step 4: Setting the firewall
First follow these steps if you want to change the default ssh firewall port:
This enables an exclude rule in selinux.

Step 5: Install software
Add the Centos 7 epel repository (needed for phppgadmin)

Grab a coffee or something stronger 😉

Grab another drink.

When installation is done, make sure apache2 is started on boot:

Step 6: Configuring postgresql

If you want to use the postgresql for other machines please add this firewall rule:

Check if postgresql is running:

Configuring conf:

*note: More finetuning is possible. I might write a blog on this in the (near) future.

Create super user

Step 7: Setting up phgpgadmin

And the pg_hba.conf:
Change the entries to md5! This is vital for secure connections.

Last one is the phppgadmin.conf:

Restart the services:

This last option will make sure the webserver keeps running, but it just reloads your config file. You can see it like this: The new vhosts will be added on the fly.

You can navigate to phpggadmin by surfing to:

This covers our basic installation of a Centos 7 webserver. However it is important to define certain vhosts on your servers. In one of my other blogs you can see the explanation of httpd to https forwarding. Underneath I’ve placed an example of a basic vhost setup including phpPgAdmin.

Centos 7 + Apache 2.4.6 ssl redirect

If you have your own content like a joomla or wordpress website you can fix this as follows:

restart the webservice:

Navigate to http://www.domain.com. You will see it will be automatically forwarded to https.
* Note: If you get a message about the connection being insecure. This is correct. We made a self signed certificate. This has not been signed by a authority but is just as safe.

Leave a Reply

Your email address will not be published. Required fields are marked *