Background:
I've installed Apache 2 and have tried set up virtual directories... but when I try to test the different sites, I keep getting 404 error messages.
The article/tutorial I've been following is How To Configure the Apache Web Server on an Ubuntu or Debian VPS.
I have the following folder structure in place:
/var/www/webtest.com/test.html
/var/www/ttimes.com/test.php
In the /etc/apache2/sites-available folder, I have the following configuration files:
cd /etc/apache2/sites-available
ls -lah /var/www/
Output:
total 44K
drwxr-xr-x 9 root root 4.0K Jul 28 21:37 .
drwxr-xr-x 15 root root 4.0K Jul 28 19:54 ..
drwxr-xr-x 2 root root 4.0K May 11 2013 current
drwxr-xr-x 2 root root 4.0K Apr 3 08:21 html
-rwxr-xr-x 1 root root 177 Nov 23 2013 index.html
-rwxr-xr-x 1 root root 124 Jul 28 20:14 test.php
drwxr-xr-x 5 jmj root 4.0K Jun 6 11:58 ttimes.com
drwxr-xr-x 2 jmj root 4.0K Jul 28 21:21 webtest.com
Here's what the webtest.com.conf file looks like:
<VirtualHost *:80>
ServerAdmin admin@webtest.com
ServerName webtest.com
ServerAlias www.webtest.com
DocumentRoot /var/www/webtest.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Here's what my hosts file looks like:
127.0.0.1 localhost
127.0.1.1 cp-AOA150
This is all just on a local development box where I want to have multiple sites located under /var/www. Once the site is developed, I'm going to move them to my hosting company. I currently don't have other IP addresses to add, so I skipped the step of adding VPS server IP addresses.
I am able to successfully run the
sudo a2ensite webtest.com.conf
command and I restart Apache.
But when I go to my site by typing http://localhost/webtest.com/test.html
, I get a 404 not found error.
What I've tried so far:
I've reviewed the article to make sure I didn't miss any steps.
proved that Apache itself is working by going to http://localhost.
When I do that, I get a page that reads:
Index of /
[ICO] Name Last modified Size Description
Apache/2.4.7 (Ubuntu) Server at localhost Port 80
Then I stop the Apache service and try the same URL. It fails.
You have it set up as a virtual host pointing to webtest.com, but you're trying to access it through localhost/. With a VirtualHost, it doesn't exist in that path.
The easiest way is to edit your /etc/hosts file to make a local DNS entry for webtest.com. Add a line to that file like this:
127.0.0.1 webtest.com
Then point your browser to webtest.com, and you should see your site.