Deploying Laravel 4 on hosting server - laravel

I have a problem deploying Laravel 4 on hosting server (hostgator). I have uploaded all files to the server. Current PHP version is 5.3.24 and I have followed all the instructions on four.laravel.com/docs/installation.
I get following error:
Fatal error: Call to a member function run() on a non-object in /home3/varoid/public_html/index.php on line 51

If you look at the index.php in your public_html folder, you'll see it calls $app->run(). Since run isn't defined, $app is probably not available. On line 35 the $app is set like this:
$app = require_once __DIR__.'/../bootstrap/start.php';
It doesn't work for you, so this means the start.php could not be found. Maybe you placed it elsewhere than the default path? In case you didn't know __DIR__ means, the current dir (public_html). Just make sure the file exists and try again!

Related

How to deploy laravel project on ovh hosting?

For the last month I coded a laravel project on local, using Laragon to have a local server. Now I want to deploy it online, using an ovh hosting ( required by a client ). So I have my ovh hosting, with the "perso" offer.
I used the ftp credentials given by ovh, with FileZilla, and it worked. It gave me something like this :
Then I uploaded all my project in the www folder. Now, when go to the domain, it doesn't display the front page but rather the folder itself, aka this :
For now, I didn't touch the .env file. I deleted the default index.html in the www folder, I know the problem probably come from this. I searched everywhere and found not clear explanation. My knowledge on web hosting is limited, so I'm struggling with this. I know I missed something. Anyone who could help me, would save my life. Thank you !
do not put you project files in the www folder, instead put them in a folder outside that directory 'called laravel for example'.
then copy or move the contents of the 'public' directory to 'www'. (www dir will now contain index.php,...).
edit the two lines in www/index.php that require autoload.php and app.php to reflect the new directory changes:
require __DIR__.'/../vendor/autoload.php';
should be:
require __DIR__.'/../laravel/vendor/autoload.php';
and
$app = require_once __DIR__.'/../bootstrap/app.php';
should be:
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
The best is to create a new folder in the /www folder with the name of your project.
For exemple: /www/laravel-project
Then you will need to go OVH admin panel, click on your domain and change the folder it is going to by /www/laravel-project/public
You need to go to the public folder of your Laravel project.
saying that your project name is : Laraval_project :
using "filezilla", put 'laravel_project/' under the directory 'www/'.
find the dir named : 'public/' under 'laravel_project/' and copie/pass it in the the parent dir, wich is : 'www/'.
now u have side by side 'laravel_project/' and 'public/' under 'www/'.
in 'public/' folder u'll find four files -> move them all to the parent dir, wich is 'www/'..
edit www/index.php file as Rabah said :
edit the two lines in www/index.php that require autoload.php and
app.php to reflect the new directory changes:
require __DIR__.'/../vendor/autoload.php';
should be:
require __DIR__.'/laravel_projec/vendor/autoload.php';
and
$app = require_once __DIR__.'/../bootstrap/app.php';
should be:
$app = require_once __DIR__.'/laravel_project/bootstrap/app.php';
if ther is a file named : 'www/index.html', rename it :
'index.html.old . enjoy

How to deploy laravel to server using ftp

Hi I'm newbie on Laravel. I have to upload laravel project to Linux server(CentOS). Customer provide me ftp path. For example 10.222.20.10/srp. So I put all files into that path and after edited database inside .env file. I run 10.222.20.10/srp on webbrowser but I getting error 'This page is not working, error 500'. I attached picture as below. Appreciated for advise and thank you very much.
Please Follow this Steps:
1.
Copy all contents inside the /project/public directory to project/
Remember to copy the public/.htaccess to the project/ also
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’;
And update them to the correct paths as following
require __DIR__.’/../project/bootstrap/autoload.php’;
$app = require_once __DIR__.’/../project/bootstrap/app.php’;
2. Set permision 777 project/storage and project/bootstrap/cache
Maybe this tutorial will help you Deploy Laravel To Shared Hosting The Easy Way
Please Follow this Steps:
1.public folder(index.php) is the start point of your application set
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
according to your configuration or use symlink
2.Migrate Database (if you don't have ssh access create a route and use Artisan facade Artisan::call("migrate"); and don't forget to remove it )
3.Link storage if you need (if you don't have ssh access create a route and use Artisan facade Artisan::call("storage:link"); and don't forget to remove it )
4.Check server logs maybe folder premissions is wrong.

