Setting up Apache2 VirtualHost to run multiple sites locally Ubuntu 16.04
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!
server apache2 localhost hosting
add a comment |
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!
server apache2 localhost hosting
add a comment |
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!
server apache2 localhost hosting
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!
server apache2 localhost hosting
server apache2 localhost hosting
edited 10 hours ago
pa4080
14.4k52670
14.4k52670
asked 10 hours ago
ellenellen
1738
1738
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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 directive IncludeOptional sites-enabled/*.conf
in the main conf. file /etc/apache2/apache2.conf
. So:
# remove the previously created symbolic link
sudo rm /etc/apache2/sites-enabled/my-site.com
# rename the configuration file
sudo mv /etc/apache2/sites-available/my-site.com{,.conf}
# enable the configuration file (create the symlink); use 'a2dissite' to disable
sudo a2ensite my-site.com.conf
# restart Apache2:
sudo systemctl restart apache2.service
Don't forget to flush your browser's cache and try to access your site.
Thank you! This worked
– ellen
7 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1123314%2fsetting-up-apache2-virtualhost-to-run-multiple-sites-locally-ubuntu-16-04%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 directive IncludeOptional sites-enabled/*.conf
in the main conf. file /etc/apache2/apache2.conf
. So:
# remove the previously created symbolic link
sudo rm /etc/apache2/sites-enabled/my-site.com
# rename the configuration file
sudo mv /etc/apache2/sites-available/my-site.com{,.conf}
# enable the configuration file (create the symlink); use 'a2dissite' to disable
sudo a2ensite my-site.com.conf
# restart Apache2:
sudo systemctl restart apache2.service
Don't forget to flush your browser's cache and try to access your site.
Thank you! This worked
– ellen
7 hours ago
add a comment |
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 directive IncludeOptional sites-enabled/*.conf
in the main conf. file /etc/apache2/apache2.conf
. So:
# remove the previously created symbolic link
sudo rm /etc/apache2/sites-enabled/my-site.com
# rename the configuration file
sudo mv /etc/apache2/sites-available/my-site.com{,.conf}
# enable the configuration file (create the symlink); use 'a2dissite' to disable
sudo a2ensite my-site.com.conf
# restart Apache2:
sudo systemctl restart apache2.service
Don't forget to flush your browser's cache and try to access your site.
Thank you! This worked
– ellen
7 hours ago
add a comment |
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 directive IncludeOptional sites-enabled/*.conf
in the main conf. file /etc/apache2/apache2.conf
. So:
# remove the previously created symbolic link
sudo rm /etc/apache2/sites-enabled/my-site.com
# rename the configuration file
sudo mv /etc/apache2/sites-available/my-site.com{,.conf}
# enable the configuration file (create the symlink); use 'a2dissite' to disable
sudo a2ensite my-site.com.conf
# restart Apache2:
sudo systemctl restart apache2.service
Don't forget to flush your browser's cache and try to access your site.
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 directive IncludeOptional sites-enabled/*.conf
in the main conf. file /etc/apache2/apache2.conf
. So:
# remove the previously created symbolic link
sudo rm /etc/apache2/sites-enabled/my-site.com
# rename the configuration file
sudo mv /etc/apache2/sites-available/my-site.com{,.conf}
# enable the configuration file (create the symlink); use 'a2dissite' to disable
sudo a2ensite my-site.com.conf
# restart Apache2:
sudo systemctl restart apache2.service
Don't forget to flush your browser's cache and try to access your site.
edited 31 mins ago
answered 9 hours ago
pa4080pa4080
14.4k52670
14.4k52670
Thank you! This worked
– ellen
7 hours ago
add a comment |
Thank you! This worked
– ellen
7 hours ago
Thank you! This worked
– ellen
7 hours ago
Thank you! This worked
– ellen
7 hours ago
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1123314%2fsetting-up-apache2-virtualhost-to-run-multiple-sites-locally-ubuntu-16-04%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown