There's nothing special. you need to copy all the files to the server. You can write a gulp task to do this. I'm using something like that with vinyl ftp. works perfectly.
doesn't work copy all files to server. I have tried, but I received error 500.
I cannot find the file bootstrap/paths in laravel 5 Maybe I need change the path in index.php...
I don't know how to begin..
Anybody help me?
Laravel is not designed to work on shared hosting providers. You can hack up framework of cource but I dont recommend it.
Nowdays SSD hostings are cheap. With forge it is possible to set up server for 15$/m easy.
Hi, I would like to use Laravel 5 on shared hosting. I use SSH connection to my user folder. I installed composer successfully. Then I run "php composer.phar create-project laravel/laravel laravel --prefer-dist" and that was fine (I just had to enable proc_open before). Ok, the next step should be redirecting public folder and here I have problems. I copied all files from laravel/public to public_html.
Then I corrected paths in public_html/index.php:
require DIR.'/../laravel/bootstrap/autoload.php';
$app = require_once DIR.'/../laravel/bootstrap/app.php';
When I open the site in browser I get this error: PHP Catchable fatal error: Argument 2 passed to array_first() must be callable, integer given, called in /home/myuser/laravel/storage/framework/compiled.php on line 1446 and defined in /home/myuser/laravel/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 134
What now ? Please, help.. I'm so close to make it work..
Ok, I think that I found the solution for my question: ini_set('eaccelerator.enable', 0); should be added to index.php
pitagora04 said:
Ok, I think that I found the solution for my question: ini_set('eaccelerator.enable', 0); should be added to index.php
Did you got the solution?
My procedure for installing Laravel 5 on shared hosting with Apache and cpanel
connect to hosting via SSH
install composer
in cpanel open Select PHP version and choose 5.4. (I also set phar extension)
install laravel: php composer.phar create-project laravel/laravel myproject --prefer-dist
copy everything from myproject/public to public_html
open public_html/index.php and set:
require DIR.'/../myproject/bootstrap/autoload.php';
$app = require_once DIR.'/../myproject/bootstrap/start.php';
and put this on top:
ini_set('eaccelerator.enable', 0);
Hope this could help somebody..
its worked for only home page.other pages doesn't work.may problem with .htaccess.
I've tried it on my shared hosting. Here's what I did.
Install and setup laravel on your local (meaning you local machine)
Once done, copy all files to your hosting.
Create an .htaccess file on your laravel's root directory. This is to access it without the "public" on the url.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>I received error 500. means an error on the server.
Of course you need to do some configuring. check your laravel logs. The error should be there. probably a missing php extension or your htaccess file is not properly configured. set your app debug mode to true temporally laraval will throw the error.
Hi,
Finally I did the job on my shared hosting (I use Bluehost)... This is what I did
Now... This is the "tricky part"... actually not xD In Bluehost I see this structure
Inside of public_html I can see all the files of public directory of Laravel 5
Go to index.php and edit the line 22
#From this
require __DIR__.'/../bootstrap/autoload.php';
#To this
require __DIR__.'/../[framework-folder]/bootstrap/autoload.php';
And the line 36
#From this
$app = require_once __DIR__.'/../bootstrap/app.php';
#To this
$app = require_once __DIR__.'/../[framework-folder]/pulcro/bootstrap/app.php';
The final step is to edit the .htaccess file and add some lines
RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)$ /$1 [L]
Refresh the cache of my browser and.. Victory!!
I know that this is not the absolute right way to install the framework (God, I never spoke about Composer)
But... It's working for me now
Hope that this can help somebody in order to deploy Laravel 5
Regards
I was running into similar issues running Laravel 5 on shared hosting. I had better luck running Laravel on OpenShift Online.
I put together a QuickStart if anyone is looking for an easy/free way to get Laravel up and running: Laravel 5.0 on OpenShift
Check out the README on GitHub for the ins/outs of local/remote deployment, debugging, running migrations, etc.
Oh i see now. Was laravel installed on the server using a command from cpanel or something? how did it go in to the framework directory ?
I would never recommend shared hosting for Laravel because of its security issues that the server faces.
Shared servers are usually prone to hacking attacks and if any malicious activity occurs, it effects whole network of websites using the server. Plus, you might experience resource limitation as everybody else in the network uses the same CPU, memory and hard drive. Or your server may get swamped by requests or overloaded which might cause it to stop.
So I believe dedicated hosting is a better choice than hosting a Laravel app on shared server. I would highly recommend Cloudways.
I have recently started my project on Laravel 5 there. Created my server on DigitalOcean in just 7 minutes with pre-installed Laravel 5.0.4 <redacted - mixed content>.
There also provide Google Compute Engine and Amazon AWS servers.
from require DIR.'/../bootstrap/autoload.php'; to require DIR.'/bootstrap/autoload.php';
from $app = require_once DIR.'/../bootstrap/app.php';
to $app = require_once DIR.'/bootstrap/app.php';
from
if ($uri !== '/' && file_exists(DIR.'/public'.$uri)) { return false; }
require_once DIR.'/public/index.php';
to
if ($uri !== '/' && file_exists(DIR.'/'.$uri)) { return false; }
require_once DIR.'/index.php';
that's all...now you can access your project from localhost/your-project
I can see the welcome Zen greeting page but if I try to navigate to another page I get a 404 error. Im using laravel 5 and I'm on hostgator
So, I've been having this problem for a while but I just figure out how to solve thanks to ricksonchew's comment.
The shared hosting site I use is: https://byethost.com/
The Laravel version is: 5
After uploading my project(40 mins), I created 2 .htaccess files and each one has a purpose.
I pasted the .htaccess file to the public directory.
This is what it should be written in the file:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I also added another .htaccess to the root laravel project directory:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
The explanation is simple, if you've noticed, the first file gets rid EXCLUSIVELY of the "index.php" path, you can add an then test by yourself. The second .htaccess gets rid of the "public" path, then hen you type in the domain name, these files probably will solve the problem for you!
Hi pitagora04, Thanks for your post. Just wondering... how did you enable proc_open through ssh?
Cheers
pitagora04 said:
Hi, I would like to use Laravel 5 on shared hosting. I use SSH connection to my user folder. I installed composer successfully. Then I run "php composer.phar create-project laravel/laravel laravel --prefer-dist" and that was fine (I just had to enable proc_open before). Ok, the next step should be redirecting public folder and here I have problems. I copied all files from laravel/public to public_html.
Then I corrected paths in public_html/index.php:
require DIR.'/../laravel/bootstrap/autoload.php';
$app = require_once DIR.'/../laravel/bootstrap/app.php';
When I open the site in browser I get this error: PHP Catchable fatal error: Argument 2 passed to array_first() must be callable, integer given, called in /home/myuser/laravel/storage/framework/compiled.php on line 1446 and defined in /home/myuser/laravel/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 134
What now ? Please, help.. I'm so close to make it work..
itarafath said:
how to Setup Laravel 5 in Shared Hosting ?
This is a good option , supports laravel May from $ 3.5 / month www.hostinglaravel.com/planes.php
Another working solution: https://medium.com/@kunalnagar/deploying-laravel-5-on-godaddy-shared-hosting-888ec96f64cd
I recently wrote an article on how I was able to host my laravel on a shared host. http://www.stuckcoders.com/how-to-host-your-laravel-project-in-a-shared-hosting/
Below are steps I've set on a hosting with cPanel without any changes in laravel_app:
check out/copy laravel_app code to your home, /home/your_user/laravel_app
set permissions:
chmod 755 /home/your_user/laravel_app/ chmod 755 /home/your_user/laravel_app/public/ chmod 644 /home/your_user/laravel_app/public/index.php chmod -R 777 /home/your_user/laravel_app/storage
create symlink ln -s /home/your_user/laravel_app/public ~/public_html/laravel_app_public
create ~/public_html/.htaccess following hoshomoh's instruction
Options -Indexes
RewriteEngine On RewriteCond %{REQUEST_URI} !^/laravel_app_public/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ laravel_app_public/$1 RewriteRule ^(/)?$ laravel_app_public/index.php [L]
How do you disable varnish cache in the .htaccess ??
One.com (shared host) keeps sending me this:
You add one line in your htaccess file in the root directory with only this "disablevcache" "true"
But suprise suprise, this does not work... !!
Is this meant to be in the .htaccess in the root folder??? And where do you put it if THIS is your .htaccess so far...
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Thanks
ricksonchew said:
I've tried it on my shared hosting. Here's what I did.
<IfModule mod_rewrite.c>
Install and setup laravel on your local (meaning you local machine)
Once done, copy all files to your hosting.
Create an .htaccess file on your laravel's root directory. This is to access it without the "public" on the url.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
First make zip of your project.
Upload it to the public_html or www according to your hosting.
Extract it. Open your project.
Move all files from public folder to your project main folder.
Open index.php file. Change below two lines.
require DIR.'/../bootstrap/autoload.php';
$app = require_once DIR.'/../bootstrap/app.php';
to this
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
6 Open server.php. Change below two lines
if ($uri !== '/' && file_exists(__DIR__.'/public/'.$uri))
require_once __DIR__.'/public/index.php';
to this
if ($uri !== '/' && file_exists(__DIR__.'/'.$uri))
require_once __DIR__.'/index.php';
7 Open .htaccess file. Replace all with below lines
DirectoryIndex index.php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RedirectMatch 404 /\.git
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/index.php [L]
</IfModule>
8 Open .env file. Change
APP_URL=http://localhost
to this
APP_URL=yourdomain
You can follow this step by step guide here. It's almost same as the solution accepted, but it would be more clear if we can refer a blog post on it http://justlaravel.com/how-to-deploy-laravel-project-shared-hosting/
HOSTING LARAVEL 5.4 PHP 7 Shared Hosting It offers web hosting for your projects in Laravel Framework all versions (4.x up to 5.4), we have support for PHP versions 5.3, 5.4, 5.5, 5.6, 7.0 and 7.1, up to 20 times faster thanks to the storage technology SSD. Http://hostinglaravel.com/
Hey Guys,
This is a probably very late solution but I hope it will help someone in future. Create a .htaccess and place the file in your laravel root directory. Then paste the following and save. It should solve all the problems regarding shared hosting and 404's being thrown when visiting any other pages apart from the homepage.
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.codestudio.club/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: [email protected]
ErrorDocument 404 /index.php
</IfModule>
Probably a very late reply but may help others. I followed the same method as @luanntvn about the symlink process and in my opinion is the simplest approach for deploying a laravel application on a shared hosting. I had no problems in hosting my application and it runs great.
First, let say in your hosting server (VPS, or shared hosting…whatever), you have current www/ directory, which is accessible publicly via web domain, for example:
/Users/petehouston/www/
Now, create a new directory, which contains all your application source code, at the same level as www/, for example:
/Users/petehouston/project/
You can use git, svn, mecurial or whatever method you like to transfer your code to this directory.
At this point, you can see that the project code is apparently not accessible to the web, right?
Next step is to copy all contents inside the /project/public directory to www/ directory. The easy example is that, with the fresh Laravel 5 installation application, the project/public/index.php should be copied to the www/index.php , have you got the point?
Remember to copy the public/.htaccess to the www/ also. Don’t forget this, it is very important for your app routes. Without it, your routes won’t be working and there will be a blank or empty page in every route.
Now let’s modify the www/index.php to reflect the new structure. Don’t modify the project/public/index.php, okay? Only modify www/index.php, remember this!!!
Find the following line require DIR.’/../bootstrap/autoload.php’; $app = require_once DIR.’/../bootstrap/app.php’;
It worths to mention that some shared hosting service providers allow symlink to the public_html directory of the main domain, we can simplify the process, instead of copying the whole project/public/ to /www, we create symbolic linking,
ln -s /Users/petehouston/project/public /Users/petehouston/www
Almost done, it is time to set permissions for the project/storage directory, it should be writable.
$ chmod -R o+w project/storage
The final step is here, config your application variables in the project/.env .
All righty right! Everything should work now.
If you don’t have composer installed already on your server, you can easily grab it to the project directory then.
$ cd /User/petehouston/project/ $ curl -sS https://getcomposer.org/installer | php — –filename=composer
Now you can execute composer to manage dependencies.
$ php composer install $ php composer dumpautoload -o $ php artisan config:cache $ php artisan route:cache
From now on, each time you deploy, I mean you update the project/ directory, you will need to reflect all changes in project/public/ directory into www/, except the www/index.php, which is already configured above to include the correct paths.
You can easily achieve this via bash shell command line. I wrote this little script sync.sh, you can use this by putting into the same directory level with project/ and www/
$ pwd /Users/petehouston/project $ cd .. $ pwd /Users/petehouston $ ls project/ www/ sync.sh $ chmod +x sync.sh $ ./sync.sh
By:Xtreem Solution
I recently wrote an article on how I was able to host my laravel on a shared host. (Hostgator) https://www.5balloons.info/hosting-laravel-5-5-project-on-shared-hosting-hostgator/
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community