简体   繁体   中英

How to put laravel 5.3 project on shared hosting

I made a laravel project on my localserver. I just copy the project folder and pasted on my web server in public_html folder. It's giving an error when i open it.

Forbidden

You don't have permission to access / on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Can anyone please let me know step by step how to put my laravel project on web serve?

Well there are three ways to upload and make workable on shared hosting which I came to know.

  • Rename server.php file to index.php (which is not the correct way)
  • Shift public/* to root (also, its not the correct way)
  • Need to add a line in public/index.php after initialization of $app

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

and that's proper way as per my knowledge.

(My last answer was deleted before I could submit my edits, so here's another, more complete answer)

There is an easy answer, and a long answer.

Long answer

The most important part to know is that the only part of Laravel that should be accessible to the public is in the public folder. Which means that, on your shared host, the content of public should reside in whatever folder is the public on your host (they usually are named "www", or "public_html", but it can be anything, really).

I'm going to assume here that you have only one project on your account and say that, if it's the case, you now only need to upload every other file and folder at the same level as the public folder you have and set the correct permission to the storage folder.

In the end, if the only thing you do is upload all of your project to the root folder of your account, then rename Laravel's public folder to public_html , this is supposed to work (of course, assuming that you can also use the CLI and call artisan and composer commands).

Easy answer

If you can use the command line and create synlinks on your host, you can simplify your life by uploading all of your project into a folder outside of the public_html folder and symlink public to your public_html like so: ln -s /full/path1/project/public /full/path/to/public_html

Detailed answer and more tips

You can read this article that goes into more detail and gives commands to achieve everything. I tried to keep my answer as concise as possible, so if you want a more step by step approach, this link or a bit of google searching will do the trick!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM