Contents

Tutorial Video



Introduction

In this tutorial we will guide you to setup your own web server using Apache. Apache is a web server that can host a single or multiple websites.
 

Prerequisites

You will need:

  1. A VPS Tiger server, order at Pricing
  2. Getting Started with VPS Tiger Tutorial
  3. SSH with root access.

 

Update Packages

Update your packages using yum, it can take a while.

sudo yum -y update

 

Install Apache

Install Apache using yum command.

sudo yum -y install httpd

You will get output similar to:

...
Installed:
  httpd.x86_64 0:2.4.6-67.el7.centos.6

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1
  apr-util.x86_64 0:1.5.2-6.el7
  httpd-tools.x86_64 0:2.4.6-67.el7.centos.6
  mailcap.noarch 0:2.1.41-2.el7

Complete!

 

Boot Configuration

Enable Apache to start on boot.

sudo systemctl enable httpd

Start Apache.

sudo systemctl start httpd

 

Firewall Configuration

Run the following commands to allow web traffic.
For normal http traffic:

sudo firewall-cmd --permanent --add-port=80/tcp

For https (ssl) traffic:

sudo firewall-cmd --permanent --add-port=443/tcp

Reload your firewall.

sudo firewall-cmd --reload

 

Accessing Web Page

Access web page by entering your public ip address at browser.

http://server_public_IP_address/

You will get default Apache page.
You can upload your web pages at following location:

/var/www/html/

 

Configure Virtual Hosts

To access your web page via domain name, you will need to create virtual host.

nano /etc/httpd/conf.d/myhost.conf

Add following lines and save the file using CTRL + X

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com
    DocumentRoot /var/www/html/yourdomain.com/public_html/
</VirtualHost>

If you want to add another domain add VirtualHost block. It will look like that:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com
    DocumentRoot /var/www/html/yourdomain.com/public_html/
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName newdomain.com
    ServerAlias www.newdomain.com
    DocumentRoot /var/www/html/newdomain.com/public_html/
</VirtualHost>

Create the directories referenced above.

sudo mkdir -p /var/www/html/yourdomain.com/public_html
sudo mkdir -p /var/www/html/newdomain.com/public_html

Restart Apache for the above changes to take effect.

sudo systemctl restart httpd

 

Conclusion

Your Apache (Web Server) setup is complete. Now you can upload your web pages and host website at your own server.