0

I have a Linode server that I run for more than 30 websites on it! Today I wanted to add another website and I created a new .conf file in sites-available folder in Apache2 folder.

After enabling it and restarting my Apache, it seems like that it doesn't work at all. when going to the newly configured domain it loads one of my previously enabled website instead of the new one.

I usually copy one of my old .conf files to create a new one. But in case here's my .conf file:

# domain: bilitsaz.ir
# public: /var/www/bilitsaz.ir/public_html/

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin info@bilitsaz.ir
  ServerName  www.bilitsaz.ir
  ServerAlias bilitsaz.ir

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/bilitsaz.ir/public_html
  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/bilitsaz.ir/logs/error.log
  CustomLog /var/www/bilitsaz.ir/logs/access.log combined
</VirtualHost>

I checked the documentRoot and it all seems correct. I wonder if you guys can help me out, thanks.

UPDATE:

apachectl -t responds with: syntax OK and the log for that website with apachectl -S is: port 80 namevhost www.bilitsaz.ir (/etc/apache2/sites-enabled/bilitsaz.ir.conf:4) alias bilitsaz.ir

UPDATE 2:

Ok I enabled HTTPS using Let's Encrypt for the website and it loads just fine, but for some reasons I need the website to be plain HTTP, I wonder why the server does not load any new HTTP virtual host anymore

Sohail
  • 101
  • 4
  • 1
    Did you actually enable it? Is the symlink in `sites-enabled` present? What does `apachectl -t` and `apachectl -S` say? Log file entries? – Sven Jun 14 '16 at 10:19
  • surfing with Filezilla there's a link in sites-enabled for the site, `apachectl -t` says: `syntax OK` and the log for that website with `apachectl -S` is: `port 80 namevhost www.bilitsaz.ir (/etc/apache2/sites-enabled/bilitsaz.ir.conf:4) alias bilitsaz.ir` – Sohail Jun 14 '16 at 10:22
  • You should improve your question by [editing it](https://serverfault.com/posts/783816/edit) to include those details. Comments aren’t very readable and many people skip them. You should also include relevant entries from either `/var/www/bilitsaz.ir/logs/error.log` (or the log files for the default virtual host). – Anthony Geoghegan Jun 14 '16 at 11:34
  • thanks for pointing it out Anthony, I'll update the question and will include any extra info I have, about the error logs, it's actually empty! I assume Apache doesn't recognize it as a host yet so there's no error for it – Sohail Jun 14 '16 at 11:38

1 Answers1

1

Your configuration looks fine. Maybe you have some other issue like .htaccess redirection or you are trying to access your domain with https, but it hasn't been configured properly.

Also look at the access.log when you enter the new domain.

tail -f /var/www/bilitsaz.ir/logs/access.log

Edit1: If you are forcing the domain to go to https and not installed certificate for it, it will always redirect you to some other domain on the same IP that has certificate.

Edit2: Look at your htaccess file for https redirection or in your website/CMS configuration.

Edit3: I am not using let's encrypt, but from what i am googleing: It can force any domain to HTTPS:

After the dependencies are installed, you will be presented with a step-by-step guide to customize your certificate options. You will be asked to provide an email address for lost key recovery and notices, and you will be able to choose between enabling both http and https access or force all requests to redirect to https.

Maybe it has changed the main apache.conf. I think you should go to Let's Encript community support. Sorry if i wasn't be able to help you.

NIZ
  • 131
  • 4
  • Hey NIZ, thanks for the reply, there's nothing in access.log ! there's nothing wrong with .htaccess file. the thing is I tried to install Let'sEncrypt recently on couple of websites on this server, they seem to be working but one thing I noticed is that when I type in bilitsaz.ir , it redirects to https version, even though it's not enabled for it – Sohail Jun 14 '16 at 11:50
  • I updated the question NIZ, can you do me a favor and take a look at that and let me know what you think? – Sohail Jun 14 '16 at 12:34