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

stef's avatar
Level 1

Laravel 5.1 on shared hosting not working

Hi,

i am new to laravel and i like it so much, but now i need help! I have googled for my question, but nothing runs for me.

I installed laravel on my local(xampp) machine via composer, my php version is 5.6.

Now i have uploaded laravel on my webserver(also php 5.6 and a subdomain):

  • html -> fletcher -> app, public etc
  • document root is set to public

and i get an internal error 500.

Sorry for my bad english ;-)

Kind regards

0 likes
37 replies
danmatthews's avatar

Have you installed your composer dependencies using composer install ?

It's highly unlikely you'll have SSH access to shared hosting to do this, so do it on your local machine, then FTP the vendor folder up onto your hosting.

stef's avatar
Level 1

Thx for the fast reply.

Yes i installed laravel via composer create project .... on my local machine and the vendor dir is also uploaded. At the first upload filezilla displays vendor errors ... wrong password ... at the second upload .. only the vendor dir ... everyting woks fine.

I think i haven't got SSH.

pyxl's avatar

Is it working now? If not, make sure you give storage write access (with subfolders).

stef's avatar
Level 1

Hi @all,

it is not working and the write access are all set to 777, also the files and directories, called recursive :-)

I didn't change anything, i have uploaded the project directory like on my local machine. Everything is Laravel Standard, no changes.

Internal Server Error

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

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

tomicakorac's avatar

Well are you able to access the server error log? That would save you hours of wandering in the dark.

stef's avatar
Level 1

Hi tomicakorac,

the error log is empty! No items available!

I am going nuts!

bitcoinboy's avatar

Upload the full project (after running composer) , Then you can use PHPstorm to synchronize between your local work and remote work , that's how I do in my shared hosting, But a problem you may get in some shared hosting is that you can't create a virtual host to hide public path in url .

Bitcoin Boy.

tomicakorac's avatar

@stef it is not possible for a server to report a server error (500) and not write it down in its error log. If you are getting a 500 error, but are not seeing any errors in your error log, then you are not looking at the correct error log. I would suggest contacting your host's support for tracking down the cause of this.

@bitcoinboy so far the only way to hide public/index.php on a shared host that I found always usable is this one

stef's avatar
Level 1

Hi @tomicakorac and @bitcoin

i am in touch with my hoster. Could this problem be that the mod_rewrite is not included for my hosting package?

Kind Regards

stef's avatar
Level 1

Hi @all,

ok i can't get the server error log files, because it is an shared server and not only for my accout.

I uploaded the project on a friends server with ssh(also shared hosting), it also doesn't run.

What kind of option do i still have?

Rgds

kodemania's avatar

Having same problem and waiting for someone to have any solution to it.

kodemania's avatar

I have laravel 5 app and I deployed it to shared hosting server via ftp. transferred all files to server and put public folder contain in public_html and all other files one step above public_html. Still getting 500 internal error.

code of my .htaccess file is

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ /index.php [L]
</IfModule>

composer.json contains

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "illuminate/html": "^5.0",
        "laravel/socialite": "^2.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

alainbelez's avatar

i really do think this is a permission problem. if you're using cpanel, you can see the error log in cpanel.

lyesqiz's avatar

The 500 error mostly due to the conflict of erase settings. Would you post the error logs to check where the problem is.

lrobi2015's avatar

Ok so I changed my directory structure to the way @kodemania has his, which is what I had done for a Laravel 5 project, now I am not getting a 500 error anymore, but a blank screen :....

It doesn't seem that error logging in enabled on this server...if I turn it on now, it will take about 24 hours for the changes to take effect.

Can anyone say what is the best way to upload files to shared hosting? Should I just throw all the project files into public_html? Or should I leave everything except what is in public outside of public_html and only put the content of the public folder inside public_html?

ian_h's avatar

@lrobi2015 On my VPS, I create a laravel dir and upload all of the files to that (either via SCP / FTPS or GitFTP).

I then delete the public_html dir and add a symlink to public in the laravel dir:

ln -s laravel/public public_html

and job done =)

Cheers..

