/ home / user / Projects中的PHP项目 - 如何配置apache?
I have a PHP project located at:
/home/hommer/Projects/Joomla
I know that if I place the project itself in /var/www/Joomla
it would work, but how can I tell Apache to go and look in that directory, or if in the future I have another directory, to look into that other directory too?
I am under Ubuntu 12.10.
我有一个PHP项目位于: p>
/ home / hommer / Projects / Joomla
code> pre>
我知道如果我将项目本身放在 / var / www / Joomla code>中,它会起作用, 但是我怎么能告诉Apache去查看那个目录,或者将来我还有另一个目录,看看那个其他目录呢? p>
我在Ubuntu 12.10下。
div>
You could use a symlink (symbolic link) in /var/www to point to /home/hommer/Projects/Joomla.
$ cd /var/www
$ sudo ln -s /home/hommer/Projects/Joomla Joomla
Then you will have to configure the right permissions.
Also, if you want to do that, check that your Apache configuration allows this, by adding FollowSymLinks
in /etc/apache2/sites-available/000-default.conf (or the config file you're using for /var/www):
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
...
</Directory>
Eventually, the complete path must be executable by Apache, so you can do that:
$ sudo o+x chmod /home /home/hommer /home/hommer/Projects /home/hommer/Projects/Joomla
Open httpd.conf
and search for this directive: <Directory "/var/www/Joomla">
There you can point to a new directory, in your situation: <Directory "/home/hommer/Projects/Joomla">
then reload Apache configuration:
sudo reload apache2
Generally Apache will look in the public folder which should be located in the root of your project directory. You can configure Apache on a project level by placing .htaccess file also in your project directory, and provide Apache directives related to your project. In .htaccess you can tell Apache to look for any file, by your specification. Also if you are on Ubuntu (not only Ubuntu) you can change host name (/etc/hosts) , and add new Apache virtual hosts (/etc/apache2/sites-enabled).