The Apache web server is the most popular way of serving web content on the internet. It accounts for more than half of all active websites on the internet and is extremely powerful and flexible.
Apache breaks its functionality and components into individual units that can be customized and configured independently. The basic unit that describes an individual site or domain is called a virtual host
.
These designations allow the administrator to use one server to host multiple domains or sites off of a single interface or IP by using a matching mechanism. This is relevant to anyone looking to host more than one site off of a single VPS.
Each domain that is configured will direct the visitor to a specific directory holding that site’s information, never indicating that the same server is also responsible for other sites. This scheme is expandable without any software limit as long as your server can handle the load.
In this guide, we will walk you through how to set up Apache virtual hosts on an Ubuntu 14.04 VPS. During this process, you’ll learn how to serve different content to different visitors depending on which domains they are requesting.
Before you begin this tutorial, you should create a non-root user as described in steps 1-4 here.
You will also need to have Apache installed in order to work through these steps. If you haven’t already done so, you can get Apache installed on your server through apt-get
:
sudo apt-get update
sudo apt-get install apache2
After these steps are complete, we can get started.
For the purposes of this guide, my configuration will make a virtual host for example.com
and another for test.com
. These will be referenced throughout the guide, but you should substitute your own domains or values while following along.
To learn how to set up your domain names with DigitalOcean, follow this link. If you do not have domains available to play with, you can use dummy values.
We will show how to edit your local hosts file later on to test the configuration if you are using dummy values. This will allow you to test your configuration from your home computer, even though your content won’t be available through the domain name to other visitors.
The first step that we are going to take is to make a directory structure that will hold the site data that we will be serving to visitors.
Our document root
(the top-level directory that Apache looks at to find content to serve) will be set to individual directories under the /var/www
directory. We will create a directory here for both of the virtual hosts we plan on making.
Within each of these directories, we will create a public_html
folder that will hold our actual files. This gives us some flexibility in our hosting.
For instance, for our sites, we’re going to make our directories like this:
<pre> sudo mkdir -p /var/www/<span class=“highlight”>example.com</span>/public_html sudo mkdir -p /var/www/<span class=“highlight”>test.com</span>/public_html </pre>
The portions in red represent the domain names that we are wanting to serve from our VPS.
Now we have the directory structure for our files, but they are owned by our root user. If we want our regular user to be able to modify files in our web directories, we can change the ownership by doing this:
<pre> sudo chown -R $USER:$USER /var/www/<span class=“highlight”>example.com</span>/public_html sudo chown -R $USER:$USER /var/www/<span class=“highlight”>test.com</span>/public_html </pre>
The $USER
variable will take the value of the user you are currently logged in as when you press “ENTER”. By doing this, our regular user now owns the public_html
subdirectories where we will be storing our content.
We should also modify our permissions a little bit to ensure that read access is permitted to the general web directory and all of the files and folders it contains so that pages can be served correctly:
sudo chmod -R 755 /var/www
Your web server should now have the permissions it needs to serve content, and your user should be able to create content within the necessary folders.
We have our directory structure in place. Let’s create some content to serve.
We’re just going for a demonstration, so our pages will be very simple. We’re just going to make an index.html
page for each site.
Let’s start with example.com
. We can open up an index.html
file in our editor by typing:
<pre> nano /var/www/<span class=“highlight”>example.com</span>/public_html/index.html </pre>
In this file, create a simple HTML document that indicates the site it is connected to. My file looks like this:
<pre> <html> <head> <title>Welcome to <span class=“highlight”>Example.com</span>!</title> </head> <body> <h1>Success! The <span class=“highlight”>example.com</span> virtual host is working!</h1> </body> </html> </pre>
Save and close the file when you are finished.
We can copy this file to use as the basis for our second site by typing:
<pre> cp /var/www/<span class=“highlight”>example.com</span>/public_html/index.html /var/www/<span class=“highlight”>test.com</span>/public_html/index.html </pre>
We can then open the file and modify the relevant pieces of information:
<pre> nano /var/www/<span class=“highlight”>test.com</span>/public_html/index.html </pre> <pre> <html> <head> <title>Welcome to <span class=“highlight”>Test.com</span>!</title> </head> <body> <h1>Success! The <span class=“highlight”>test.com</span> virtual host is working!</h1> </body> </html> </pre>
Save and close this file as well. You now have the pages necessary to test the virtual host configuration.
Virtual host files are the files that specify the actual configuration of our virtual hosts and dictate how the Apache web server will respond to various domain requests.
Apache comes with a default virtual host file called 000-default.conf
that we can use as a jumping off point. We are going to copy it over to create a virtual host file for each of our domains.
We will start with one domain, configure it, copy it for our second domain, and then make the few further adjustments needed. The default Ubuntu configuration requires that each virtual host file end in .conf
.
Start by copying the file for the first domain:
<pre> sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/<span class=“highlight”>example.com</span>.conf </pre>
Open the new file in your editor with root privileges:
<pre> sudo nano /etc/apache2/sites-available/<span class=“highlight”>example.com</span>.conf </pre>
The file will look something like this (I’ve removed the comments here to make the file more approachable):
<pre> <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> </pre>
As you can see, there’s not much here. We will customize the items here for our first domain and add some additional directives. This virtual host section matches any requests that are made on port 80, the default HTTP port.
First, we need to change the ServerAdmin
directive to an email that the site administrator can receive emails through.
<pre> ServerAdmin <span class=“highlight”>admin@example.com</span> </pre>
After this, we need to add two directives. The first, called ServerName
, establishes the base domain that should match for this virtual host definition. This will most likely be your domain. The second, called ServerAlias
, defines further names that should match as if they were the base name. This is useful for matching hosts you defined, like www
:
<pre> ServerName <span class=“highlight”>example.com</span> ServerAlias <span class=“highlight”>www.example.com</span> </pre>
The only other thing we need to change for a basic virtual host file is the location of the document root for this domain. We already created the directory we need, so we just need to alter the DocumentRoot
directive to reflect the directory we created:
<pre> DocumentRoot /var/www/<span class=“highlight”>example.com</span>/public_html </pre>
In total, our virtualhost file should look like this:
<pre> <VirtualHost *:80> ServerAdmin <span class=“highlight”>admin@example.com</span> ServerName <span class=“highlight”>example.com</span> ServerAlias <span class=“highlight”>www.example.com</span> DocumentRoot /var/www/<span class=“highlight”>example.com</span>/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> </pre>
Save and close the file.
Now that we have our first virtual host file established, we can create our second one by copying that file and adjusting it as needed.
Start by copying it:
<pre> sudo cp /etc/apache2/sites-available/<span class=“highlight”>example.com</span>.conf /etc/apache2/sites-available/<span class=“highlight”>test.com</span>.conf </pre>
Open the new file with root privileges in your editor:
<pre> sudo nano /etc/apache2/sites-available/<span class=“highlight”>test.com</span>.conf </pre>
You now need to modify all of the pieces of information to reference your second domain. When you are finished, it may look something like this:
<pre> <VirtualHost *:80> ServerAdmin <span class=“highlight”>admin@test.com</span> ServerName <span class=“highlight”>test.com</span> ServerAlias <span class=“highlight”>www.test.com</span> DocumentRoot /var/www/<span class=“highlight”>test.com</span>/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> </pre>
Save and close the file when you are finished.
Now that we have created our virtual host files, we must enable them. Apache includes some tools that allow us to do this.
We can use the a2ensite
tool to enable each of our sites like this:
<pre> sudo a2ensite <span class=“highlight”>example.com</span>.conf sudo a2ensite <span class=“highlight”>test.com</span>.conf </pre>
When you are finished, you need to restart Apache to make these changes take effect:
sudo service apache2 restart
You will most likely receive a message saying something similar to:
* Restarting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
This is a harmless message that does not affect our site.
If you haven’t been using actual domain names that you own to test this procedure and have been using some example domains instead, you can at least test the functionality of this process by temporarily modifying the hosts
file on your local computer.
This will intercept any requests for the domains that you configured and point them to your VPS server, just as the DNS system would do if you were using registered domains. This will only work from your computer though, and is simply useful for testing purposes.
Make sure you are operating on your local computer for these steps and not your VPS server. You will need to know the computer’s administrative password or otherwise be a member of the administrative group.
If you are on a Mac or Linux computer, edit your local file with administrative privileges by typing:
sudo nano /etc/hosts
If you are on a Windows machine, you can find instructions on altering your hosts file here.
The details that you need to add are the public IP address of your VPS server followed by the domain you want to use to reach that VPS.
For the domains that I used in this guide, assuming that my VPS IP address is 111.111.111.111
, I could add the following lines to the bottom of my hosts file:
<pre> 127.0.0.1 localhost 127.0.1.1 guest-desktop 111.111.111.111 <span class=“highlight”>example.com</span> 111.111.111.111 <span class=“highlight”>test.com</span> </pre>
This will direct any requests for example.com
and test.com
on our computer and send them to our server at 111.111.111.111
. This is what we want if we are not actually the owners of these domains in order to test our virtual hosts.
Save and close the file.
Now that you have your virtual hosts configured, you can test your setup easily by going to the domains that you configured in your web browser:
<pre> http://<span class=“highlight”>example.com</span> </pre>
You should see a page that looks like this:
Likewise, if you can visit your second page:
<pre> http://<span class=“highlight”>test.com</span> </pre>
You will see the file you created for your second site:
If both of these sites work well, you’ve successfully configured two virtual hosts on the same server.
If you adjusted your home computer’s hosts file, you may want to delete the lines you added now that you verified that your configuration works. This will prevent your hosts file from being filled with entries that are not actually necessary.
If you need to access this long term, consider purchasing a domain name for each site you need and setting it up to point to your VPS server.
If you followed along, you should now have a single server handling two separate domain names. You can expand this process by following the steps we outlined above to make additional virtual hosts.
There is no software limit on the number of domain names Apache can handle, so feel free to make as many as your server is capable of handling.
<div class=“author”>By Justin Ellingwood</div>
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Got stuck at the “Create the First Virtual Host File” step: my droplet has a file called “default” and “default-ssl” in sites-available, not “default.conf” as stated. And is the subsequent statement: “The default Ubuntu configuration requires that each virtual host file end in .conf.” still correct?
Look for 000-default.conf
@michaelleblanc1: It sounds like you are on a different Ubuntu release, perhaps 12.04. This tutorial is specifically talking about 14.04 where the file has been renamed from simply “default” to “000-default.conf” Assuming that you are on 12.04, you should be fine, but you might also want to take a look at this article:
https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts
Thanks for this great tutorial. My primary virtual host (ie example.com) is alive and well.
My droplet’s ip address still points to /var/www/html though and provides the “Apache2 Ubuntu Default Page”. I would like my ip to point to the new virtual host I created and hence to /var/www/test.com/public_html. How can I achieve this result?
Thank you.
You have to “sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf”. The conf file tells the server where to direct traffic. Reread “Step Four — Create New Virtual Host Files”. Let me know if I can help further.
you have disable the 000-default.conf
sudo a2dissite 000-default.conf
Thanks,its works!
**A million like for you **
Thank you, you save my day.
thanks!
@Kerem: Do you still have the default configuration enabled? If so, edit the file “/etc/apache2/sites-enabled/000-default.conf” and change “DocumentRoot /var/www/html” to “DocumentRoot /var/www/test.com/public_html”
Hi, I’ve set up two virtual hosts like the article details and I’m having a similar issue to @kerem I want to be able to host two websites on the server, but in the /sites-enabled/000-default.conf there is only space for one (1) document root. How do I add in /var/www/doc/public_html and /var/www/morgan/public_html? I’ve done (and triple checked) the settings and files in this article. and I’m not sure what I’m missing.
@MorganJohnstone: Hello!
To serve two websites with Apache, you’ll have to create a virtual host for each. The main sections that deals with this is Steps 4 and 5.
You’ll want a virtual host file (a file that contains the configuration for a site between
<VirtualHost *:80>
and</VirtualHost>
tags) for each of your sites. In one of them, you can have the document root pointed at/var/www/doc/public_html
, and in the other, you can have the document root pointed at/var/www/morgan/public_html
.The
ServerName
andServerAlias
directives in each of these virtual hosts will determine which content will be served by matching the values against the client’s request.When you’ve finished creating a file for each of your sites, you need to enable them with the
a2ensite
command (this is covered in step 5). Afterwards, be sure to restart Apache.If you’re still having issues after following these steps, post back with exactly what is happening. Hope this helps!
@Andrew SB, Thank you very much. This worked perfectly.
Thank you very much… Your guide help me a lot. =)
Hi i had troubles pointing the domain to i’ts directory witch can be fixed by editing example.com.conf before: <VirtualHost *:80>
after: <VirtualHost example.com.conf> Now is working but i’m not sure that this is right solution.
Sorry “which” not "witch ".
I also had to specify <directory /var/www/test.com/public_html/> Require all granted </directory>
in the conf file as per http://httpd.apache.org/docs/2.4/upgrading.html
Posting comment filtered out the <> tags for lt tag directory /var/www/test.com/public_html/ gt tag Require all granted lt tag /directory gt tag
in the conf file as per http://httpd.apache.org/docs/2.4/upgrading.html
It worked for me,by doing this tutorial i learned about config files, command line, and got a website! Thank-you, roosterscomputerrepair.with-linux.com
This works for me for 12.04 just by creating 000-default.conf instead of default default.conf. Now I am looking for how to incorporate secure (https) website as I have startssl.com certificate and key. Thanks for WONDERFUL work D.O.
i got stuck in sudo a2ensite example.com.conf my terminal said “Site example.com does not exist” i miss something, or this tutorial not working in ubuntu 14.10?
The conf must be missing from Apache.
I’m with same errror, where this setting?
happened to me too but then I skipped to edit my hosts file and everything works fine
I’m with same errror, where this setting?
I got an error when command this
a2ensite example.com.conf
instead I proceed to edit my host file
/etc/hosts
Hi @netominas, does
/etc/apache2/sites-available/sitename.conf
exist?yes, you need to create that conf file for each of your domain, then add your domain to the hosts file
ow worked, I was creating the file sitenam without de “.conf”. Tks! :)
does /etc/apache2/ exist? i have to disable http to https redirect pls help
@mulyana2205: Does the file “<code>/etc/apache2/sites-available/example.com.conf</code>” actually exist? When you run “<code>sudo a2ensite</code>” make sure you use the name of the actual file you created.
You don’t have permission to access / on this server.
@kasnca: Do you have an index file in your documentroot?
@kasnca: I was getting the same. Try adding:
<Directory /> Require all granted </Directory>
It worked for me.
i copied the /etc/apache2/sites-available/000-default.conf over to /etc/apache2/sites-available/ididntsee.com.conf and edit it from there but am still getting the default apache 2 page instead of the index.html page
I created two virtual host using two domain names I own and want to host on one droplet. The IP for one is still propagating but the first one is set and shows the default apache2 page.
Scratch the first comment. I started over from scratch, new server with new ip - directed both domain names to new IP, followed all directions including new non-root user and now all I am getting is 404 not found error on one site and “could not connect to isahappyperson.com” error on the other.
I took each step slowly as to not make any mistakes so I have no clue what to do now. Does anyone know what is wrong?
droplet server is on Ubuntu 14.04 LTS
update: I directed the domain names to the new IP in the DO dashboard but failed to change them where I registered the domain names.
So, now one site works fine - is showing the custom index.html but the other site is showing the apache2 default index.html
Any thoughts?
http://www.unixmen.com/setup-virtual-hosts-apache-ubuntu-14-04-lts/
DO is nothing but copy and paste tutorials… I don’t think half of the writers ever try these themselves…
update: ididntsee.com is working www.ididntsee.com is working
isahappyperson.com is NOT working www.isahappyperson.com is working
both .com.conf files are the same except the domain name itself
DocumentRoot /var/www/isahappyperson.com/public_html ServerName isahappyperson.com ServerAlias www.isahappyperson.com
and…
DocumentRoot /var/www/ididntsee.com/public_html ServerName ididntsee.com ServerAlias www.ididntsee.com
So, why is one working and not the other?
Update: Glad to report that all is well and working fine. Had to run a2dissite 000-default then service apache2 restart
All is good now :)
Thanks, all solved now.
What if I need to host my server files outsite /var/www ?
All of my projects are on my Dropbox folder and I simply cannot access them using the default virtualhost configuration on Ubuntu 14.04 + LAMP. I followed your instructions to the letter with no success. All I get is a 403 document with the message “You don’t have permission to access / on this server.”
I tried other tutorials but none has solved my problem.
Here’s my virtual host configuration:
< Virtualhost *:80 > DocumentRoot /home/brunowerneck/Dropbox/Projetos/websites/Site/web Servername site.servidor.home < Directory /home/brunowerneck/Dropbox/Projetos/websites/Site/web/ > AllowOverride All Require all granted < /Directory > < /Virtualhost >
I have also tried to change folder ownership to root, to www-data and back to my user and chmod 755. None worked. Quotation marks on DocumentRoot and Directory directives make no difference.
Any clues?
I did it!
It turns out it was a permissions problem. By further reading Apache2 documentation, I noticed it said I had to give 755 permission on the entire path, not only on my DocumentRoot.
So I did: cd /home/brunowerneck sudo chmod -R 755 Dropbox/
And voilà, everything works as they should! Finally!
Great Tutorial … It is work.
but tis is onlt local how to make for internet …who can help me to make it pls
@thedarkangel771: Are you installing this on a server that has port 80 open to the internet? If you’re doing this on a local computer, you’re most likely behind a router. You’d need to open the port in your router as well, but that’s a little off topic for here.
Exactly what I needed, thank you Justin!! :)
Hi
I used this tutorial and everything worked fine for me. Thanks for that. But I have opposite to usual question. Is it possible to get to this website by an internal ip without editing host file. I would like to avoid it, so everybody in local network could access webpage by ip.
Btw. this website is working perfectly fine by typing URL in web browser from both internal and external network.
Great tutorial, thank you.
How would I go about modifying my files to get my django project running? I tried pointing the document root to my django project, but all I get is a page with the files in my project i.e wsgi.py, urls.py etc. I want to use mod_python but I am not sure what to change.
@cebomakeleni: You need to use
mod_wsgi
. Check out the docs on the Django Project’s site.@bartosz.dega: You can add the IP as an alias of the Virtual host:
Running 14.04 lts 64 bit. Absolutely doesn’t work for me. I have an existing virtual site as: lrwxrwxrwx 1 root root 10 Apr 23 08:54 bpslk -> /ddr/bpslk
As you can see, it’s a soft link to a directory in my “working-data” partition. This works fine. All of the files in /ddr/bpslk are are owned by me, and are set to 644, and all dirs are 755. There is no bpslk.conf file. Entering http://localhost/bpslk takes my browser to the index.html page located in /ddr/bpslk.
So I added a soft link to /ddr/tipitaka and I get a 404 error.
I have a dual-boot machine, so I rebooted in Linux Mint 15, entered the following commands in a terminal sudo cd /var/www sudo ln -s /ddr/tipitaka ./
Then in my browser I typed localhost/tipitaka and it works! The tipitaka home page opens
BTW I’m having the same trouble with Linux Mint 17 which is based on Ubuntu 14.04.
I think there has been some update that has thrown a wrench into the works.
Sure would like to resolve this, as now I have to do my web site development in Mint 15.
-Harry
Hi there, I seem to miss something, I have multiple domains and they all go to toe same droplet, and all of them work properly except one but everything in the virtualhost is same as in the ones that work.
Problem: getbootstraptheme.com works just fine but the www.getbootstraptheme.com returns error, like the domain would not be registered. Can it be that I messed something up in godaddy (the place where domain registered and routed to the droplet) ?? i have duplich.com and www.duplich.com working just fine. both of the domains getbootstraptheme.com and duplich.com are registered at godaddy and routed to the same droplet via IP, but one is working fine and the other is broken… I can not figure out what is happening… Thanks for any advice
@jcausevi: www.getbootstraptheme.com loads fine for me, are you still experiencing this issue?
Hi there,
I don’t have a name for my server yet so how can i setup multiple virtualhosts in a way that i can access them using my ip? Example: http://1.2.3.4/firstapp goes to /home/user1/pythonapp/firstapp and http://1.2.3.4/secondapp goes to /home/user2/pythonapp/secondapp
Is that possible? I tried this configuration but it didn’t work:
Thanks!
@faustovaz: You’ll want to use Apache’s Alias directive. It would look something like:
This worked great for me - all 5 of my “.com” domains worked fine- HOWEVER my 6th domain was a “.biz” site and even though there is nothing out of the ordinary about it’s configuration-- It defaults to the apache welcome page (/var/www/html) - I have removed the 000-default.conf file from both /etc/apache2/sites-available & /etc/apache2/sites-enabled - reloaded apache several times- no change in result for the “.biz” domain.
I had similar issue. The solution was to a2dissite (disable in other words) the
000-default.conf
(don’t delete it):/etc/apache2/sites-available/
folder.sudo a2dissite 000-default.conf
sudo service apache2 restart
Apparently
000-default.conf
was causing errors and blocking my.conf
files. Besides this fix, the tutorial is correct. And I didn’t add any<directory>
bits.@Andrew SB, that worked perfectly. Thank you!
@will: Does its virtualhost file exist in
/etc/apache2/sites-enabled
? Make sureServerName
is set toyourdomain.biz
and it’s pointed to the correct IP address.Stuck at ServerAdmin admin@amazonsurfandshop.com command not found Also tried admin@amazonsurfandshop.com command not found
@benea: These are not commands, they are the lines you need to edit in
/etc/apache2/sites-available/example.com.conf
using nano:Thank you much Kamal. I got it. I think I’m getting dizzy. There are so much thing to do for just configuring the apache2.
I tested the results:
For http://amazonsurfandshop.com -
Apache2 Ubuntu Default Page: It works! With 2 pages detailed explanation.
Not the lines typed in to the index.html - Success! The amazonsurfandshop.com virtual host is working!
For http://test.com
A real web page for test.com showed up.
Is this a success results!
@benea: You need to replace
test.com
with your actual other domain name. :)I don’t have other domain. My only domain is amazonsurfandshop.com.
Does the first result for http://amazonsurfandshop.com work though even it did not come out the message typed in the index.html “Success! The …”
With respect to this Tutorial, is it absolutely necessary to use the public_html folder in setting up virtual hosts, or could you adjust it so that file uploads can go straight into the domain folder? In other words, I would rather set this up so that uploads go straight into
http://yourdomain.com/
rather than…
http://yourdomain.com/public_html
So, is this doable, and if so, what differences in setup from that tutorial are needed?
@info: This article configures Apache2 to serve the contents of
/var/www/domain1.com/public_html
fordomain1.com
, not/var/www/domain1.com
. If you take a closer look at theDocumentRoot
directive, you’ll see that it points to the/var/www/domain1.com/public_html
directory:Important if the virtual allways redirect to default html page : reload under sudo… sudo service apache reload Hope it will help ;)
Thank you so much. This fixed it for me!
Great tutorial!
It was very easy and so clear, thanks a lot!
Thanks, every thing is fine
Just out of curiosity, what’s the reasoning for setting world permission to octal 5? edit: I get that it has to do with the assumption that systems like Wordpress may involved components that assume need to write or have assumptions that might require world at execute, but what exactly then will that do? Is it not a severe security issue? (I will openly admit: I’m not sure what “execute” means in any precise manner in this context.)
I follow this tutorial but no hope, the apache2 won’t serve any of html and images file but PHP file. There is no log in apache.log and error.log …
All i get is no response, no data received. But if i point to php file in the server, it work totally fine.
Do you guys have any idea?
I followed every step of the tutorial and when i finally restart apache2 i get this error;
and when I type in the web address the website doesn’t load. All it says is the requested URL wasn’t found on this server.
This is a great tutorial. Do you have one that describes how to setup ampache with this? I’m trying to get ampache working external to the LAN but cannot access it via port 8080 even though I can access my apache server via web browser externally.
I followed the tutorial, but there is no change happen - I am keep getting the “Apache2 Ubuntu Default” page for the following domain recence.uk - Can someone please tell me where I go wrong.
Aditional Info: I looked at the dir - there is a file exisits /recence.uk/public_html/index.html
All worked!! Thanks alot for the tutorial!
Just 1 question, i have 2 sites, when 1 have a index.php and the other use a index.html it work. But when both have a index.php, my second site dont answer (like if there was no website installed).
I need to configure anything else to make it work?
Thanks!
Clear, concise instructions. Thank you.
Great guide! Really easy to follow! Thanks!
I wish to ask, please tell me as based on the above settings and directory file arrangements, where I should put the website files?, is it to be in; public_html folder with the index.html ? Thanks you in advance to all,
i do that same as your articles but i got same page on both website .plz help me
Hi, I hope my question will not be out of the subject, so if I may ask, the hosts settings on the above examples are what? external IPs (111.111.111.111 example.com) or local ? sorry to ask again but I have a problem to access the websites publicly, it always redirect my websites to my Cisco Router log on page…http://sweetqcorner.com Thank you for any help,
Thanks man
Can anyone tell me why my virtual hosts work when I enable in /etc/host adress 127.0.0.1 instead of 111.111.111.111 like author wrote it in this tutorial? Thank you.
You should replace 111.111.111.111 with the IP address of your server.
Thank you for the answer :)
This comment has been deleted
Thanks for the great tutorial!
a2ensite and other things are okay, i have checked everything as much as i can. The problem is when i try to go example.com or test.com it actually goes to the real website which is already on the internet.
when i try to go file:///var/www/example.com/public_html/index.html it works except php command lines. (I am also incapable of php, but i will someday. Just copied a php command from the internet.)
Little help will be appreciated, I am using Ubuntu 14.04.
Okay i found the solution. I just added 127.0.0.2 example.com 127.0.0.3 test.com to the hosts file with
sudo nano /etc/hosts
111.111.111.111 goes to nowhere, that was my problem. Thanks for the tutorial again.
thanks - clear and concise tutorial.
I got a strange problem.
If I configure the address in my local hostfile it works just fine, but as soon as I remove it I get page not found. If I ping the address it looks up the correct ip but doesn’t get any response.
Any ideas?
Is there a way I can view the sites using the IP address?
eg 123.456.789.10/test.com 123.456.789.10/example.com
I’ve got it to work using Ubuntu 12.04 but not with 14.04
You can add a virtualhost for your IP address that points to
/var/www
which makes all of your domains accessible:Perfect. Thanks!
Thank you for your tutorial. Apache configuration on Ubuntu was for a long time an enigma for me, now it is much clearer.
I’m getting stuck after the following:
when I create the html file. I enter the sample page,body in your example and try to save and get the following error. I’ve went back and ran the following command a couple of times and retried and it doesn’t seem to help.
“[ Error writing /var/www/mydomain.com/public_html/index.html: Permission denied ]”
Any ideas where I went wrong?
Screenshots: Drive
Thanks Justin. This was very helpful.
This is not working for me at all. I keep getting the Ubuntu page instead of my index page. Everything is there. What am I missing?
I’ve added my domain, the /var/www, everything I can think of and it just won’t pull the index file.
how to make subdomain? just like test.example.com
Looks like your html tags are showing in this article. Maybe its my computer?
And in the tutorial towards the first part what directory is it? It keeps changing from publichtml to public_html and then back and forth and I end up just having both…
Perfect! Thank you. I spent all day trying to get nginx to work. Got Apache to work first try thanks to this article.
My etc/hosts look like 127.0.0.1 localhost 127.0.0.1 ubuntu 127.0.0.2 myhosting.com www.myhosting.com
Then I you that we have to add the public IP address of my VPS, I assumed that my VPS IP address is 192.168.30.100 so it will look like this:
127.0.0.1 localhost 127.0.0.1 ubuntu 127.0.0.2 myhosting.com www.myhosting.com 192.168.30.100 myhosting.com
I save it and in my browser i input myhosting.com and it does not display the page Success! The myhosting virtual host is working!
Can you tell me why or where is the mistake? I try removing the assuming ip and even that it does not work…
This did not work for me, my page doesn’t come up, I need help.
I have tried this tutorial for two domains, one success is done but other shows in the browser “Not Found”. In the putty, when I use the command:
sudo service apache2 restart
to restart, I find this following message:AH00112: Warning: DocumentRoot [/var/www/MyDomainName.com/public_html] does not exist
But fact is that, there is such of directory. Could you help me?
Hi,
I am running UbuntuGNOME 14.04. At the end I get error.
Doens’t matter if use:
or
retrieved with
Any idea?