Reputation: 9900
I installed LAMP on a new EC2 server and via the public IP address I can see the default Ubuntu webpage as loaded by my new apache server.
My problems began when I created a new directory, simply called test, alongside the original html directory. In test, I created index.html with the content "Test page responding and loading ...".
So, I then copy /etc/apache2/sites-available/000-default.conf
to test.conf and set DocumentRoot /var/www/test
.
I enabled the virtualhost by sudo a2ensite test.conf
and restarted the server with sudo service apache2 reload
.
In my browser, when I visit the IP address I get the ubuntu page as loaded by apache. I then append /test
to the end of the IP address and I get a Not found: The requested URL /test was not found on this server. error.
I disabled the 000-default.conf
virtualhost, just out of curiosity, and restarted the server. My output from test/index.html
loads in a browser using just the IP address - which I did not expect.
ServerAdmin webmaster@localhost DocumentRoot /var/www/test
Options Indexes FollowSymLinks AllowOverride All Require all granted
I'm trying to simply serve test/index.html when I visit .../test in my browser.
Upvotes: 0
Views: 806
Reputation: 17872
If you don't want Apache to select the default virtual host (the first one for a given host+port) you'll need to use ServerName
or ServerAlias
in your added virtual host to make sure it matches the hostname/address you're using in the browser.
apachectl -S
will summarize your vhosts.
Upvotes: 1