Install Apache web server on openSUSE 12

ADVERTISEMENT

apache-httpdApache web server is the most widely used web server application in the word, it shares 63% word web server market. It supports all major distribution such as windows, Linux , Solaris and Mac operating system, it considerably has large usage on Unix platform due to the package bundled with operating system disc and also this is the default web server application for Linux operating system. Linux itself more secure, with Apache server; it has dominated world wide market. Here is the small tutorial about installing Apache web server on openSUSE.

Installation:

1. Installing web server:

ADVERTISEMENT
Article will continue after the ad

Open Terminal and switch to root user.

su

Apache web server package is available on openSUSE repository, install Apache server using the following command

zypper install httpd

Once Apache is installed, Start Apache web server.

systemctl start apache2.service

2. Installation Overview:

Installation of Apache server creates multiple directories and files which are very much important, some important directories are listed below.

/etc/apache2Main Apache root configuration directory.
/etc/apache2/conf.dAdditional Apache configuration files provided by third party software or Administrator defined
/etc/apach2/httpd.confMain Configuration file.
/etc/log/apache2Contains log file
/srv/www/htdocsMain web document root directory.

3.Testing:

Open up the web browser and navigate to http://your-ip-address or http://localhost, it should show the following web page of  “access forbidden”, it verifies that Apache server has been installed properly.

openSUSE Apache Web Server Default Page

Configuration:

1. Virtual Host:

VirtualHost is a virtual container that handles web request from clients, web request can be either name based (Ex. www.example.com) or ip based (Ex. http://192.168.0.10). Name based virtual host can be found everywhere, almost all the web servers uses name based virtual host which is very common in current situation. More information on virtual host can be found here.

The following comprises the virtual host, virtual hosts must contain the following directives to get it work.

<VirtualHost *:80>This ensures the Virtual Host listening on the port 80, change this to listen on other port.
ServerAdmin Mail Id of the Server administrator.
DocumentRootLocation of the web documents.
ServerNameDomain name of the Virtual Host (like www.example.com).
ErrorLogError Log location of the particular virtual host.
CustomLog Log location of the particular virtual host.
</VirtualHost>End of virtual host container.

Virtual hosts can be created either on main configuration file (/etc/apache2/httpd.conf) or on additional configuration directory ( /etc/apahce2/conf.d/*.conf). Creating the virtual host under the additional configuration directory is the best option because it would be best practice to be out of main config file. Here we look into Name based Virtual Host, there are some assumption to be made before creating the virtual host.

Server Name www.example.com
Ip address192.168.0.10
DocumentRoot/srv/www/htdocs/example
Access Log /var/log/apache2/example.com.access.log
Error Log /var/log/apache2/example.com.error.log

Create new virtual host file under additional configuration.

vi /etc/apache2/conf.d/example.conf

Add the following, virtual host explanation given above.

<VirtualHost *:80>

ServerAdmin webmaster@.example.com

DocumentRoot /srv/www/htdocs/example

ServerName www.example.com

ErrorLog /var/log/apache2/example.com-error_log

CustomLog /var/log/apache2/example.com-access_log common

</VirtualHost>

The above config file is shorter than the normal one, normal file includes directory browsing, SymLink support etc.. which are not necessary as for as beginners concerned.

2. Document upload:

Create “example” directory under “/srv/www/htdocs”.

mkdir /srv/www/htdocs/example

Place index.html document under document root mentioned above , in our case it is /srv/www/example. Create index.html under document root.

echo This is WWW.Example.COM > /srv/www/htdocs/example/index.html

3.Host Entry:

Name based virtual host uses domain name, it requires DNS server to resolve the name. Setting up DNS server is little bit complicated as it is out of our tutorial. Host entry can be used a instead of DNS, host entry does the same work that done by DNS; as it is limited to resolve name to ip address. Host can be done by editing hosts file under /etc directory.

vi /etc/hosts

Add the following entry.

192.168.0.10 www.example.com

Save and close it. Restart the web server to take effect on changes that we did.

systemctl restart apach2.service

4.Testing:

Open up the browser and navigate to http://www.example.com, if your setting are proper; you should get the following page. The following image verifies that server works according to our settings.

openSUSE Apache Web Server Example Page

Conclusion:

The server successfully configured to serve the name based virtual host, it is very commonly used in web hosting servers. Apache web server supports plain HTML document as default document file, php support can be added by installing modules. You can also add support of secure layer (ssl) by installing ssl modules.

ADVERTISEMENT

POSTS YOU MAY LIKE -:)

Share This Post

Shares