简体   繁体   中英

Error setting up a virtual host in Apache/Ubuntu

I am trying to configure a virtual host on a dedicated server for one of domains - I have never set up a server before, so unsurprisingly I have gotten stuck. I have been following a couple of tutorials and it looks like I have actually succeeded in setting up the virtual host, however after making the changes my test index page will not load and the standard "Ubuntu" page will not load now either when I enter the server's IP into my address bar.

I have created the subdirectory for the domain files as "/var/www/mysite.com/public_html" and have copied and edited the default ".conf" file so that it looks like this:

 <VirtualHost *:80>
    ServerAdmin me@mysite.com
    ServerName mysite.com
    ServerAlias mysite.com
    DocumentRoot /var/www/mysite.com/public_html
    <Directory /var/www/mysite.com/public_html>
            Options -Indexes
            AllowOverride All
            Order Allow,Deny
            Allow from All
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
 </VirtualHost>

After this I ran the "sudo a2ensite mysite.com.conf" command and restarted apache. When I check run "apache2ctl -S" I get the following response:

 VirtualHost configuration:
 *:80                   is a NameVirtualHost
     default server mastnew.com (/etc/apache2/sites-enabled/000-default.conf:1)
     port 80 namevhost mastnew.com (/etc/apache2/sites-enabled/000-default.conf:1)
     port 80 namevhost mysite.com (/etc/apache2/sites-enabled/ibeka.xyz.conf:1)
             alias www.mysite.com
 ServerRoot: "/etc/apache2"
 Main DocumentRoot: "/var/www/html"
 Main ErrorLog: "/var/log/apache2/error.log"
 Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
 Mutex mpm-accept: using_defaults
 Mutex watchdog-callback: using_defaults
 PidFile: "/var/run/apache2/apache2.pid"
 Define: DUMP_VHOSTS
 Define: DUMP_RUN_CFG
 User: name="www-data" id=33
 Group: name="www-data" id=33

It looks like everything when exactly as the tutorial expected. As I said though, when I navigate to my domain the browser just hangs from thirty seconds or so and then tells me it cannot open the page. If I remove the "mysite.com.conf" file and try again, I land on the "Ubuntu" page. So something is going on with my new ".conf" file or there is some other conflict that is causing the server to freak out.

Any help would be appreciated. Thanks.

This may not be a useful answer if anyone is looking at this later, but it's worth trying if you're stuck. I really don't understand why it worked, but my domain was available after I tried this:

So I disabled the site using "sudo a2dissite mysite.com.conf" and then restarted apache. I checked that it was disabled and that my root index was up online (I'll be hiding/deleting this later). Then I re-enabled the site with "sudo a2ensite mysite.com.conf" and again restarted apache. After this, for some reason, the site became available online and all of my public files are now accessible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM