Error 500 ubuntu index.php setting

All we need is an easy explanation of the problem, so here it is.

I’m getting this error after putting my file inside html directory and I’m confused about this setting. I think I have to open the index.php file, but I’m getting a 500 error. Let me know about any error you notice please.

Error 500 ubuntu index.php setting

Error 500 ubuntu index.php setting

This is data from /etc/apache2/sites-available/fullstack1.conf:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/fullstack1

    <Directory /var/www/html/fullstack1/public/>
        DirectoryIndex index.php
        AllowOverride All
        Require all granted
        Order allow,deny
        Allow from all

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    LogLevel warn

This is data from /etc/apache2/apache2.conf:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied

<Directory /usr/share>
        AllowOverride None
        Require all granted

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Looks like you have a couple of items to look at in the fullstack1.conf file:

  1. Your DocumentRoot should point to the directory that visitors to the site will start from which, based on the <Directory> entity, should be:

  2. The final slash in the <Directory> entity is unnecessary:

    <Directory /var/www/html/fullstack1/public>
  3. If you are running a modern version of Apache, these two lines can be removed from the <Directory> entity:

    Order allow,deny
    Allow from all

    These permission statements are now handled with the Require statements.

  4. If Apache does not know what to serve when people visit the bare domain, it will default to showing the directory structure or present an error. As you’re running a PHP-based site, you can add this line immediately after DocumentRoot:

    DirectoryIndex index.php index.html index.htm

    This will look first for index.php in the /public directory and fail first to index.html if the PHP file does not exist, then to index.htm.

Once these items are taken care of, restart (or reload) the Apache server:

sudo service apache2 restart

This should give you what you need 👍🏻

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply