Usually, we have to put our web application inside the document root of Apache in order to make the application accessible from the network. However, there is a trick to make the web application still accessible even though we put it outside of Apache's document root. Yes, this can be done by creating a virtual directory.
Apache mod_aliasTo be able to create a virtual directory, an Apache module named mod_alias must be loaded. To ensure that, we can open the httpd.conf file and look for lines like this.
LoadModule alias_module modules/mod_alias.soIf there is a "#" character preceeding that line, You have to delete that character first then restart your Apache.
Editing httpd.conf
If Apache mod_alias has been loaded, we can try to create the virtual directory. Open the httpd.conf, then searh the
<ifmodule alias_module> # ADD THIS LINES FOR YOUR VIRTUAL DIRECTORIES lias /project1 /home/me/web/project1 Alias /project2 /home/me/web/project2 Alias /project3 /home/me/web/project3 </ifmodule>As you can see, the syntax for creating a virtual directory is quite simple. In the example above, we create an alias or virtual directory named /project1 and also specify its physical location , in the example its physical location is in /home/me/web/project1. We can also create more than one virtual directory using the same syntax.
The job has not finished yet. We still need to do some configuration for that virtual directory. We can do that by adding these lines.
# SETTING DIRECTORY FOR /home/me/web/project1 <Directory "/home/me/web/project1"> Options None AllowOverride All Order allow,deny Allow from all </Directory>The most common configuration is like the example above. In this example we configure the directory /home/me/web/project1 used by the virtual directory /project1. If we have more than one virtual directory, we must add syntax above as many as the number of virtual directories we have.
We have to restart Apache to make the configuration changes take effect.
(http://w3shaman.com/article/creating-virtual-directory-apache)
Không có nhận xét nào:
Đăng nhận xét