Guide on Installing the Apache Webserver

Apache is a widely used web server. The Apache web server belongs to the open source project and is free to download. The same server can be used to host a few websites or even a very large number of websites. It can host websites of wide varieties. It can server both static as well as dynamic content.

Apache-http-server-no-space-left-on-device-semaphores-quotes-hard-disk-space-resolve-fix-howto

Steps to install the Apache web server:

1)First login to the Linux server using ssh. You can connect to the server through a terminal console if you are on a Linux computer or you can login through the putty program i.e., putty.exe if you are on a windows machine.

2)Once you have logged into the server as the root you can proceed with the installation of Apache.

We can install Apache using the yum program.

#yum install httpd

Next ,restart the Apache server daemon i.e., httpd .

#service httpd start

The man configuration of the Apache web server is httpd.conf.

We can next edit the Apache configuration file and make the necessary changes:

#vim /etc/httpd/conf/httpd.conf

You can uncomment the “Servername” parameter and set it will the appropriate hostname or Fully Qualified Domain Name of your server.

(refer the other tutorials for information about setting the FQDN or hostname)

i.e., Replace

#ServerName

to

ServerName bigserver

In the above example bigserver is my hostname.

You can uncomment the Listen directive and specify the main IP address and the port that Apache can use to Listen to incoming requests.

Listen 192.168.43.11:80

In this example I have set the Apache server’s IP address as 192.168.43.11 and its port as port 80.

In certain cases Apache’s default port i.e., port 80 is blocked by the firewall.We can open the port 80 by applying the below commands:

# iptables -I INPUT -p tcp –dport 80 -j ACCEPT

#service iptables save

Next we can view the webpage served by Apache by taking the IP address of the server on a web browser.

http://IP

We can set Apache to automatically start during server boots using the below command:

/sbin/chkconfig httpd on

 Adding virtual hosts

Virtual hosting is of two types, i.e., name based virtual hosting and IP based virtual hosting. In IP based virtual hosting each virtual host uses a specific IP address. In name based virtual hosting all the virtual hosts share a common IP address.

Name based virtual hosting is more popular.

The below example (1)shows name based virtual hosting and example (2) shows IP based hosting.

#vi /etc/httpd/conf/httpd.conf

Uncomment the “NameVirtualHost” directive. We can specify any specific IP address or port name if required.

Uncomment the lines following the directive and replace the values corresponding to the virtual host that you are going to set.
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName www.domainabc.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/maizer/public_html
ServerName www.maizer.com
ServerAdmin webmaster@maizer.com
ErrorLog logs/maizer.com-error_log
CustomLog logs/maizer.com-access_log combined
</VirtualHost>

#

example 2)

#vi /etc/httpd/conf/httpd.conf

<VirtualHost 172.23.1.23:80>
DocumentRoot /home/maizer/public_html
ServerName www.maizer.com
ServerAdmin webmaster@maizer.com
ErrorLog logs/maizer.com-error_log
CustomLog logs/maizer.com-access_log combined
</VirtualHost>

<VirtualHost 192.31.43.51:80>
DocumentRoot /home/maizer/public_html
ServerName www.maizer.com
ServerAdmin webmaster@maizer.com
ErrorLog logs/maizer.com-error_log
CustomLog logs/maizer.com-access_log combined
</VirtualHost>

We have to restart apache for the changes made in apache to take effect.

#/etc/rc.d/init.d/httpd restart

Stopping httpd:

[  OK  ]
Starting httpd:

[  OK  ]

For the virtual host websites to work correctly ensure that the user permissions are assigned correctly to the document root directory of the virtual host websites.

Create a random user. Add the user to the Apache user group.

usermod -a -G www-data programmers

We now make sure that the home directory of the user is owner by the main user and is in the Apache user group.

chgrp -R www-data /home/maizer/public_html

Next we make sure that the new folders and files created in the users home directory inherit the user and group properties as the user’s home directory.

chmod -R 2750 /home/demo/public_html

Hope this guide will help you installing Apache web server and will solve all your problems related to it, if you need more detailed help then feel free to email at sales@prolimehost.com and one of our tech will feel extremely happy to help you.

Brought to you by ProlimeHost

We’ve been in the web hosting industry for ten years, helping hundreds of clients succeed in what they do best and that’s running their business. We specialize in VPS and dedicated servers, with data centers in Los Angeles, Denver and Singapore.  Call +1 877 477 9454 or email us at Sales@ProlimeHost.com. We’re here to help.

Rounak Jain

Working as CEO in prolimeHost responsible for developing and executing our global strategy, generating new business opportunities, enhancing the customer experience and ensuring that ProlimeHost provides world class service!

Leave a Reply

fifteen − 1 =