how to install laravel on hostinger server/ any other free hosting server. I had learned and done working codes in localhost. But i would like to run it on a real server.
Laravel Version : 5
PHP Version Server :5.5.35
1) I had copied the full laravel code to "/home/< username >/"
2) copied the files in /home//laravel/public to /home/< username >/public_html
But it shows an error.
Fatal error: require(): Failed opening required '/home//public_html/../bootstrap/autoload.php' (include_path='.:/opt/php-5.5/pear') in /home//public_html/index.php on line 22
Answer :
Use Heroku Server as @lciamp Suggested in the comment
Clarification :
Please suggest me a list of Payed Servers which support Laravel Framework
Since you have SSH access do this:
Filesystem
- SSH into the server
- Change directory to the project root
- delete the
public_html
folder
- create a symbolic link from
public
to public_html
ln -s /home/< username >/public /home/< username >/public_html
- Install Laravel dependencies
- Change permissions
chmod -R 755 *
chmod -R 777 storage/ bootstrap/cache/
Checklist
- Make sure your environment file uploaded and is proper.
- If the server is Apache, make sure you uploaded the
.htaccess
files.
- You probably uploaded all the assets, if so you will not need to do bower or npm.
- Restart the server.
**In Case of a Limited Shell Environment
- Install Laravel dependencies locally and upload the
vendor
folder with everything else.
- Instead of uploading the whole Laravel app to
/home/< username >/
upload it to /home/< username >/public_html
.
Modify your /home/< username >/public_html/.htaccess
to redirect all requests to the public
subfolder.
# /home/< username >/public_html/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect All Requests To The Subfolder
RewriteRule ^ /public
</IfModule>
Make sure you have the proper /home/< username >/public_html/public/.htaccess
(GitHub).
# /home/< username >/public_html/public/.htaccess
<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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
After you copy the code to your hosting server, you need to install the composer
packages required to run Laravel. You can do this using composer install
(providing that composer
is installed). Otherwise, you need to install composer
first.