Hello
I'm hosting a new website on a LAMP server, with my website folder, , found in the /var/www/ folder. I configured my virtualhost file like this:

vim /etc/apache2/sites-available/monsite

and added the following to the created file:

# Le virtualHost de monsite.fr
<VirtualHost *:80>
    ServerAdmin webmaster@monsite.fr        # L'E-Mail de l'administrateur
    ServerName  monsite.fr                  # L'adresse du site
    ServerAlias www.monsite.fr monsite.com  # Les alias du site
    
    # Les documents du site 
    DocumentRoot /var/www/monsite.fr/
    
    # Les options du site (comme dans un .htaccess)
    <Directory /var/www/monsite.fr/>
        # On autorise tous le monde a voir le site
        Order allow,deny
        allow from all
    </Directory>
    
    # Les logs (historiques des IPs et des fichiers envoyés)
    ErrorLog /var/log/apache2/monsite.fr-error_log      # Erreurs
    TransferLog /var/log/apache2/monsite.fr-access_log  # Acces
</VirtualHost>

I then configured my Windows host file, since am accessing the website from Windows instead on FireFox, and added the line:

192.xxx.x.xxx www.monsite.fr

Normally, then if I opened in my browser, it should point to the website, however, am getting an error: "500 Internal Server Error"

The server encountered an internal error or misconfiguration and was unable to complete your request.

However, if I use:

whereby using this link I can access the installation files, it does work, but

gives me the server error mentioned above

Anyone knows what may be causing this?

Dani AI

Generated

A short, practical diagnosis and checklist for the situation described by (domain name mapped in hosts file works for the IP path but the domain returns an HTTP 500). That pattern almost always points to a vhost-level problem (different config, different .htaccess or access rules) rather than a network/DNS issue. Common root causes are: the virtual host file not being active or matched, a syntax or directive in the vhost that Apache rejects for that host, per-site access rules (.htaccess) that fail under the vhost, or file/permission issues that only apply when the DocumentRoot is the site directory rather than a subfolder of the default docroot.

Quick diagnostic commands and interpretation:

sudo apache2ctl -t
sudo apache2ctl -S
sudo tail -n 200 /var/log/apache2/error.log
sudo systemctl reload apache2    # or: sudo service apache2 reload
  • apache2ctl -t finds config syntax errors that often cause 500-level failures when a vhost is parsed.
  • apache2ctl -S shows which vhost is chosen for the domain and where that vhost file lives (useful when a default vhost is being used instead of the intended one).
  • The Apache error log will contain the precise reason for the 500 (missing directive, permission denied, mod_rewrite/.htaccess parse error, PHP fatal error, etc.).

Checklist of targeted fixes (ordered by frequency/impact):

  • Ensure the vhost file is enabled and Apache reloaded (name-based vhost selection must match the domain in the hosts file).
  • Inspect the vhost for deprecated or distro-specific directives (access control syntax changed between Apache 2.2 and 2.4).
  • Temporarily disable any per-site .htaccess (as noted by ) or move it aside to confirm whether it triggers the 500.
  • Verify filesystem permissions and ownership so the webserver user can read the files and directories.
  • Run the site through the error log messages and the two apache2ctl checks above to find the exact misconfiguration.

Since later confirmed an Apache config fix resolved the issue, these steps summarize the fastest, verifiable path to the actual cause for future readers encountering the same behavior.

Recommended Answers

All 2 Replies

I'm guessing you're using a PHP script. Try the following:

1. Rename .htaccess to ._htaccess and see if it works. If it doesn't, rename it back.

2. Apache might be having a problem serving PHP scripts. Create an info.php file in your root apache directory and type in

<?php phpinfo(); ?>

. browse to

http://localhost/info.php

and see if it loads up.

Apache is definitely configured right. The problem is with the script. Somehow, Apache is having a problem serving it.

Which script are you trying to install?

It was indeed a prob with the apache config itself, a friend helped me out in the end with it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.