I have had a site I was working on running in /var/www/html for a while. I'm starting a new project and would like to run another site locally.
After some googling, I was checking out this previous question: https://ubuntuforums.org/showthread.php?t=1423044
I created a folder in /var/www
called my-site
and just cloned the git repo I will be using in there for the time being.
Then I added a file called my-site.com.conf
to /etc/apache2/sites-enabled
. Here's what it looks like:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName www.my-site.com
DocumentRoot /var/www/my-site/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/my-site/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I added the following to /etc/hosts
:
127.0.0.1 www.my-site.com
I also ran the following command within /etc/apache2/sites-enabled
:
ln -sf /etc/apache2/sites-available/my-site.com /etc/apache2/sites-enabled/my-site.com
The problem is that when I go in my browser to my-site.com
, I am redirected to the old site that I had running on localhost before. My old site doesn't allow a user to go anywhere until they have logged in, and it seems like I am consistently being redirected to the login page.
How do I access my new site and set up an environment where I can work on both of these projects?
Let me know if I need to provide more information.
Thanks!
The content of your configuration file looks good. The problem is the filename -
my-site.com
. The configuration file must end with.conf
, otherwise it wouldn't be included in the Apache's configuration by the directiveIncludeOptional sites-enabled/*.conf
in the main conf. file/etc/apache2/apache2.conf
. So:Don't forget to flush your browser's cache and try to access your site.