Score:0

Error 500 ubuntu index.php setting

br flag

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.

Structure of directory

enter image description here

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

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName www.fullstack1.xyz
    ServerAlias fullstack1.xyz
    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
     </Directory>

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

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

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

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

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
cn flag
Does this answer your question? [Server Error 500 Localhost in xampp](https://askubuntu.com/questions/610768/server-error-500-localhost-in-xampp)
Doug Smythies avatar
gn flag
did you enable php? i.e. is it in `/etc/apache2/mods-enabled`. Not sure which version for you look for php7.4.conf ,for example, in `/etc/apache2/mods-available` and enable via `sudo a2enmod php7.4` (but use your version numbers).
gian avatar
br flag
info.php tells me i'm using PHP Version 7.4.26
Score:1
in flag

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:

    /var/www/html/fullstack1/public
    
  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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.