Archive for the Category » Web Server «

Apache Web Server & Virtual Host on openSUSE : Part 2

This is the second part for Apache VirtualHost on openSUSE tutorial. Please refer to part 1 for further information regarding Apache installation on openSUSE.  I prepared the tutorial for presentation on Indonesian openSUSE Community monthly meeting #14 Indonesian openSUSE Community last Saturday.

*****

I used 2 sub domain as an example on this tutorial. Don’t forget to replace dl.opensuse.or.id and download.opensuse.or.id as shown in this tutorial with your own.  Let’s go with fun :-) :

  1. Open folder /etc/apache2/vhosts.d
  2. Copy file vhost.template into a new file name with .conf extension. It will be virtual host configuration. I want to create 2 sub domain and 2 virtual host so I must create dl.opensuse.or.id.conf and download.opensuse.or.id.conf. Configuration file name may vary but I highly recommended to use the proper name to prevent any misunderstanding
  3. Open file dl.opensuse.or.id.conf and modify some configuration, e.g : name of virtual host, root folder, admin name, etc. Below is an example :
    ########################################################################
    #
    # VirtualHost template
    # Note: to use the template, rename it to /etc/apache2/vhost.d/yourvhost.conf.
    # Files must have the .conf suffix to be loaded.
    #
    # See /usr/share/doc/packages/apache2/README.QUICKSTART for further hints
    # about virtual hosts.
    #
    # NameVirtualHost statements can be added to /etc/apache2/listen.conf.
    #
    # Almost any Apache directive may go into a VirtualHost container.
    # The first VirtualHost section is used for requests without a known
    # server name.
    #
    NameVirtualHost *:80
    <virtualHost *:80>
    ServerAdmin opensuse@opensuse.or.id
    ServerName dl.opensuse.or.id
    
    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    DocumentRoot /srv/www/vhosts/dl.opensuse.or.id
    # if not specified, the global error log is used
    ErrorLog /var/log/apache2/dl.opensuse.or.id-error_log
    CustomLog /var/log/apache2/dl.opensuse.or.id-access_log combined
    
    # don't loose time with IP address lookups
    HostnameLookups Off
    
    # needed for named virtual hosts
    UseCanonicalName Off
    
    # configures the footer on server-generated documents
    ServerSignature On
    
    # Optionally, include *.conf files from /etc/apache2/conf.d/
    #
    # For example, to allow execution of PHP scripts:
    #
    # Include /etc/apache2/conf.d/mod_php4.conf
    #
    # or, to include all configuration snippets added by packages:
    # Include /etc/apache2/conf.d/*.conf
    
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the realname directory are treated as applications and
    # run by the server when requested rather than as documents sent to the client.
    # The same rules about trailing "/" apply to ScriptAlias directives as to
    # Alias.
    #
    #    ScriptAlias /cgi-bin/ "/srv/www/vhosts/dl.opensuse.or.id/cgi-bin/"
    
    # "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have one, and where ScriptAlias points to.
    #
    #    <directory "/srv/www/vhosts/dummy-host.example.com/cgi-bin">
    #       AllowOverride None
    #       Options +ExecCGI -Includes
    #       Order allow,deny
    #       Allow from all
    #    </directory>
    
    # UserDir: The name of the directory that is appended onto a user's home
    # directory if a ~user request is received.
    #
    # To disable it, simply remove userdir from the list of modules in APACHE_MODULES
    # in /etc/sysconfig/apache2.
    #
    <ifModule mod_userdir.c>
    # Note that the name of the user directory ("public_html") cannot simply be
    # changed here, since it is a compile time setting. The apache package
    # would have to be rebuilt. You could work around by deleting
    # /usr/sbin/suexec, but then all scripts from the directories would be
    # executed with the UID of the webserver.
    UserDir public_html
    # The actual configuration of the directory is in
    # /etc/apache2/mod_userdir.conf.
    Include /etc/apache2/mod_userdir.conf
    # You can, however, change the ~ if you find it awkward, by mapping e.g.
    # http://www.example.com/users/karl-heinz/ --> /home/karl-heinz/public_html/
    #AliasMatch ^/users/([a-zA-Z0-9-_.]*)/?(.*) /home/$1/public_html/$2
    </ifModule>
    
    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    <directory "/srv/www/vhosts/dl.opensuse.or.id">
    
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs-2.2/mod/core.html#options
    # for more information.
    #
    Options All
    #Indexes FollowSymLinks
    
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None
    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
    </directory>
    </virtualHost>
    ########################################################################
    
  4. Change the configuration according your purposes
  5. After completing the first virtual host configuration, repeat the same way to second virtual host configuration
  6. Note : for better checking (it should be o real condition), don’t forget to separate home folder for both virtualhost by changing DocumentRoot configuration. I create a new text file called   this-is-dl-location.txt on  /srv/www/vhosts/dl.opensuse.or.id and this-is-download-location.txt on  /srv/www/vhosts/download.opensuse.or.id.  By setting this, browsing http://dl.opensuse.or.id will be refer to  /srv/www/vhosts/dl.opensuse.or.id and diplaying it’s content : this-is-dl-location.txt
  7. Restart Apache service :
    service apache2 restart
  8. Edit /etc/hosts and add 2 address :  dl.opensuse.or.id and download.opensuse.or.id both with same address (your local IP address)  or add an address record into your DNS Server. We need this step to bring the request for virtual address into correct address
  9. Testing the virtual host with the url : http://dl.opensuse.or.id and http://download.opensuse.or.id
  10. BEWARE : Don’t forget to add prefix NameVirtualHost *:80 into your virtual host configuration. This is a general bug on many tutorial regarding Apache & VirtualHost setup on openSUSE. Without this prefix, virtual host will only refer to same folder