Laravel 5.5 | Redirect main domain to public folder

I have laravel 5.5 project uploaded to live hosting on /public_html/commerce.
When I go to domain.com/commerce/public then everything looks working perfectly.
But when I point the domain directly to commerce/public, so; when I visit domain.com then all links got broken like this:
domain.com/product/domain.comget-item-sizes-detail
Route for above link:
Route::post('/get-item-sizes-detail', 'ProductController#getItemSizesDetail');
Ajax request:
url:'get-item-sizes-detail',
type:"POST",
dataType:"JSON"
Any suggestions?
Here's a quick fix:
Create a folder in your public_html directory
I will call it webroot you can call it anything you want.
Put all the content of your Laravel public folder inside public_html directory
Put all other remaining files and folder of your Laravel project inside webroot
Edit public_html/index.php, change line 22 require __DIR__.'/../bootstrap/autoload.php'; to require __DIR__.'/webroot/bootstrap/autoload.php'; and change line 36 $app = require_once __DIR__.'/../bootstrap/app.php'; to $app = require_once __DIR__.'/webroot/bootstrap/app.php';
So you don't have to point your main domain to public_html/public again.
Just accessing the maindomain.com should have your project running just like using PHP artisan serve. But still using a service like Forge or Fortrabbit is the best way to host your Laravel app.
Good luck

How to access settings from `.env` inside the `index.php`

I’m creating a deployment configuration for Laravel project.
On my hosting public/ folder must be moved to another place.
Obviously, since that, I need to change path to the autoload.php and app.php in index.php.
However, I’d like to add and use a parameter which would tell where these files reside. Something like this:
require __DIR__ . '/../' . env('DEP_EXT_FOLDER') . 'vendor/autoload.php';
I think, the most proper place for such a parameter is .env file.
However, I’ve got an error:
Call to undefined function env()
You can't use the env() function before loading the autoloader.
if you absolutely want to use your .env file, you will have to use native php preg_match() for finding your key and using the value after that :)

Publishing site created with Laravel error

Hi there i follow this tutorial how to setup on the FreeWebHostingArea com :
If your domain is pointed to public_html directory then all content should placed in that directory. How ? let me tell you
Copy all files and folders ( including public folder ) in public html
Copy all content of public folder and paste it in document root ( i.e.
public_html ) Remove the public folder Open your bootstrap/paths.php
and then changed 'public' => DIR.'/../public', into 'public' =>
DIR.'/..',
and finally in index.php,
Change
require DIR.'/../bootstrap/autoload.php';
$app = require_once DIR.'/../bootstrap/start.php'; into
require DIR.'/bootstrap/autoload.php';
$app = require_once DIR.'/bootstrap/start.php';
but when i load the index i get this error
Fatal error: require(): Failed opening required
'/home/vhosts/epernikhardware.eu5.org/vendor/composer/autoload_files.php'
(include_path='/home/vhosts/epernikhardware.eu5.org/vendor/phpseclib/phpseclib/phpseclib:.:/usr/share/pear:/usr/share/php')
in
/home/vhosts/epernikhardware.eu5.org/vendor/composer/autoload_real.php
on line 47
And can amy one explain me how to easily get this simple site to work is it so hard to publish a few web pages with laravel framework. Please help
I don't know about that hosting but for other hosting service such as JustHost, GoDaddy, BlueHost, HostGator... I deploy the Laravel web pretty much easy.
1) Access to the host via SSH, get the source code
$ cd www/
$ git clone https://github.com/ME/MY-PROJECT.git .
2) Get Composer:
$ curl -sS https://getcomposer.org/installer | php -- --filename=composer
3) Update all dependencies (/vendor)
$ composer update
4) Move the /public/.htaccess to the root
$ mv public/.htaccess .
That's all, site is ready. Perhaps, there are more steps in configuring the database but it is not necessary to mention here.
If you host your site on Forge or DigitalOcean, the process would be much easy, just add the source origin, and most of things will be done automatically.
Make sure the PHP version in your computer and the PHP version in the cpanel of your hosting site is the same. I also had the same problem and this helped me.

Resources