0

I have created a virtual host using apache in ubuntu for my wordpress site. I disabled the default page apache servers and enabled my site, but the default site is still displayed instead of my site. What could be wrong?

NOTE I used an IP address instead of servername/xxxx.com. Can that be the reason? Thank you

<virtualHost *:80>
  ServerAdmin webmaster@localhost
  ServerName  xx.xx.90.xx

  DocumentRoot /var/www/wordpress
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

 <Directory /var/www/wordpress>
     Options -Indexes
 </Directory>

 <IfModule mod_dir.c>
   DirectoryIndex index.php index.html index.cgi
 </IfModule>

<virtualHost/>

1 Answers1

0

It's worth checking that the default site is actually disabled. You haven't stated which Ubuntu version you're using, but in most versions, Ubuntu versions of Apache come with the lines:

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

inside /etc/apache2/apache2.conf. Make sure those lines are in, or Apache won't know to look inside that folder for its configs. If you list the contents of:

ls /etc/apache2/sites-enabled/

If you used a standalone configuration for your virtualhost in /etc/apache2/sites-available you should only have your site available in there, and not the default site.

It is also worth using your domain name rather than your IP address, as aready mentioned. You may, at some point, want to host other content in that server.

If this is the only virtual host you will have, you can do without the ServerName line. Try commenting it out (put a # at the start of the line).

Finally, after making sure that you have only the virtual hosts you want in /etc/apache2/sites-enabled, restart Apache in order to load the new configurations:

sudo systemctl restart apache2

Your new configuration won't load until you do so.

The error about www-browser is strange. How did you install Apache? It means that there is no command-line browser installed. You could install Lynx and this should fix it (sudo apt install Lynx), but I'm doubtful that this is the cause of the default page being shown instead of your own. Again, after any change, reload Apache with sudo systemctl restart apache2.

Kurankat
  • 1,243