Support the ongoing development of Laravel.io →
Installation Configuration
Last updated 1 year ago.
0

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.

0

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?

0

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.

0

However. I installed laravel 4 in shared hosting.5 wont work/

0

Tell your admins to make root /public and you are good to go.

0

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..

Last updated 9 years ago.
0

Ok, I think that I found the solution for my question: ini_set('eaccelerator.enable', 0); should be added to index.php

0

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?

0

My procedure for installing Laravel 5 on shared hosting with Apache and cpanel

  1. connect to hosting via SSH

  2. install composer

  3. in cpanel open Select PHP version and choose 5.4. (I also set phar extension)

  4. install laravel: php composer.phar create-project laravel/laravel myproject --prefer-dist

  5. copy everything from myproject/public to public_html

  6. 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..

Last updated 9 years ago.
0

its worked for only home page.other pages doesn't work.may problem with .htaccess.

0

I've tried it on my shared hosting. Here's what I did.

  1. Install and setup laravel on your local (meaning you local machine)

  2. Once done, copy all files to your hosting.

  3. Create an .htaccess file on your laravel's root directory. This is to access it without the "public" on the url.

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{REQUEST_URI} !^public

RewriteRule ^(.*)$ public/$1 [L]

</IfModule>
Last updated 9 years ago.
0

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.

0

Hi,

Finally I did the job on my shared hosting (I use Bluehost)... This is what I did

  • 1.- Setup a project Laravel 5 in localhost correctly configured
  • 2.- Double check the server configuration of PHP 5.4 (this because every little change on .htaccess file may change that config)
  • 3.- Create a directory in the same level of public_html and put the project inside of that folder.
  • 4.- Put the content of public (L5) directly on public_html (be aware of don't overwrite the .htaccess file accidentally)

Now... This is the "tricky part"... actually not xD In Bluehost I see this structure

  • mail
  • perl5
  • php
  • public_html
  • [framework-folder]
  • ssl

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

Last updated 9 years ago.
0

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.

Last updated 9 years ago.
0

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 ?

0

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.

Last updated 6 years ago.
0
<p>if you do not have SSH access do the following:</p> <p>1. empty the content of publics directly on your project folder</p> </p>2. Edit index.php now in your-project/index.php and not your-project/public/index.php </p>

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';

  1. Edit server.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

0

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

0

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!

Last updated 8 years ago.
0

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..

0

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

0

Another working solution: https://medium.com/@kunalnagar/deploying-laravel-5-on-godaddy-shared-hosting-888ec96f64cd

0

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...

0

Below are steps I've set on a hosting with cPanel without any changes in laravel_app:

  1. check out/copy laravel_app code to your home, /home/your_user/laravel_app

  2. 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

  1. create symlink ln -s /home/your_user/laravel_app/public ~/public_html/laravel_app_public

  2. 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]

0

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...

<IfModule mod_rewrite.c> RewriteEngine On

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Thanks

Last updated 8 years ago.
0

ricksonchew said:

I've tried it on my shared hosting. Here's what I did.

  1. Install and setup laravel on your local (meaning you local machine)

  2. Once done, copy all files to your hosting.

  3. Create an .htaccess file on your laravel's root directory. This is to access it without the "public" on the url.

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{REQUEST_URI} !^public

RewriteRule ^(.*)$ public/$1 [L]

</IfModule>
0

This was simple and worked on Dreamhost for me.

0
  1. First make zip of your project.

  2. Upload it to the public_html or www according to your hosting.

  3. Extract it. Open your project.

  4. Move all files from public folder to your project main folder.

  5. 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
Last updated 7 years ago.
0

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-ho...

0

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/

0

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>
Last updated 6 years ago.
0

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.

0

@kevosomi it works but not on all pages, it does not retrieve requested data..

0

@luanntvn's soln worked perfectly.

Last updated 6 years ago.
0

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

https://gist.githubusercontent.com/petehouston/32ae937e3b7bfab...

By:Xtreem Solution

Highly Skilled Laravel Developer

Dedicated PHP Developer

0

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/

0

Sign in to participate in this thread!

Eventy

Your banner here too?

itarafath itarafath Joined 11 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.