1

I am new to this and I searched everywhere for a server routing method to be able to store 2 sites at different paths to a single domain. Most help I found refers to using virtual host to multiple domains, subdomains, IP etc. So far non of them fits what I need.

So I have the latest stack of Apache2, PHP, MySQL, on Debian-8 with 2 functional sites (databases, users, ...all OK) installed on sub folders of /html:

crm_site under /var/www/html/crm (storing a php script for project tracking)

and

wp_site under /var/www/html/wordpress (storing a wordpress website).

I want to be able to access them using the only domain I own (say www.example.com) which I already have set up to reach my server. I was hoping that I would only need to add the path to my domain (www.example.com/crm/index.php or www.example.com/wordpress/index.php) and they will be served, but no matter what I add after the domain, the browser leads to the same place, showing the directory list in html (that is crm, and wordpress).

Can anyone tell me how can this be done? Thank you.

S.I.
  • 3,250
  • 12
  • 48
  • 77
Leo M
  • 11
  • 1

1 Answers1

0

it sounds like you have everything setup correctly with the exception of your starting Directory.

It may be best to reword your question. This seems to be your situation (speaking from your perspective):

  1. have a website at http://machine.domain.com
  2. I want to set /var/www/html as my default directory
  3. I want to set index.php as my default document

Once you view your issue this way, it is greatly simplified. A search engine can help you at this point.

To further guide you, doing said search for "apache set default directory" on Google, for instance, has the answer in bold. ... change the root directory of Apache or move the project to /var/www/html

You've already done this, right? So 1. and 2. above are done. If not, look at the following (which assumes apache2 package on Ubuntu latest. i've tested this in a docker container):

file: /etc/apache2/apache2.conf

contents:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Change the above /var/www/ to /var/www/html/

Next, the .php serving issue. This is controlled by the DirectoryIndex directive as referenced here. Looking at it's contents shows that index.php is enabled by default.

example:

root@b62dsa09327e:/# grep -rnw '/etc/apache2/' -e "DirectoryIndex"
/etc/apache2/mods-available/dir.conf:2: DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

This takes care of 3. And now we're all out of issues in your original question.

Note: you may have to chown the directory to whatever apache2 is running as in the event you dropped files in there as root. You'll also have to restart apache in order to have the changes above reflect in the service.

CamiloSan
  • 1
  • 2
  • Thanks. You are probably right about something not being configured correctly (or not at all) in order to allow php; the server keeps coming back to the document_root. Not sure w – Leo M Oct 20 '16 at 06:00
  • Not sure what exactly, I was hoping for more direct clues (major newbie here), but I'll keep digging through the links spurring from your comment. – Leo M Oct 20 '16 at 06:02
  • i think you might get more traction if you simplify your question, which would then end up making your question look just like your config file. I'll update my answer in kind to show you... – CamiloSan Oct 24 '16 at 17:57