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,193
  • Thank you for your suggestions @kurankat. ls /etc/apache2/sites-enabled/ lists only my site. When I try to check the status of apache, it tells me that www-browser is not found. Again when I restart, it says "Missing address for virtualhost". I am sure that is because I am using using IP instead of domain name. I am just testing the site so I don't have a domain. Is there a way I can use Ip to test?. Can I test without using virtualhost? Thank you. – user1048281 Mar 09 '20 at 10:26
  • Please I am using Ubuntu 18 LTS – user1048281 Mar 09 '20 at 10:27
  • I've added some suggestions to the answer. Try commenting out the ServerName if this is the only server, and don't forget to reload Apache when you make changes. – Kurankat Mar 09 '20 at 10:44
  • please, I have applied the suggestions. I am doing everything from ansible so ansible reloads and restarts apache after the installation. but still the default page keeps showing. even though sites-enabled lists only my site. @Kurankat – user1048281 Mar 09 '20 at 23:09
  • Sorry, I know nothing about Ansible. – Kurankat Mar 09 '20 at 23:23
  • Thank you very much. The ansible does the installation alright. the problem right now is with apache configuration – user1048281 Mar 09 '20 at 23:26
  • "the ansible does the installation alright". I wouldn't be so sure, or it would be working. It generally works out-of-the-box. I've modded the answer to check the contents of /etc/apache2/apache2.conf. – Kurankat Mar 09 '20 at 23:34
  • One more question, but you've tried it with your browser in incognito or private mode to make sure you're not getting a response from the cache, right? – Kurankat Mar 09 '20 at 23:57