On next part, we will discuss YAST usage for configuring Apache Web Server & Virtual Host on openSUSE

Category: OpenSUSE, Web Server  Tags: ,  4 Comments

Apache Web Server & Virtual Host on openSUSE : Part 1

apache_logoApache Web Server maybe one of such popular server application and those are so many articles describes an implementation how to &  Apache Web Server tutorial on openSUSE. Even with so many tutorial regarding Apache and virtual host on openSUSE, I’m going to mad for about 2 days finding why Apache virtual host doesn’t work as it should be.

The problem maybe related to my  fault but I don’t want any openSUSE fans going to be mad for about a days only for setup Virtual Host on openSUSE :-) . Another reason why I writing the tutorial is because I must preparing a good tutorial for Indonesian openSUSE monthly meeting next Saturday.

Tutorial will be divided into 3 part. Initial part is about Apache installation and simple setup to make “it Works !”. The second part will describe about virtual host setup using text configuration and the third part will describe graphical method, an implementation of YAST2 Web Server for setting up Apache and virtual host. Let’s move on the part 1 : Installing and simple configuration

*****

INSTALLATION

Installation using  YAST

  1. Open YAST | Software | Software Management
  2. Change the Filter choice from Search to  Patterns
    setting web
  3. Scroll down the option and choose Server Functions
  4. Thick down  Web and LAMP Server
  5. Click Accept and follow the installation wizard

Installation using Konsole/Terminal

  1. Open Konsole / Terminal (ALT+F2, konsole)
  2. Run the following command:
  3. zypper in -t pattern lamp_server

Simple Configuration

Running the Service

  1. Open YAST | System | System Services (Runlevel)
  2. Find the service name :  Apache2
  3. Click  start and Enable
  4. we would also activating and running the service using konsole by running this command from konsole :
  5. chkconfig --add apache2
    chkconfig apache2 on
    service apache2 restart

Activating Index File

For security reason, openSUSE disabling unindexed folder. If we try to browse the folder without index.html, it will shocked us with error message “Access Forbidden”. We may add the index file (e.g : index.php) into Apache configuration or change the index behaviouras describe below  :

  1. Open file /etc/apache2/server-default.conf
  2. Go to the position of DocumentRoot  configuration (see below)
  3. #
    # Configure the DocumentRoot
    #
    <directory "/srv/www/htdocs">
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs-2.2/mod/core.html#options
    # for more information.
    Options None
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    AllowOverride None
    # Controls who can get stuff from this server.
    Order allow,deny
    Allow from all
    </directory>
  4. Change Options None into Options All. We may also using another option (Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews). Please refer to http://httpd.apache.org/docs-2.2/mod/core.html#options for further information
  5. Restart Apache
  6. service apache2 restart

Testing the Web Server

  1. Open your browser
  2. Type this address : http://ip-address-web-server or http://hostname or http://localhost (The last option will only be used on your local computer). Contoh : http://192.168.100.1 atau http://vavai.vavai.com
  3. If you get the nice information It Works! then you passed the first part of Apache setting :-)

Note

  1. openSUSE used /srv/www/htdocs as default home folder
  2. Apache configuration could be found at /etc/apache2
  3. If you used Firewall, make an exceptin for port 80 unless you used another port. Port  80 is a standar port for Apache Web Server
Category: OpenSUSE, Web Server  Tags: ,  8 Comments

Switch to our mobile site