1. adel

    site site1 does not exiist ! i got this error when i tryed sudo a2ensite site1

  2. Rubel Ahamed

    Hello i want to change cacti default login page such as "please enter your cacti user name and password" this sentence do not contain login page , how do i change configuration file. please help me.

  3. borgauf

    I've got:

    You don't have permission to access / on this server.
    Apache/2.4.10 (Ubuntu) Server at borgauf.macsyma Port 80

    Here's my conf file:

    ServerAdmin webmaster@localhost
    ServerName borgauf.macsyma

    DocumentRoot /home/lawrence/webdev/borgauf.macsyma

    Options FollowSymLinks
    AllowOverride None

    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all

    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/"

    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from ::1/128

    Not sure what's wrong. Also did

    chmod 775 webdev webdev/borgauf.macsyma

  4. Miguel Herrera

    This is absolutely the best tutorial on setting up apache on the web. You did a wonderful job here and I am grateful to have found this and configured my server with the greatest o ease. Thank you!


    • Thanks. I'm glad you found it helpful.

  5. amir

    thank for this post.
    very good.

  6. matt h

    I have followed this tutorial to a Tee but everytime I enter either site1 or site2 it just loads the default apache page and NOT my Site1 works! index page? Can anyone help me, I'm using ubuntu 12.10 with all the latest updates and upgrades, It is a fresh install and have ONLY installed the lamp stack following the tutorial at the top of the page. please help


    • If you're using Firefox as your web browser, try clearing the browser cache. I can't tell you the number of times that Firefox has driven me crazy because of that. Alternatively, try installing Chromium and check your pages.

      It could also be an issue with permissions on your directories. Try

      chmod 775 webdev webdev/site1 webdev/site2
  7. pat

    Sorry the line that says this is the only line that needs to changed in the apache2.conf file is

  8. pat

    I just clean installed ubuntu 14.04 and got the 404 errors, I had used this on 12.04 for about 2yrs.
    My solution is as follows dont know if it is correct but works fine.

    First change apache2.conf
    sudo nano /etc/apache2/apache2.conf

    AllowOverride None
    Require all granted

    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted

    # Options Indexes FollowSymLinks
    # AllowOverride None
    # Require all granted

    Follow Linerds instructions until sudo cp default site1 at this point make it
    sudo cp 000-default.conf site1.conf

    Next sudo nano site1.conf
    under ServerAdmin add
    ServerName site1

    then change
    DoucumentRoot /home/yourid/webdev/site1
    save changes

    sudo a2ensite site1.conf

    then finish out like Linerd says.

    Linerd thank you for the original tutoral. Like I said this works, if it works after update without having to make the change again I don't know time will tell.

    • pat

      is the missing line above. Sorry


    • Thank you! This is a great tutorial but maybe a bit out of date...but I got it working with your comment. Just for clarity I had to change "require all denied" under as mentioned in your post.

      So happy to have this working with a nice directory structure and http address. Thanks, Linerd!


  9. Thanks a whole lot for this tutorial. I just did a fresh install of ubuntu and this is the first tweaking I've done on it. Worked like a charm! I stumbled around a little at first and couldn't get it to work right, because I wasn't understanding the steps correctly. After a few tries I finally got 'er done.


    • I'm glad you got it working. Enjoy.

  10. Olwe

    How could this be modified to include access to /home/me/webdev/site1 over a home network? That is, I'd like not just http://site1 to work but work across my home network, i.e., http://192.168.0.x/site1 ?

  11. Olwe

    Got it to work with this tip I got off StackOverflow:


    ServerName site1

    ServerAdmin webmaster@localhost
    DocumentRoot /home/memyselfI/webdev/site1

    Options FollowSymLinks
    AllowOverride None

    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted

    . . .

    Don't know how much of this is truly good karma vesus kludge. . . .

    • Embinf

      Thanks, I got it to work too, on Linux Mint 16. The config file(s) in /etc/apache2/sites-available/ must end with the .conf extension, e.g. site1.conf. And here is what the contents of the file look like:

      <VirtualHost *:80>
      # The ServerName directive sets the request scheme, hostname and port that
      # the server uses to identify itself. This is used when creating
      # redirection URLs. In the context of virtual hosts, the ServerName
      # specifies what hostname must appear in the request's Host: header to
      # match this virtual host. For the default virtual host (this file) this
      # value is not decisive as it is used as a last resort host regardless.
      # However, you must set it for any further virtual host explicitly.
      ServerName site1

      ServerAdmin webmaster@localhost
      DocumentRoot /home/user/websites/site1/
      <Directory />
      Options FollowSymLinks
      AllowOverride None
      <Directory /home/user/websites/site1/>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Require all granted

      # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
      # error, crit, alert, emerg.
      # It is also possible to configure the loglevel for particular
      # modules, e.g.
      #LogLevel info ssl:warn

      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

      # For most configuration files from conf-available/, which are
      # enabled or disabled at a global level, it is possible to
      # include a line for only one particular virtual host. For example the
      # following line enables the CGI configuration for this host only
      # after it has been globally disabled with "a2disconf".
      #Include conf-available/serve-cgi-bin.conf

      # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

  12. Olwe

    Your sites-available config file is out of date for Apache 2.4.6 and my hacking around hasn't relieved a very difficult "403 Forbidden You don't have permission to access / on this server" I'm having. Any ideas?

  13. devk

    Hello! I also have a file access problem: site1 and site2 are in a /home/myid/webdev. Folders and sub-folders of site1 and site2 are not writable through php. I have chmod'ed folder 'webdev' recursively to 755, so what could be blocking there?

    • devk

      Solved! Apparently, some PHP needed to be executed by user www-data, so i chown'ed the respective folder accordingly (adding myId to the www-data group was not good enough).

  14. Embinf

    Thanks for the tutorial. I always have a file permission problem after setup and get the message: 403 Forbidden You don't have permission to access / on this server - when trying to access the newly setup websites.
    I solve this by using the file manager to change permissions of the files and folders. So for a website that is on the hard-drive at:
    I have to enable read only access for the files in the site1 folder for both group and others.
    Then for each sub-folder in the line I change folder access permission to Access files for both group and others ( so I do this for site1, websites, )

    My questions are - is there a better way to do this? Or did I miss something, because I do not see any other comments about file access problems? Is it possible to do this by adding yourself to a group so that everyone does not get access to the web development folders?

    • Embinf

      Sorry some things did not print properly in my comments above because I used angle brackets.
      /home//websites/site1/ should be /home/user name/websites/site1/
      and then
      ( so I do this for site1, websites, ) should be ( so I do this for site1, websites, user name)

  15. Marsup

    Wehre are the apache error logs located, and which file to bee seen for errors? Thanks.

    - Marsup

    • Linerd

      You can find the Apache logs under /var/log/apache2.

  16. lenny b

    I'm not working locally, I have a server at an ip address and the partition for the site and files is on a separate disk than where the var/www directory is. Both virtual on the same server, but following the steps above, I get the "Index of/" page.

    I'm using Drupal and put but to no avail. (that's not the real IP of course, but the example)

    Is there anything else to reload/restart when doing this?

    • lenny b

      nevermind. I just copied and changed the default file so that the ip goes straight to the folder. Thanks.

  17. Ajas K A

    yes, it worked....thank you so much.....

  18. Eras

    Great Tutorial. Had wrestled with Apache for a while without any luck.

  19. Josh

    What additional steps do I have to take to view the sites over my home network? I can view them on the machine that the server is running on, but that is not my main computer.

    • andy

      Are you trying to connect to the IP address of your server or if its this is know as a loopback address for your local machine and you wont be able to connect to another machine using this ip address. Try the IP for the server.

  20. L-Regbot

    This is a life-saver. Use it lots. But how can I remotely access my ~/webdev/site1 ? It functions just fine on my own computer, but on my home LAN gets me "It works!" but gets me "Not found." AFA I know I've got everything 755 permissions-wise.

  21. Pervez

    Thank you for this post .I want to know how can I inheriting HTML templates in APACHE2 Web-server as we can do in Django Framework . And how can I configure my My webpage with JS CSS IMAGE folders in webdev......?

  22. Bhavyesh

    hey dear, can u guide me for this,,,
    when i place any folder inside site1 folder then, i am unable to access that folder.. in my Ubuntu 12.04 via the web browser. The css placed under any sub folder or the java-script also under any sub folder is not considered by the browser.

    Example http://site1/ is working but http://site1/css gives forbidden message...

    • Linerd

      Do you have execute permission on the css folder? If not, try

      cd ~/site1
      chmod 755 css
  23. Bhavyesh Gadhethariya

    Hey brother u are really sharing a nice stuff. I got really satisfied answer and technique of configuring apache.thanks once again. it is of great help to me πŸ™‚

  24. Beardmancer

    Hi! This and your LAMP instructions are working great for me, way better than XAMPP for Linux. Thanks!

    One problem I'm encountering: on one of my sites, index.php (in the site's root directory) is not able to access main.css (in /css). The same is true for any resource in a subfolder that index.php tries to access. The specific error is "403 Forbidden."

    I have no experience configuring apache or php. Is there a setting somewhere that tells the site to include subfolders? The site's folder is located in my home directory, so I can't imagine that permissions would be an issue.

    Ubuntu 12.04, in case that matters.

    • Beardmancer

      Ah, I'm a dolt. Checking "Allow executing file as program" under folder properties did the trick. I should have ready into it a bit more.

      • Linerd

        I was just in the middle of a reply to look at the execute permissions on your folders when your second comment came in. I'm glad you got it figured out.

  25. leo

    hello, how can I access the site I created following your guide externally? I setup a wordpress, can I show it to someone over the internet? Thanks in advance

  26. Capri

    I am new bird in Linux world... I have created my own Linux Apache server in CentOS for my network monitoring with CACTI, I have configured each & everything & my apache is working fine. I have registered my web portal also but still i am not able to my portal(web-page) with other machine in network. please suggest me what can i do for resolution of my this error. Please help me & guide for succesful result. Thanks in advanced for my help.

  27. ric

    I don't know if you can answer me but I can't find /etc/apache2 directory in Mageia. I don't suppose you know where to look for this? πŸ™‚

  28. K.narender

    hi, dis narender.k i want total informaion abt linux from basic to top level theory notes can u plz..............provide me the site u know/....................

  29. Versti

    When I browse to my http://site1/ I only get 'Could notcConnect' errors
    As far as I can tell I've followed the directions, including the permissions suggestion.
    Browsing localhost gives me the default 'It works!' page, but that's all I can load.
    Please Help!?!


  30. ERROR
    The requested URL could not be retrieved
    what happen?? not working in my ubuntu

    • Linerd

      Did you replace yourID in the file above with your user ID? Otherwise, it could possibly be a permissions issue with your directories. Do you have execute permission on all of the directories in your path?


      • yes, i replace "yourID"
        how i can execute permission? which directories?
        thanks for quick replay my question

        • Linerd

          You want execute permissions on your home directory, the webdev directory and site1 directory. You should be able to right click on the folders in your file manager to check the permissions. You can also set them from there.

          You can also set permissions from the command line:

          chmod ugo+x ~
          chmod ugo+x ~/webdev
          chmod ugo+x ~/webdev/site1
          chmod ugo+x ~/webdev/site2

          • thanks very much

  31. Hamidjon

    Thanks a lot, it is working πŸ™‚

  32. Samir


    I got the solution. I was missing on some minor entry under my tools->options->Network->Connections->Settings.

    When on proxy network, then under firefox browser all I had to choose was manual proxy with my proxy settings. And I had to add my newly created document root folder with name for example site1, site2 etc. in No Proxy for entry in my firefox browser.

    Thanx anyway.

    • Linerd

      Thanks for posting your solution. I haven't had to work with proxy servers, so I couldn't be of much help.

  33. Samir

    Also, Adding to above information, I am able to open my joomla websites by typing localhost in both cases when I put it in /var/www/ .

    So, Apache server is fine with or without proxy on vmware.

  34. Samir

    Thanks for the great tutorial. This really helped me. But I am facing some issues.

    I have Ubuntu-12.04LTS using vmware on Windows 7. I work on a internet with proxy configuration when I use my laptop in the office else I switch to no proxy. I configured the Apache as per your tutorial for multiple websites. It works great when I don't use proxy with my personnel internet connection at home.

    But in office when connected with internet using proxy, it does not work. When I enter the site in address bar of firefox, it gives me google search results. This is not the case when I dont use the proxy at home.

    For your information I have following configuration,
    1. on Vmware setting for network, I have chosen NAT.
    2. On Ubuntu under System Settings -> Network ,
    i use manual proxy wwwgate0.xxxxx.com with port 1080 when using office else I configure it to no proxy when at home.
    3. On Ubuntu, under Network Connections -> Wired I choose to configure my wired connection IPV4 as always Automatic(DHCP). This remains unchaged in both situations and I am able connect to internet.
    4. In firefox under Tools->Options->Network->Connections->Settings, i choose No proxy or Manual depending upon where I am accessing internet.

    Please help.

  35. Yatindra

    Super...I was struggling with an open source application installation for 3 weeks and the steps mentioned by you worked. Thanks a ton!!!!

  36. o2se3tak

    Thanks! Worked like a charm πŸ™‚

  37. ljuper

    Why can i surf to the page http://192.168.1.*/site1/
    but not http://site1 from my other computers on the same network?

    Using ubuntu headless server. 12.04

    P.s iΒ΄ve used the sleazy hack sudo ln -s /home/user/webdev/site1/ /var/www/ to make it work

    • Linerd

      I think you would need to edit your /etc/hosts file on each machine of your network so that site1 resolves as

      • ljuper


        Thanks, i understand i can do that on each machine i have in the network.
        But that is not an option since i have a couple of machines. It works if i edit the hosts on my OSX of course, but i canΒ΄t run around. And is it even possible to reach and edit the host files on a iPhone by the way?

        Do i have to edit the DNS Server running on the server? And if, is there a good tutorial available?

        • Linerd

          Editing the DNS would be the "right" way to fix it for every client. Sorry, I don't know how to do this. BIND is the typical DNS server on Linux, so I suggest you start your research there. Good luck! πŸ™‚

  38. Noddy

    Thank you for this. I have just tested it on Xubuntu 12.04 and everything works fine.

    I used gksudo leafpad instead of sudo nano


    I had so many issues doing this on Natty 11.04, however on Pp 12.04 and your tutorial it works fine.
    BIG BIG thank you!

  40. ans

    Hey Linerd,
    It looks like things are getting worse for me. This solution I posted worked fine Yesterday, now my browsers can't display any local pages or phpMyAdmin any more... what's going on? thx

    • Linerd

      Check you /etc/hosts file. Sometimes Network Manager likes to overwrite this file, so you might need to make the changes again. If that is the case, you could try making the file immutable so it can't be overwritten by the system. So make your changes to the file, then

      sudo chattr +i /etc/hosts

      If you later need to reverse this later (is mutable a word?)

      sudo chatter -i /etc/hosts
      • ans

        My problem was much simpler. Apache just stop running and I didn't know. sudo service apache2 start was enough! Thanks again.

  41. ans

    Hey there,
    Thank you for the tutorial. I follow all the steps on ubuntu 12.04, but when I enter site1 or site2 on the address bar it is always the content of the default.html which is displayed. I check that site1 and site2 was enabled in the sites-enabled folder and the links are there. Can you help me figure out what is wrong?
    Thank you

    • Linerd

      What is the content of your /etc/hosts file? You should have a line that looks like: localhost site1 site2

      If you edit that file, make sure to then reload Apache

      sudo service apache2 reload

      You might also want to clear your browser cache for good measure too.

      • ans

        hey sorry, I have been waiting and didn't even think about just refreshing the page to see your reply.
        this is the content of my hosts: localhost localhost site1 localhost site2
        I did that after reading this comment here:
        " Matt says:
        January 10, 2012 at 8:33 AM

        "Should the first line in /etc/hosts read " localhost site1 site2" for instance?"

        No, each site requires a new line so instead of " localhost site1 site2" it should be: localhost site1 localhost site2

        You just repeat the steps you did to create site1 in order to create site2, site3, etc. except you add a line in /etc/hosts for each new site. Also, your site name can be pretty much any name you want (it doesn't have to be "site1"). "
        I change the configuration to localhost site1 site2 and it it working! I have been on ths simple line for the hole night!!! crasy !
        Thank you

  42. bifs

    Excelent tutorial but I have a more especifc question regarding permissions:

    Supposing I don't want do change from /var/www main directory, and that I am programming from an external computer with Netbeans updating files directly on the server, what should be /var/www permissions? And owner of the directory?

    With only one site I managed it, but now I have other projects and I am trying to setup a SVN subvservion repository and everything goes right until it's time to write inside /var/www/whatever...

    Could you please, give me some tips?

    Thanks in advance!

  43. Pawan

    hey! thanks for this!
    I was planning to have a local wordpress development environment setup. so i followed your tutorial and everything worked.
    except one. when i create a new post or page and publish it, and try to open its permalink, i get the 404 error. it says that the link can not be found on Apache2(ubuntu) server at port 80.

    moreover, it displays the url as "/permalink" rather than "site1/permalink".
    what is going wrong?

    • Linerd

      It sounds like mod_rewrite isn't working. Did you change AllowOverride to All under the <directory /home/yourID/webdev/site1/> section?

  44. Lah

    Thank you for this tutorial. Could you give a bit more explanation on Apache directives in more simple as this configuration. Also add some comments in the files. thank you

    • Linerd

      After reading this post, you pretty know everything I know about Apache πŸ™‚

      I know it's not the easiest reading, but I suggest you check out the official Apache documentation.

  45. Larsen

    I keep getting the same error


    You don't have permission to access / on this server.

    Apache/2.2.20 (Ubuntu) Server at site1 Port 80

    I tried to rerun the tutorial, but still the same : / any idea what went wrong?

    • Ines

      I have the same problem πŸ™

      • o2se3tak

        check permissions for your home directory (under which you have created site1 and site2). you need to try: chmod 750 /home/yourid or chmod 710 /home/ or chmod 755 /home.yourid (depending on how much access you want to give - the least that is required for the sites to be visible is execute permission for the group)
        do the same with the webdev folder and its contents chmod 750 -R /home/yourid/webdev (or 710 or 755)

  46. zaldy

    followed the instructions here and everything came out as expected. thanks!

  47. John Erck

    You rock. Thanks so much for posting this. I'm moving off a shared host and onto a barebones Linux box with no support... was totally lost as to how to emulate my old environment and this did the trick.

  48. Jeoffrey Stiernon

    Great tutorial ! Worked like a charm !

  49. sugiono

    maybe below can give more information ( note that site1 name is mysite here )

    sugiono@ubuntu:~$ apachectl -S
    ulimit: 88: error setting limit (Operation not permitted)

    VirtualHost configuration:
    wildcard NameVirtualHosts and _default_ servers:
    *:80 is a NameVirtualHost
    default server localhost (/etc/apache2/sites-enabled/000-default:1)
    port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default:1)
    port 80 namevhost mysite (/etc/apache2/sites-enabled/mysite:1)
    Syntax OK

  50. Sachith

    Thank you very much. Instructions were perfect

  51. Stanislav

    MANY MANY THANKS. 5:00 was trying to make a virtual host on a pile of manuals, only your fully working. Thank you!

  52. Sugiono

    Hello again,

    I checked each step , and everything looks good. testing.php and phpmyadmin run smoothly. the only thing when I try to execute install.php, the browser stop and blank.

    Can you please advise? I did change the /etc/apache2/sites-available/[sitename] ,

    Options Indexes FollowSymLinks MultiViews
    AllowOverride All ( and also to AuthConfig>
    Order allow,deny
    allow from all

    restart the apache, and still not working. pls anyone can help?

    • Linerd

      What is install.php? What is is supposed to do?

      • sugiono

        install.php is an executable file for my php package / module, but no worry about that first since i am still figuring out how to enable site 1 and site 2 since everytime i reload apache,
        error line 13
        unable to resolve host
        thus i can never access index.html i have stored in that directory, instead it shows the index.html from /var/www
        i do not know what happend, i edit /etc/hosts and erase the ubuntu , since i thought that is the confusing culprit everytime the apache2 want to restart,
        can you please help me straight this out, thanks in advance

        • sugiono

          the exact message is
          sugiono@ubuntu:~$ service apache2 reload
          * Reloading web server config apache2 ulimit: 88: error setting limit (Operation not permitted)
          apache2: apr_sockaddr_info_get() failed for ubuntu
          apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
          httpd not running, trying to start
          (13)Permission denied: make_sock: could not bind to address
          no listening sockets available, shutting down
          Unable to open logs
          Action 'graceful' failed.
          The Apache error log may have more information.

          • sugiono

            this problem arise since I install ubuntu server on my pc.

            the creating a web development directory was fine, but then i was unable to execute install.php ( see my top posting), so i clean install everything and start with ubuntu server, ubuntu desktop and LAMP.

            I forward my server ( port 80 ) so that I can have it alive. it went great for /var/www web, but when i tried to have the second hosting, web development, fail with the above message ( see my 3rd posting) although the name site1 can be accessible ( direct to /var/www, where it should be /home/webdev/site1 )

          • Linerd

            Do you get the same errors if you use sudo with the above command?

            sudo service apache2 reload

            You can fix the fully qualified domain name by doing this:

            echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn
        • Linerd

          Don't remove that line from /etc/hosts. It should work with it in there and removing it may mess up something else.

          I think you need to find the file that is referencing IP address Since you're working with your local machine, it should probably reference

  53. Rodrigo

    Hi there,

    I did it exactly the way you explained, and everything has been set up right. The only problem happened in the end ..

    phpmyadmin could not be found ... i've got an 404 error, even with the "success" message at the end of installation "ldconfig deferred processing now taking place"

    what could be the error?

    Thanks that much ..

    hugs from Brazil

  54. Nipun

    Hi,Thanks for the wonderful tutorial.If i wish to view say index.html under site1 from another computer connected over LAN,how can i do that.
    So from my other computer if i fire http://site1/index.html it should render the contents

  55. Paul

    Great tutorial. I'm new to this stuff. Did the same thing for site2 as suggested but it didn't work! It generated the index.html output from /var/www/ instead. I think the tutorial needed to be a little more concise with regards to site2. Checked my scripts to ensure that there were no typo's. Should the first line in /etc/hosts read " localhost site1 site2" for instance?

    • Matt

      "Should the first line in /etc/hosts read " localhost site1 site2" for instance?"

      No, each site requires a new line so instead of " localhost site1 site2" it should be: localhost site1 localhost site2

      You just repeat the steps you did to create site1 in order to create site2, site3, etc. except you add a line in /etc/hosts for each new site. Also, your site name can be pretty much any name you want (it doesn't have to be "site1").

      • Linerd

        I use localhost site1 site2

        with no problems.

  56. Nipun

    HI.Thanks for the great tutorial.
    Whenever i reload apache2 i get the following:
    * Reloading web server config apache2 [Sat Nov 26 19:42:10 2011] [warn] NameVirtualHost *:0 has no VirtualHosts
    [Sat Nov 26 19:42:10 2011] [warn] NameVirtualHost *:0 has no VirtualHosts

    Also i am not able to send "PUT" requests via any REST client(for eg Google Chrome has an extension for the same)

    • Linerd

      Your virtual host file should refer to *:80 for port 80, not *:0.

      • raj

        U have to /etc/apache2/httpd.conf ----------- servername localhost . U won't get the error

        • raj

          U need to do this in /etc/apache2/site-available/site1 -------- DocumentRoot which u have create a directory site folder

          • raj

            Try it...........


            a2dissite default
            service apache2 reload
            service apache2 restart

            u can see that error won't get u..............[warn] NameVirtualHost *:0 has no VirtualHosts

  57. Thanks lol....
    Below mentioned url is very easy to understand,

  58. gido505

    I'm not really much on posting comments but I just have to thank you for this great tutorial, everything worked with no headaches.
    A thank you also for this tutorial on installing lamp on ubuntu 10.04

    Thank you very much. πŸ™‚

  59. bart

    Thanks for the tutorial.
    I also liked the idea to have it all setup under the account that I use on the server (ubuntu).

    Now here is the issue that I have not been able to resolve and hope someone can help me with the optimal solution.
    I use Joomla and Joomla uses www-data (the account apache uses) to write files when you install extensions or add files to the CMS.
    Then I use an FTP account same as ubuntu user ID to copy an manipulate files remotely.

    Yes I can cmod the files and dir eachtime they are written to give access to Joomla or my account but there must be some way that both system account www-data and useraccount have full access to /home/useraccount/webdev/site1 site2 etc

    If not what is the use to set it up under the /home/useraccount

    sorry I am a noob but eager to learn what is the best way to do this.

  60. richarduie

    Thanks for this and the LAMP install how-to. Worked out of the box for me on Lucid - both laptop and workstation. I'm a mere developer, but the ease of this makes me feel frisky about the notion of doing it on my (internal) network print/file server as well. Refreshing to find simple, correct, complete how-tos.

    Having been "playing with" Linux since '95 (Slackware, RedHat, Mandrake, Mandriva) and using exclusively since '05 (Fedora, Kubuntu), I observe 'tis rare and wonderful to get perfect advice in Linux-land. Yours is the kind of effort that leads to more satisfied Linux-geeks and fewer Windoze and Mac based developers.


    P.S. Last addition for my purposes was cURL...Shi Chuan had that at:

  61. Olwe

    I've followed the chmod instructions, but still get:

    You don't have permission to access / on this server.

    Any ideas on how to troubleshoot/fix?

  62. Stramash

    Thanks for the guide. I am getting a 403 when I try http://site1/ The file permissions are 644 and the directory is 755.

    • Linerd

      I think your index file needs to have execute permission. Have you tried setting the file permission to 755? Actually, 744 might work too.

      • Stramash

        I found my mistake. First I took out:

        Options FollowSymLinks
        AllowOverride None

        And that worked, then I realised I hadn't set All here:

        Options Indexes FollowSymLinks MultiViews
        AllowOverride All

        So I put the first bit back in, AllowOverride to All, and changed permissions back to 644 for files and 755 for dirs.
        Everything is fine now, though I am going to find out why each works and the difference they make.

  63. Al


    Great instructions, thanks. Very clear.

    I've got it all working on my Ubuntu virtual machine, running on a windows box but I've got a problem. I can't seem to access it via:
    I get a 'Not Found' response from apache.
    It works within the Ubuntu box i.e.
    ...but I'd rather just work with the browser if I can, from windows.
    Any ideas anyone?



    Oh, by the way... you'll need to set the 'i' immutable attribute on the hosts file or else Network Manager will screw it up for you. i.e.:

    sudo chattr +i /etc/hosts

  64. gadasadox

    thanks man, it helps me alot.

  65. Zoran

    Hi guys. Sorry but i still have problem. I followed all instructions but without success.
    Whenever i try to to start my website i get default page - not index.html page of site.

    Does anyone have suggestions how to fix this?

    • meg

      Make sure you added ServerName site1 to the site1 file in the sites-available directory.

  66. Mav

    Hey, a little help please ... I set it up exactly as described, and followed the instructions exactly as you said; then I got a "Oops! Could not contact domain ... trying again." So then I added the fqdn file, then I followed community help on Ubuntu and disabled the default using a2dissite, and kept the enabled for site1, and now I am getting a Forbidden error about not having permission to access / on this server?

    I actually did all of this after following your previous post about setting up a dev environment with Ubuntu, so I'd really appreciate any troubleshooting help with this.

    • Linerd

      It may be a permission issue with the directory where have your files. Try this:

      chmod o+x /home/yourID/webdev/site1

      If you're using Firefox, you may also want to try clearing the browser cache after you change permissions.

      • Mav

        Just to check -- by cdmod you mean chmod, right?

        • Linerd

          Oops. Yes, I mean chmod. I'll fix my previous comment.

  67. Sam

    Great tutorial. I have done step by step uninstalling LAMP and reinstalling it again. I also installed phpmyadmin but http://localhost/phpmuadmin is giving me a 404 not found error.
    Can you please help get this phpmyadmin working

    Thank you

  68. Robert

    I get the following message where I use samd instead of site1.
    I have followed the instructions above exactly.

    While trying to retrieve the URL: http://samd/

    The following error was encountered:

    Unable to determine IP address from host name for samd

    The dnsserver returned:

    Name Error: The domain name does not exist.

    I can ping samd and get the correct response.

    Any help would be greatly appreciated.

    • Robert

      Solved this. The proxy server was intercepting the url. I just added samd to the exception list and it worked.

  69. Safiur Rahman

    when i run
    sudo /etc/init.d/apache2 reload

    I get

    * Reloading web server config apache2
    Warning: DocumentRoot [/home/yourID/webdev/site1/] does not exist

    How can I fix?

    • JB

      You have to replace "yourID" with your login name, i.e. the name of your home directory. So if your login name is "safiur", then your home directory is probably /home/safiur.

      To change to your home directory in terminal, type:
      cd ~

      Then to display the current working directory, type:


      It should display something like:


      where login_name is your actual login name.

  70. jimmidill

    Great site, great tutorial! I am a windows user but am using ubuntu 10,10 via VMWare (to teach myself PHP on a lamp stack). I like ubuntu but I still get lost everytime I step too far outside of my cosy familiar windows world, and if I'm honest most linux guides and tutorials have succeeded in baffling my poor pea-sized brain!

    This is one of the first linux sites that hasn't gone over my head, which I'm very grateful for πŸ™‚ I'll be following closely from now on. Thanks!

  71. alixky

    Great tut!! I have been following yours from installing LAMP and configuring Apache2 from this post and I have to say everything running without any hiccup. You're the man! Thank you very much! This site will be definitely one of my favorite spot on the net!


  72. Thanks for the great tutorials on getting LAMP up and running and setting it up for multiple sites! I love my new test environment.

    When my computer goes into suspend, I lose the changes I made /etc/hosts. Not a huge deal since I just sudo nano /etc/hosts and make the edits again. If you have any idea why this file "resets" I'd love to know what I can do about it.

    Thanks again for the fantastic tutorials!

    • Linerd

      I don't have time to dig into this right now, but it looks like there's a bug in Maverick. You may find a work-around if you read through the comments on the bug report.


      • Thanks for the tip and link. I will check it out. It's not a huge deal to me since the workaround is quick and easy. When I figure it out, I will post it here. Thanks again!


        • Ubuntu 10.10 apparently released a fix in the network manager, because the "hosts" file is no longer overwritten, on suspend or reboot. Very nice! Thanks again, Linerd, for the great tutorial. I plan on reformatting and starting fresh with the final release of 11.04, so I will be using this tutorial again... Best, Aaron


  73. Just as a side note: When adding site2 I configured /etc/hosts like this: localhost.localdomain localhost site1 site2

    Now all three of the sites work, so I assume sites can be continually added to the list without affecting the others.

    Question: To enable the site I entered 'sudo a2ensite site'. Is there a command for disabling the site; say I no longer have the site.? I just don't want the list to grow and bog something down.

    • Linerd

      Yes, there is a command to disable a site. It is a2dissite. To remove site2 it would be like this:

      sudo a2dissite site2

  74. Hey man. I'm truly just a beginner, but through workin' with tutorials have kinda learned a few things through teaching myself. Here's all I want. I have an ubuntu 10. server with LAMP on it. I just want to be able to host multiple sites that are custom created by myself through Dreamweaver and such. I can see my site fine on my 'localhost' server, the computer I'm on right now, but cannot let's say through my laptop over the net. If I could just be told what has to be done, not necessarily step by step, then I can maybe figure it out. Then again, maybe not, but I'd like to know what's missing. Is it just a matter of setting a unique IP and configuring my domain name (which I bought through GoDaddy.com) to find that address? Or is it something else?

    I'm a beginner, REALLY JUST beginning... So, thank you very much, I really appreciate it!

  75. Adrian

    Hi, thanks for the tutorial it has gotten me further than any previous attempts, there is however a snag at the very end that I wonder if you can help me with:

    Where it says in you directions

    "Edit the first line adding site1 to the end of the line so it looks something like this and save the file. localhost site1"

    the file I see is different, it looks like this and I don't know where I should apply the edit: adrian-N80Vm # Added by NetworkManager localhost.localdomain localhost
    ::1 adrian-N80Vm localhost6.localdomain6 localhost6 adrian-N80Vm

    # The following lines are desirable for IPv6 capable hosts
    ::1 localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts

    When I run the final command

    "sudo /etc/init.d/apache2 reload"

    I get this:
    Warning: DocumentRoot [/var/www/home/adrian/webdev/site1/] does not exist

    Any ideas?

    • Linerd

      You should apply your edit to the end of the second line in your case: right after "localhost".

      For the warning you're getting. Make sure that the path you have in your site1 configuration file is just /home/adrian/webdev/site1/.

      • Adrian

        I've removed/reinstalled LAMP and followed instruction to the letter (copy-pasted) twice, still not working. Is it possible that you are using 10.04 and there is a bug in 10.10?

    • Adrian

      Thanks for your answer, just to clarify (I'm a total newbie:)

      Should it be:

      • Linerd

        It should be:

        • Adrian

          I'm doing something wrong, think it's best to start over, Do I need to delete something so it won't clash with new configuration?

          • Adrian

            Never mind, I've removed and installed LAMP anew, should take care of it.
            If it still does not work I'll be back nagging πŸ™‚

  76. Daniel

    Great tutorial, I have a special case in my setup I was wondering if you could help me out a little, I'm dualbooting Win7 & Ubuntu each on its partition, plus I have an extra big partition to store and share all my files betweem OS's, so in this partition I have setup a folder named "www" and from windows I'm accesing it using wamp by modifying in apache to link the server to "a:/dropbox/www" and on ubuntu I'm using lamp but I haven't been able to change from /var/www to /media/documentos/Dropbox/www since that is the path that appears in nautilus.

    Anyhelp would be appreciated.

    • Linerd

      You should be able to create a configuration file for your site similar to the one above for site1. Just replace the instances of /home/yourID/webdev/site1/ with /media/documentos/Dropbox/www/.

      • Daniel

        Hi linerd, I did, exactly what you said, after the last step, restart apache, I get the following error:

        403 Forbidden (In the title of the browser)


        You don't have permission to access / on this server.
        Apache/2.2.16 (Ubuntu) Server at localhost Port 80

        I don't know what's going on.

        • JohnJ

          I have the same 403 error. I am working on a single boot Ubuntu 11.04 install.

          I came here after working through the tut on installing LAMP and running into problems in the last section: installing and testing phpmyadmin.

          Otherwise: tx for the great tuts.


          • Charlie

            This is a cracking tutorial - I ran into the same 403 issue and after some digging sorted the solution.

            Firstly you can check in the apache logs to confirm /var/log/apache2/error.log to see if it is a permissions issue.

            The you can fix it by changing the permissions on the directory

            cdmod o+x /home/yourid/webdev/site1

            Hope this helps.

  77. amit

    great post.n Thanks

  78. Mark

    Hi Linerd -

    Your tutorial worked beautifully for me - every step.

    Just reached the point where I downloaded the actual site and DB from my provider (for my first "test site") and the strangest thing is happening. I don't know what to make of it.

    + Before downloading the site files (pretty much a base installation of WordPress thus far) and DB - I would go to http://site1.com on my local machine and see the "Hello World" index.html that I wrote. Just fine.

    + After downloading (and configuring teh local database) - when I go to what I would expect to be the "local instance" of this site again (the non-www URL), it's automatically mapping to the "www" URL and taking me to the live site on the real web server. I validate this explicitly by pulling the network cable -- and wouldn't you know it... I get a connection timeout!!

    Do you have any idea why my local machine is now connecting to the [real] web server server when it didn't before? Is there something in my site that's making this mapping that I need to override? Any thoughts??

    Sorry if this is a noob question... but hey, I'm a noob!

    Any insights most appreciated. Thanks!


    • Linerd

      So you downloaded the files from your provider rather than manually installing WordPress? The only thing I can figure is that there is a 301 redirect that's set up in one of the files from your provider's server. Take a look at this page: http://www.dailyblogtips.com/how-to-setup-a-301-redirect/

      The redirect will be either the one of the PHP methods or one of the Apache methods. ASP is for Microsoft servers. I'm betting it's an Apache redirect in your .htaccess file.

      If you can't find it, I suggest you blow away everything you downloaded and do a fresh local WordPress installation. http://tuxtweaks.com/2009/11/how-to-install-wordpress-on-ubuntu-part-1/

      I just work on my website theme locally and then upload the theme folder to my provider's server when I have things looking the way I want.

      One final thought. You said in your comment that you go to site1.com. You might want to try changing it to just site1.

      • Mark

        Thanks -

        Had only a little while to work this, but, I took your last comment and reworked my set-up so that mt local directories are truly site1, site2, etc... no longer site1.com, site2.com. That definely sounds better. It didn't resolve the problem yet, but it's cleaner.

        No obvious 301 redirects that weren't in the fresh WordPress download files. When I "grep 301 *" there were five php files with a 301 string - both my original WordPress and the new WordPress files matched on this front!

        Will try the fresh install via your other on-line links. We'll see how it goes...

        One question per another comment you made, though -

        So the core goal here is merely to modify my template, then? I'm trying to educate myself - and this clearly rings true. I have one site partially-functional (a small amount of initial content), but I do indeed want to significantly modify the template. If that's the case - I shouldn't be terribly worried about having my local content match as that's moot. It's all about the site design on the LAMP environment (and, naturally using as a repository for backups). Is that pretty much the philosophy?

        Thanks again!!


        • Linerd

          Yeah, I just use the local LAMP setup for theme development and customizing. I don't really use it for backups of my site. My provider has a backup system available in Cpanel that will backup all of the site files and databases in one shot. Then I just download the archive to save it locally.

  79. Squimpleton

    It worked the first day, but when I came back after, it didn't. I realized it was because the host file kept resetting to what it was before I saved it. So I re-edited it to add the various permissions.

    And now Site 1 and Site 2 are available, but for some reason they're accessing the files from my original localhost site. I checked the site1 and site2 config files and they still have home/myname/webdev/site1 and site2 as their documentroots and directories. So I don't get why they're pulling the files from localhost.


    • Squimpleton

      Never mind. I had skipped a small step.

  80. Paul

    Hey, Great Tutorial.

    I am attempting to setup a testing environment using unbuntu, however I am having some difficulties getting my site to work properly once placed into the var/www/ folder.

    It seems none of the relative paths work. In my index.php file for example, I have a bunch of includes and images, however none of them appear when I view the page, only the basic html text appears.

    I am assuming the most likely reason is that the file does not have read access to those files? Is this the case?

    Is there a quick terminal command to fix this if it is?
    Any help would be much appreciated.

    • Linerd

      I'm not sure what the correct permissions are. I'm thinking the files will need read and execute permission. To give everything read and execute permission, use this command.

      sudo chmod -R a+rx /var/www
  81. Sumesh Gupta

    I have done exactly as you have described above and site1 and site2 are working absolutely wonderfully. I wish to know if I can create name base virtual hosts in apache with localhost and access them from same machine?
    (www.myname.com etc)
    I tried the process after reading a few howto's in ubuntu forums. However whenever I restart apache a warning is received that unnumbered virtual hosts and numbered virtual hosts port 80 are not supported and reloading fails. Can I get some help with this problem?

    • Linerd

      Sorry, I can't help you with that one. That's beyond the scope of anything I've tried to do. The Ubuntu Forums are probably a better place to find help for this. Good Luck.

  82. Patrick

    Hi Linerd,

    Great tutorial, finally managed to get two sites going on a LAMP server.
    This may be a stupid question, but how do i get to the sites without modifying the hosts file, what address?
    I've tried the obvious http://localhost/site1 & http://localhost/site1/index.html

    • Linerd

      Hmm... I gave this a try and http://localhost/site1/ works for me. Did you make sure to enable the sites? Did you make sure to reload Apache?

      sudo a2ensite site1
      sudo /etc/init.d/apache2 reload

      Edit: Interesting, I just added the sites back to my hosts file and the change wouldn't take until I did a full restart of Apache, so maybe that's the trick to get it working for you.

      sudo /etc/init.d/apache2 restart
      • Patrick

        Hi Linerd,

        Thanks for the quick reply. I tried restarting Apache - no joy, I even tried undoing the fqdn fix you posted in case that was affecting it - no joy.

        Turns out to be able to access site1 & site2 via http://localhost/site1/ or http://localhost/site2/ I needed to put the site1 & site2 folder under /var/www/ as opposed to /home/patrick/webdev/ and edit the /etc/apache2/sites-enabled/site1 & /etc/apache2/sites-enabled/site2 files appropriately.

        Although as yet I haven't tested it from another machine, I'm guessing I will now be able to access it from etc.

        Just thought I would post back in case any other users have been spending as much time trying to get that going as i have! LOL

        Thanks for the great tutorial. Feel free to edit this comment to keep it concise if you wish.

  83. Bobot

    Hi Linerd,

    I just had a fresh install on a new HDD and followed your tutorial for the third time and it worked again.

    Muchas gracias


    • Linerd

      De nada.

  84. noip

    Thanks for the tutorial. Just wish I understood how those commands worked. πŸ™‚ I've set up WAMP several times, but this is my first LAMP.

  85. Lee Boone

    is there a way for other machines on a local network to view these sites? I can view the /var/www/index.html page using either the ip address ( or the name (http://linux-box) of my linux machine, but can't seem to find the custom sites. (Which work perfectly on the linux computer, thank you)

  86. Rudy

    Actually, I do have to add that it will only allow __.sytes.com to point to one of the site and it will not work in a __.sytes.net/site1 and __.sytes.net/site 2 way.

    Still need to figure out this one.

  87. Rudy

    Is the configuration the same if using a no ip tool like NO-IP?
    I cannot reach any of the 2 sites when using the NO-IP URL (.syte.net).
    I tried adding the following entry in /etc/hosts: site1 site2
    ( being the IP address of my Linux box)
    Although, if using the URL .sytes.net, I do reach the 'It Works!' Apache test page from my webserver.
    Any help would be greatly appreciated.


    • Linerd

      Rudy, I haven't tried this setup with a dynamic DNS setup. I'm thinking you would most likely have to modify the Apache configuration. However, it might work like it does when accessing the host machine web server from a VirtualBox guest. Have you tried __.sytes.net/site1 or __.sytes.net/site2?

      • Rudy

        Thx for the quick reply.
        Yes I did try __.sytes.net/site1 or /site2 without luck.
        I actually figured it out. I had to disable the default config under /etc/apache2/sites-available by using the 'a2dissite' command (sudo a2dessite default).

  88. Ryan

    Just found the hack under the older posts...sorry should have checked there first

  89. Ryan

    Fantastic post!!!!
    I managed to get this working so if I VNC onto my ubuntu desktop server I can visit http://site1/ no problems but if i try from my laptop I get an error... should I be adding site1 to the second line of /etc/hosts @ instead of localhost?

    Thanks a million



  91. Jeff

    Awesome post! It worked great!

  92. James


    Thanks for cleaning up the comments. I fixed the issue. I had the database call parameters typed as strings ( ' ' ) by removing the single string quotes I was able to get the database to connect and the page would then load.

    Thanks again for the tutorial to set up the multiple web application development environment for apache.

  93. James

    I installed LAMP on a setup of Ubuntu 10.04 and added the site1 site2 environments exactly as you show. Both sites worked just as you described. I have started using site1 to follow a series of tutorials on php.

    I have run into a problem and am baffled. Using firfox, I can got to localhost/site1 and call the index.html page and see the "Site 1 works!" in the browser
    I have copied the testing.php into site1 and when I call the page it gives me the php page, so I know that apache is serving up php from site1 as well.

    I have built the following page called index.php which calls for a MySQL database called gwdb and a table in the database called guitarwars. I have written the code exactly as it is written in the tutorial changing only the location of the database to site1 in the call to connect to the database; $dbc = mysqli_connect('site1','root', 'password', 'gwdb')

    All I am getting in firefox is a blank page. In chromium web browser I am getting "Oops this link appears to be broken"

    I am new to Linux and PHP and trying to learn and I can't see what is causing this break in the link. I have included the code below:

    <html xmls="http://www.w3.org/1999/xhtml"
    xml:lang"en" lang="en">
    <title>Guitar Wars - High Scores</title>
    <link rel="stylehseet" type="text/css" href="style.css" />
           <H2>Guitar Wars - High Scores</h2>
           <P>Welcome, Guitar Warrior, do you have
           what it takes to crack the high score list?  
           If so, just <a href="addscore.php">add
           your own score</a>.</p>
           <hr />
           // Connect to the database
           $dbc = mysqli_connect('site1','root', 'mailbox1823', 'gwdb')
                   or die('Error connecting to database');
           // Retrieve the score data from MySQL
           $query = "SELECT * FROM guitarwars";
           $data = mysqli_query($dbc, $query);
                   or die('Error quering database');
           // Loop through the array of score data, formatting it as HTML
           echo '<table>';
           while ($row = mysqli_fetch_array($data)) {
                   // Display the scare data
                   echo '<tr><td class="scoreinfo">';
                   echo '<span class="score">' . $row['score'] . '</span><br />';
                   echo '<strong>Name:</strong> ' . $row['name'] . '<br />';
                   echo '<strong>Date:</strong> ' . $row['date'] . '</td></tr>';
           echo '</table>';
    • Linerd

      James - I edited your comments into one to capture the spirit of what I think you were trying to show.

      I'm no php pro, so I doubt I'll be much help. I did try your file on my machine and it doesn't load. The file does work if I remove the php portion. Maybe another reader can offer some advice.

    • David

      in your mysqli_connect statement you should still be using localhost not site1 because the mysql server is on localhost.

  94. Pragasan

    Hi Linerd

    Thanks for the tutorial. I'm a newbie trying to set up my own ubuntu linux server for a production enviroment to host some of my applications. Is the setup tutorial for lamp and apache suitable for production environments? Also if we want to keep Ubuntu lamp installation up to date is there a command that we use?

    Thanks again for the great tutorial.

    • Linerd

      Hi Pragasan - I'm confident that the LAMP setup would be fine for a production environment. The Apache configuration, I'm not sure. I know little more than what I've documented on this website. I'm not sure that I've followed best practices for Apache, but the setup here works well for an offline development environment. I'd encourage you to consult the Apache documentation if you want to set up a production environment.

      As far as keeping things up to date; if you're running Ubuntu Desktop, then the update manager should keep you up to date. Otherwise, you can update your system with

      sudo apt-get update
      sudo apt-get upgrade
      • Pragasan

        Hi Linerd

        Thanks for all the help.

        take car

  95. Korouu

    Hey man! You are too great! What others cannot do, you have done. Now my long time desire has become possible because of your tutorial. And thanks to the almighty for showing me to this website.

  96. roy byer

    Hello there

    I have followed the tutorial and it seemed to work on the command line but when I tried to access http://site1/ i get 403 forbidden
    You don't have permission to access / on this server.
    where did I go wrong.


    • Linerd

      Check out the comments from Larry. He had the 403 error and it turned out to be a permissions problem. Do you have read permission open on your home directory?

      • roy byer

        Hello Linerd

        Thank you very much that was the problem. Great tutorial.
        Thanks again


  97. rock

    thanks a lot for such a nice tutorial...straight away it worked...

  98. Felipe

    i installed win XP as a guest using virtualbox.
    host it ubuntu KK.

    how can i access for exemple, http://site1/ from inside the virtualbox?
    need this to test sites in IE πŸ™

    i read something about chaging the hosts files in xp but that didnt do anything, so maybe i did something wrong.

    thanks for the great tutorial and for the help

    • Linerd

      A quick trip to Google found a solution. I found this on the VirtualBox Forum. Enter into the browser in XP. You should now see the site you are hosting on you VirtualBox host.

      I just confirmed this with Kubuntu 10.04 running in VirtualBox. It should work the same with WinXP. Maybe I'll write up a short post about this.

  99. wakeel ahmed ansari

    How to Configure Apache Web Server on Linux” please send me

  100. Jean-Yves

    I still don't have permissions for /var/www

    but everething works fine with site/ and site2
    thank's for localhost site1 site2
    both sites work well now.
    Thank again !
    Merci beaucoup !

  101. Jean-Yves

    I'am a (very) new user of Ubuntu. I used to work with Wamp server in Windows.
    How can I create websites when I don't have permissions to write in the webdev forder ? How can I get permissions ?

    • Linerd

      If you created the webdev folder without using sudo, then you should have write permissions to that folder. If you don't own the folder, then you should be able to change the ownership with the chown command. If you want to change the permissions, then chmod is the command you want to use. Look at the man pages for these commands for more info.

      If you follow this tutorial, you won't need permissions to the /var/www/ folder since you'll be putting the files in a folder under your home directory.

      If you want to put your files in the /var/www/ directory, you can add your userID to the www-data group with this terminal command:

      sudo adduser yourid www-data

      Correction: I just looked at my system and /var/www is owned by root.

      • Jean-Yves

        Thank you for your help.
        I tried the command :
        sudo adduser myid www-data
        I gave my password
        and I got
        Adding user myid to group www-data

        but I still don't have permissions to modify the index.html file

        • Linerd

          You can change the ownership of index.html with:

          chown yourid index.html

          You may want to change the ownership of /var/www if that's how you want to work. See my above correction about the ownership of that directory.

          cd /var
          sudo chown yourid:yourid www

  102. Bobot

    wow, i am excited. thanks a lot for the new command "sudo a2dissite".

    buenas noches and again muchas gracias.

  103. Bobot

    this tutorial, along with the tutorial on LAMP installation is great. thanks a lot.

    with the two tutorials i managed to set up my own web development environment. with a lot of tail chasing though, and lots of help from you. again, thanks a lot.

    i have some questions though. after i was done with the set up, i realised that i did not like the directory placements, directory names, and host names. i figured that maybe i don't have to do it over again.

    so what i did was to instead, just (1) move the directories to where i wanted them to be, (2) rename the directories, (3) tinker on the configuration files (found in /etc/apache2/sites-available$) for the hosts i have made before and rename them according to my desire, (4) delete the symlinks i found in /etc/apache2/sites-enabled, (5)tinker on the file /etc/hosts and change the first line accordingly (i.e. localhost localhost2 localhost3 localhost4), (6) execute sudo a2ensite for the sites, (7) reloaded apache, and finally (8) check on my browser. it worked!!!...

    my only fear is, am did i do it right? did i not break anything with what i did? muchas gracias.

    • Linerd

      It sounds like you did it right. You can also disable a site with the sudo a2dissite command. It will remove the symlinks for you.

  104. richardmutt

    Great tutorial!

    However, I'm still not able to open my site1 page. It always points to the default page.

    The error message when I reload apache2 is this...

    apache2: Could not reliably determine the server's fully qualified domain
    name, using for ServerName
    [warn] _default_ VirtualHost overlap on port 80, the first has precedence
    [warn] NameVirtualHost has no VirtualHosts


  105. sanjay

    Many thanks for the excellent tutorial

    I have make changes exactly as you have metioned in your tutorial.
    I receive following error for testing site1

    Host not found
    name lookup for site1 failed

  106. ZogsterJack

    Many thanks for the excellent tutorial - all worked perfectly for me.

    One added point - I wanted to be able to access these multiple sites from other PCs on the local network.

    Spent ages looking for the answer, then it dawned on me. Update the hosts file in /etc on the client PCs with the fixed ip address of the server and the equivalent entries to those in the tutorial; for example site1 site2 (where is the server ip address)

    This does mean you'd have to setup each client PC and then amend for each new site you add in the future, but this works for me right now.

    Guess the better option is to set up a DNS server (thinking Bind9 for this) to centralise this effort, but I'll personally save that for another late night.

    Many thanks again

    • Linerd

      @ZogsterJack - Thanks for the comment. I know some other people have been wanting to figure out the same issue with the server on a home network, so thanks for posting a solution. I tend to just do my web work on my laptop with LAMP installed, so I haven't gotten into any real networking issues. I agree that a DNS server seems like the more "correct" solution, but I haven't found the motivation to give it a try.

    • jben

      Wow thanks alot, that worked like a charm, I use VMWare to test ie6-8 and for some reason it doesn't recognize the host machines site1 or site2 unless you change the host file. If anyone is wondering where this is located for windows XP: C:\windows\system32\drivers\etc\hosts

      I suggest you assign a static address to your machine to make life easier.

      I hate ie 6! Thanks a ton, this guide has been very useful.

  107. gingerbreadman

    Wonderful tutorial. Simple and concise.

  108. Larry

    Hey Linerd.

    I figured it out. I although I had read permissions to all in ubuntu set to my "webdev" directory, I did not have read permissions set for the parent folder, which is my user in the home directory. It seems apache needs all folders in the virtual path to be readable by all. The only question I have is, does this make my entire user folder vulnerable in some way? Is there a way to restrict usability to only the home/user/webdev/ path, without having to change permissions of all other directories in the home/user/ directory individually?

    I figure that this must be possible since it is possible to have multiple users in the home directory, and there is a set up that restricts users from viewing each other's files.

    I guess the overall question is, is it possible to give read permissions to a sub directory without giving read permissions to all parent and sibling directories?


    • Linerd

      @Larry - There should be no need for the read permission to be open on sibling directories. You could also make the rest of the files readable only by you. Having read and execute permission open on the directory would allow someone else to see the files, but as long as the read permission on the file itself is restricted, they won't be able to open the file.

      I'm sure there's another option that I can't think of right now too. You may be able to do something by creating a different group ID.

  109. Larry

    Great Tutorial Linerd. Two questions.

    I am getting a 403 Forbidden permission error. I am new to running apache on my own machine (Ubuntu 9.10). Is the permissions error a problem with Ubuntu permissions or Apache permissions.

    Also, a random question. If I make the server name a .com (e.g. "ServerName site1.com"), in which order with the browser (Firefox) resolve the name conflict with the remote site?

    Do you know of a way to use Firefox to select which location to check. Someone may want to do this for testing purposes if they have static addresses all over there website (which a good coder would never do).


  110. bvsmohan

    thanks for this tutorial, its simple and works

  111. Vayu

    Thanks this was very helpful. I've now got multiple top level sites on one machine.

    Any idea how to access them on another machine on my local network?

    The "It works" page can be accessed by the other machines on my network by entering this machine's IP address, but I can't figure out how to access site1 and site2 from the other machines.

    • Linerd

      @Vayu - I haven't tried accessing the sites from other machines on my network. You may need to set up a local DNS (domain name server). It may be possible to remotely access site1 and site2 by adding a line to your /etc/hosts file on the client machines. I'll have to give that a try.

      Edit: As far as an easy solution, I've only come up with this cheap hack:

      sudo ln -s /home/userid/webdev/site1/ /var/www/

      You can then access site1 on your network at: http://ip.address/site1/

  112. Rick

    Thanks. I normally develop on Windows and this is my first attempt at ubuntu.

  113. Raphael Yabut

    This is really great!

    I am finding my way through Linux, and tutorials are really educational.

    Thanks a lot for sharing.

    Got it right the first time!

    Best regards


  114. This and the LAMP tutorial are absolutely invaluable. Thank you Linerd.


    One thing confused me. The two sites I created both ended up opening the same home page.

    I finally figured out that it was necessary to give each its own line AND its own IP address in the hosts file. Some clued up folk may have understood that without being told, but there may be other noobs like myself who need it spelled out.

    For my wordpress site:
    For my php_tutor site:

    It worked, so I guess that was the right thing to do.

    • Linerd

      Alan - Glad you got things working. I was able to get my system working with both sites on the same IP address. My hosts file looks like this: localhost site1 site2

      I'm no expert, but I don't think either way is necessarily right or wrong. There are usually several ways to get the job done. The key on this one is to make sure to run the apache2 reload command. I've also chased my tail a bit due to Firefox caching a page. The Web Developer Toolbar plugin provides an easy way to clear the browser cache.

      I just remembered that I also explicitly set up localhost to point to the /var/www directory, so that may have made a difference on my setup.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.