Friday, October 26, 2012

Configuring Apache2 Virtual Host - Creating a working Directory

Depending on the apache2 version and environment, the configuration has some different details.

Below, you get  summarized procedures to install on Windows 7 and Debian 5.



WINDOWS 7

Edit:

$INSTALL_DIR\conf\httpd.conf

Usually at:
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf

and find:
    # Redirect permanent /foo http://localhost/bar
then add the following:       

        # mapping dev.php directory
        Alias /devphp "D:/work/dev/php"
       
                Options Indexes MultiViews
                AllowOverride None
                Order allow,deny
                Allow from all
       



See additional examples on debian section below.


DEBIAN 5

If a directory requires permission, such as $HOME (the user's home), then it's required to add the user to the apache2's data group.
Below you find three examples (yellow).



# adding a new user to apache2 data group:
 sudo adduser www-data user1
# checking:
 groups www-data
# edit the file:
 /etc/apache2/sites-available/default
# and add the following at the end but before the </VirtualHost> tag:

<VirtualHost *:80>
    ...
        # usual configuration on debian to share local files
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    # configuration for local development purpose without requiring to add users to apache2's www-data group
    Alias /dev "/home/dev"
  <Directory "/home/dev">
      Options Indexes MultiViews FollowSymLinks
      AllowOverride None
      Order deny,allow
      Deny from all
      #Allow from all
      Allow from 127.0.0.0/255.0.0.0 ::1/128
      #DirectoryIndex index.html
 </Directory>

    # configuration for personal local development purpose requiring to add the user to apache2's www-data group
    Alias /devphp "/home/alsdias/work/dev/php"
  <Directory "/home/alsdias/work/dev/php">
      Options Indexes MultiViews FollowSymLinks
      AllowOverride None
      Order deny,allow
      Deny from all
      #Allow from all
      Allow from 127.0.0.0/255.0.0.0 ::1/128
      #DirectoryIndex index.html
  </Directory>
</VirtualHost>
   
# restart service:
sudo /etc/init.d/apache2 restart


NOTE:

Notice the following directions.
They are important and are self-explained:

      #Allow from all
      Allow from 127.0.0.0/255.0.0.0 ::1/128
      #DirectoryIndex index.html



No comments:

Post a Comment

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...