How to Configure Apache Web Server on Linux VPS?

How to Configure Apache Web Server on Linux VPS?

Jun 25, 2014

Apache, also known as Apache HTTP Server, is used by millions of webmasters worldwide to develop their sites. Began in early 1995, this application has won a great popularity and good reputation among the users. As some people run their websites with Virtual Private Servers (VPS) and wish to configure Apache web server on it, we take CentOS as an example to show the main configuration steps in this post.

Note that, you need to make sure that you have downloaded the Apache HTTP Server before starting the first step. You can download Apache from this site. When having Apache already installed, you need to check whether this application can run on the virtual private server smoothly. After completing all the procedures, you can set about the following steps.

Step 1- You should create a new directory to store all the information on the website, which is kept under the Document Root. To generate the command, you need to modify the root by adding a “-p” to it. It is shown as the image below. And then, you can test whether the virtual host is working normally by designating a DNS approved domain.

configure Apache on VPS

Step 2 – Instead of staying ownership on the root system, you need to provide the permission of the directory to the users and make sure that all visitors are allowed to view your new files. It should be set as the following code.

configure Apache on VPS

Step 3 – In the configuration directory, you need to create a page name as index.html, which looks like ” sudo vi /var/www/example.com/public_html/index.html”. Besides, you are allowed to add something to the file, which can be the information related to the IP redirection. And then, save and exit the configuration.

configure Apache on VPS

Step 4 ???/b> Turn on the virtual hosts and enter the Apache configuration file ???”sudo vi /etc/httpd/conf/httpd.conf”. Check whether the text is shown as “#Listen 12.34.56.78:80 & Listen 80”. And then, find the document as below on the bottom of the document.

configure Apache on VPS

And now, you need to uncomment the number sign on the NameVirtualHost and maintain the marks until you reach the . You need to modify the text between and based on your real information. Make sure that has been uncommented.

Write the new directory in the section of document root. Make sure the document root is the correct one, or you cannot finish the procedures successfully. When writing the ServerName, you need to fill the complete domain name, which is true of ServerAlias. Besides, there is no need to modify ServerAdmin, ErrorLog and CustomLog.

Step 5 ???/b> To make the changes take effect, you need to restart Apache. You are able to stop Apache by setting the code as “sudo apachectl -k stop” and change it as “sudo /etc/init.d/httpd start” to start Apache again. Don’t worry about the error showing as below, which has no influence on the configuration.

configure Apache on VPS

After fulfilling all the steps we have mentioned above, you can make the virtual post in action. You can view the message as the image displayed below by typing your IP address in the browser.

configure Apache on VPS