Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I got a LAMP server working in Ubuntu 11.04. Now the problem is that the websites have to enabled and disabled from the terminal. All all of them have to be accessed from http://localhost which is not so much efficient. So I created a VHOSTS, using some tutorials off the net. Here is the coding for it

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    Servername site.com
    ServerAlias www.site.com
    DocumentRoot /home/starx/public_html/site/public
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /home/starx/public_html/site/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
nGen
    ErrorLog ${APACHE_LOG_DIR}/site-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/site-access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

Now, still I can't access the page in http://site.com but if i access using http://localhsot/ it is accessed.

I have disabled all others site including default and have just enabled one site i.e. site

How to fix this?

share|improve this question

4 Answers 4

I was just trying to get this to work, and after looking around a bit I found out what was going wrong for me.

I am running xampp (lampp) 1.80 for Ubuntu 12.04.

open /opt/lampp/etc/httpd.conf

See Line 488

# Virtual hosts  
# Include etc/extra/httpd-vhosts.conf

remove the "#" from the include.
A new install does not load the httpd-vhosts.conf out of the box.

share|improve this answer

According to /usr/share/doc/apache2/README.Debian.gz, if you wish to create definitions for additional sites, you will want to place individual site configuration snippets in /etc/apache2/sites-available/ (see /etc/apache2/sites-available/default for an example). You can then enable and disable sites on a given host with the a2ensite(8) and a2dissite(8) commands. Note that this may not work precisely as described if the distributed configurations have been changed significantly.

If a site is enabled in this way, and continues not to appear to work, you will want to make sure that the web server can resolve the name of the new site in a way that matches an IP address the web server believes it is assigned: the simplest way is probably to check with w3m https://my.new.secure.site from the server. You also want to verify that the client resolves the name in a way that causes it to reach the server in question (although the resolved IP does not need to match one the server uses). For insecure sites, this is easiest with telnet my.new.site 80 and, once the connection is complete (there is no prompt), entering the following three lines (note that the third is blank, but you must press enter a third time):

GET / HTTP/1.1
Host: my.new.site

If these work, anything else is a browser problem. If the first succeeds and the second fails, there is probably something odd in the network layer (NAT, proxies, etc.): exactly how to troubleshoot this depends far too much on the network topology and devices present: please ask another question with specifics if this applies to you.

If the first test fails, double-check the name service available on the server and the IP addresses assigned to the server (ifconfig -a). Also check your site access logs to verify that you see a connection at about the right time. Lastly, make sure that your virtual host is listening by name, rather than by IP, and does not filter the results for / based on IP in your VirtualHost directive.

share|improve this answer
    
No still the vHOST is not working. The site is although accessible by localhost instead –  Starx Jul 10 '11 at 13:26
    
How do you mean "not working"? Which of the tests above failed? How did it fail? –  Emmet Hikory Jul 10 '11 at 17:24

I'm not sure this is what you want.

Replace your codes with this simple short codes.

<VirtualHost *:80>
   ServerAdmin admin@localhost
   DocumentRoot YourDocumentRoot
   ServerName site.com
   ServerAlias www.site.com
   ErrorLog localhost
   CustomLog localhost-access_log common
</VirtualHost>

You can read more about vhost here

share|improve this answer
    
Actually, this will not make a difference. –  Starx Jul 10 '11 at 13:20

Have you added site.com and www.site.com to your /etc/hosts file to make sure that the dns routing is correct? You can try nslookup site.com to test the dns.

If you want to make sure that http://localhost does not work, delete the /etc/apache2/default, default-ssl files and use a single virtualhost.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.