Ian

2 likes
rwdevguy's avatar

Check that the permissions for index.php are set to 644. I had a few sites on some shared cPanel servers in the past and it's something that's come up a few times.

1 like
lrobi2015's avatar

@ian_h I see... I am very afraid to delete the public_html folder...but I need to do this in order for the symlink to work, correct?

@rosswilson252 - Thanks, I will try this and let you know if this is the issue.

I wish there was a simplier, more straightforward way to deal with this drama >.>

ian_h's avatar

@Irobi2015 There's nothing "special" about the public_html dir as such.. as long as you don't have existing sites already running from there, deleting it would be no problem at all.. if the worst came to the worst, you could just recreate it =)

@rosswilson252 is also correct in that cPanel-based servers can be funny about permissions. Files need to be owned by the account owner (so if your account name is 'irobi' for example, then the files need to be owned by 'irobi' for user and group, and permissions can't be too global either, I think the most you'd get away with for files would be 0664 and dirs 0775.

I'm assuming you have SSH access to the server? if so, uploading the files should automatically assume the correct user / group as defined either by SCP / FTPS or FTP etc, whatever you use. If you need to change permissions, a quick and simple way to do this would be to put all of your uploaded Laravel files in a separate directory (as I mentioned, I use laravel but it could be anything for this step)... then do the following:

$ cd laravel (or whatever your dir is called with your laravel site in)
$ find . -type f -exec chmod 0644 {} \;
$ find . -type d -exec chmod 0755 {} \;

What this will do, is search the directory and set 0644 permissions on all of the files and 0755 on all of the directories. If it is / was a permissions problem, this would resolve it.

Now you can either move the contents of the laravel public dir into public_html or delete public_html and symlink it to your public dir or if moving to your public_html dir, move everything else back up into your home root (mv * ..).

HTH and clarifies a bit further =)

Cheers..

Ian

2 likes
Prullenbak's avatar

What's the PHP version on the server? It needs to be >= 5.5.9

1 like
stef's avatar
Level 1

Hi what's up here :-))))

i have still the problem and my head burns.

Iam thinking about forge.laravel, has anyone experience with it?

Rgds

Stef

lrobi2015's avatar

@ian_h Okay, I will give this a shot today and post my progress here. Thank you!

lrobi2015's avatar

@ian_h Okay so this problem is really weird. I am still getting a blank screen after I have checked the permissions to ensure that directories are set to 0755 and files to 0644. I am using godaddy shared hosting (not by choice), and my Laravel version is 5.1.

I uploaded a Laravel 5 project to another godaddy shared hosting account, and it is working fine. For this particular project, I added the following to the index.php file in the public directory:

$app->bind('path.public_html', function() {
    return __DIR__;
});

I even tried to put this in the Laravel 5.1 project, but it failed...

I did exactly what you said, and read this article for additional reference in case I misunderstood something: https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e

Please help me :( I have no idea what else to try.

Thank a lot in advance!

lrobi2015's avatar

Okay, so for those of you who are having this problem using shared hosting and Laravel 5.1, I found the problems. Take a look at the comments I liked!

  1. There were still some files that did not have the correct permissions - CHECK THIS BY FOLLOWING @ian_h STEPS!!!
  2. The php version that is set in the cPanel of the shared hosting account was lower than 5.5 - DOUBLE CHECK THIS!!!!
  3. @ian_h steps work for uploading files to the server. If you want to upload the project files in their own folder instead of all at the root, make sure you edit the index.php file in public as follows:
require __DIR__.'/../[name of project folder]/bootstrap/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../[name of project folder]/bootstrap/app.php';

If you don't put the project in its own folder, these lines remain unchanged.

There is no need to include this:

$app->bind('path.public_html', function() {
    return __DIR__;
});

I hope this helps some people...Thanks again everyone!

1 like
ian_h's avatar

Glad all sorted @lrobi2015 =)

Apologies I dropped off the grid, just got home yesterday from being in hospital since last Saturday having my appendix out =)

Cheers..

Ian

1 like
Next

Please or to participate in this conversation.