1

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.

Hommer Smith
  • 26,772
  • 56
  • 167
  • 296
  • 2
    Have you tried anything? There are many tutorials on how to configure Apache including changing www-root directory. – Jakub Matczak Feb 01 '14 at 21:14
  • dragoste, I have read through tutorials and I haven't been able to figure out. That's why I asked. – Hommer Smith Feb 01 '14 at 21:32
  • I don't wanna change www-root directory, I just want it to take into accounts other directories. – Hommer Smith Feb 01 '14 at 21:33
  • You probably need to configure VirtualHost. But since it's directory will be outside www-root directory, there may be some issues with access permissions etc. Try something, then come back to us if you won't be able to handle this on your own. But only if you have a specific problem! – Jakub Matczak Feb 01 '14 at 21:35
  • dragoste, the problem is specific, don't you think? – Hommer Smith Feb 01 '14 at 21:44
  • Nope. Problem is specific, when you tried something and it didn't work. Then we are here to fix it. Now, you just want us to do the whole job for you. – Jakub Matczak Feb 01 '14 at 23:23

3 Answers3

1

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
H Aßdøµ
  • 2,925
  • 4
  • 26
  • 37
1

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
Jivan
  • 21,522
  • 15
  • 80
  • 131
  • Why would the symlink be at /Joomla? That is going to put it in the "/". Shouldn't it be just Joomla? – Hommer Smith Feb 01 '14 at 21:51
  • Yeah you're right - I don't know how this "/" landed there :) – Jivan Feb 01 '14 at 21:55
  • Hi Jivan. I have FollowSymLinks in my configuration. But when trying to access the Joomla folder, I see the following "You don't have permission to access /Joomla/test.php on this server." Which kind of permisisons/groups should I set? – Hommer Smith Feb 01 '14 at 21:57
  • Hi. This question is tricky to be answered in a comment :) You have a fully explained, quite complete answer in this SO topic here: http://stackoverflow.com/questions/7381371/apache-wont-follow-symlinks-403-forbidden - and also here on AskUbuntu: http://askubuntu.com/questions/142084/apache-gives-403-forbidden – Jivan Feb 01 '14 at 21:59
  • @HommerSmith I just edited my answer. It was not so long after all :) – Jivan Feb 01 '14 at 22:07
0

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).

Miroslav Trninic
  • 3,327
  • 4
  • 28
  • 51