Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kopias's avatar

Apache not finding my index.php

Hi,

I recently used git hub to pull my web app to a server I am hosting. I changed the defualt directory to the folder with my index.php in it but I get a blank page. I then set up a few index.php with phpinfo() in them, in each folder leading up to my project folder and they work until I get into my project folder, I even chmoded everything 777 and no luck. Cant figure out why apache isn't serving my page. I ran php artisan serve and get an error in the autoload_real.php. Not sure whats wrong...

0 likes
5 replies
BENderIsGr8te's avatar

First things first - Never ever set 777 on any folder that can be accessed via a script or a web browser. Make sure you roll back your permissions to what they should be 644 for files and 755 for directories with 775 for Laravel Storage folder.

Your servers is using Apache correct? Knowing that let's start some troubleshooting. What does your VirtualHost file look like? Is it setup for the correct document root and does it include index.php as an index file?

You can test this by explicitly typing index.php at the end of your URL...for example http://mydomain.com/index.php. If you get the Laravel Welcome page, then it's a good sign that index.php simply is not setup as an index file.

The other thing to check is to make sure the .htaccess file was imported from GIT (or even committed to GIT in the first place) as it sets up Clean URL's.

Are you on dedicated (or virtual server) hosting, or shared hosting? If you are not on dedicated (or virtual server such as DigitalOcean or AWS) then you need to check that you have the correct versions of everything installed. In fact that's a good idea regardless. You say you had phpinfo() to run...what version of PHP is running? Do you have MCRYPT extension up an running (if on a shared host mcrypt may not e setup).

One thing I would love @TaylorOtwell to add to a future version of Laravel is just a simple test.php file that can be loaded that simply checks if the server meets the basic minimum requirements to run the version of the framework (such as version of PHP, check that .htaccess is there, check that folder permissions are setup correctly, check that mcrypt is setup, and I think that's about it).

Give us a post after running through these instructions and let us know what the result is and we can go from there.

1 like
kopias's avatar

Hi thanks for your answer!

@BENderIsGr8te

Im running on digital ocean, found the .htaccess file, I know I shouldnt chmod 777 but I wanted to be sure that it wasnt a permissions issue. I tried adding index.php to my servers ip, its not working. I followed the digital ocean set up lamp doc, im pretty sure it installed mcrypt, and adds index.php as the default file name for the server to serve. My config file.

<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/vaginistas/public

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

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

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Could it be something else? I even made an Nginx server, followed a Lemp set up guide and I still get a blank screen in browser. Oh and I Chmod 777 -R the whole thing to be sure its not permissions.

kopias's avatar

I get this error when running composer update, I made a helpers.php file with functions in it. Could the autoload not be finding it cause me to get a blank screen?

HP Warning: require(/var/www/b/app/HTTP/helpers.php): failed to open stream: No such file or directory in /var/www/b/vendor/composer/autoload_real.php on line 54 PHP Fatal error: require(): Failed opening required '/var/www/b/app/HTTP/helpers.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/b/vendor/composer/autoload_real.php on line 54 Script php artisan clear-compiled handling the post-install-cmd event returned with an error

[RuntimeException] Error Output: PHP Warning: require(/var/www/b/app/HTTP/helpers.php): failed to open stream: No such file or d irectory in /var/www/b/vendor/composer/autoload_real.php on line 54 PHP Fatal error: require(): Failed opening required '/var/www/b/app/HTTP/helpers.php' (include_path='.:/usr/s hare/php:/usr/share/pear') in /var/www/b/vendor/composer/autoload_real.php on line 54

BENderIsGr8te's avatar

Hmmm...the document root is /var/www/vaginistas/public. The Composer error is /var/www/b/vendor/composer/...

Where is your site located? Obviously you have it in var/www/ but do you have a folder called vaginistas or is it in a folder called b?

It's good practice to always leave the default virtual host to just point to an empty page (the default page) and then explicitly create a virtual host for each domain/site you want to create. This avoid's weird errors and unplanned scoping up to global if something isn't set properly. The fact your site is in b folder from what I can tell is a good example.

Create a virtual host file for your site, set your ServerName (and ServerAlias if you have to for 'www' sake) and set the DocumentRoot to be the root of the folder the site is deploying on.

You'll run composer update from the root of your project folder. So if you are parking your site in /var/www/vaginista then you'll want to navigate cd /var/www/vaginista then run composer update from that folder. Your vendor folder should also appear in the vaginista folder as well as your composer.json file and the rest of your project.

It sounds like a configuration problem, not a server issue. If you want to check MCrypt and the others you can type which followed by the command. So which mcrypt should output a folder where the mcrypt command is being stored. With php you can type php --version to see the version. However I feel like you need to setup an explicit virtual host that points to the folder where your site is parked and go from there.

BTW, to be clear (I think you know this) if your site is at /var/www/vaginista then you'll actually set your document root to be /var/www/vaginista/public so that the public folder is the root of the site, while the vaginista folder is the root of your project.

Please or to participate in this conversation.