So I am trying to run my Laravel 8 application on my server. I don't have root/SSH access, so I do everything with an FTP client. I uploaded all my content to my webserver and added my .htaccess file in order to run the application. It works fine in my local environment, but on my server it shows only a blank page. I put some debugging outputs in the public/index.php file and it can var_dump the $app variable.
$app = require_once __DIR__.'/../bootstrap/app.php';
var_dump($app); //Works
But it cannot var_dump $response.
$response = tap($kernel->handle(
$request = Request::capture()
))->send();
var_dump($response); //Never reached statement
I guess it just aborts somewhere deep in the Laravel execution jungle and this would be hard to trace.
This is my project root .htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^(.*)$ public/$1 [L,QSA]
</IfModule>
I cleared everythin in the storage folder but this doesnt make any impact. I also changed permissions of storage, vendor and bootstrap folder to 755 but it didn't change anything.
Locally it works both with php artisan serve or by placing everything in my htdocs folder of my XAMPP installation and browsing there.
What is the problem here?
Related
Laravel Version - 5.8.
I have to deploy my Laravel project on Shared Hosting without using php artisan serve command. So for that reason, I have renamed my root file server.php file to index.php.
Will there be any security consequences or bug, if I rename the file server.php to index.php?
you don't need to rename server.php to index.php. Just move the Public/index.php to the root of the folder and change the necessary path inside the index.php after moving. It will work for sure.
If you using cPanel, you can change webroot to public very simple don't need to rename server.php. If not you can using .htaccess to redirect all request to public folder like this :
# 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>
I have a Laravel 5.3 website, but now that I want to put it online on my server, I realize that I can't change the vhosts to make it work properly.
How can I make my website work, without vhost? I now that Zend Framework can run just fine using only .htaccess configurations. That is a way of doing it for Laravel?
The solution should allow the website to work both ways: with and without the vhosts!
This is may help.
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);
Last create a .htaccess file on root directory.
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>
I have a domain say www.example.com and on the root of the domain I have a folder called development. Inside development I have a folder called hunterlp and inside the hunterlp folder all my laravel files are placed when I navigate to http://www.example.com/development/hunterlp/ i am greeted by a 500 internal server error.
I moved all my folders from public to the hunterlp root folder and placed a .htaccess with the following in
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
# 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}]
How can I make my laravel site work in that folder?
please follow this instruction its work for you
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:
7. require __DIR__.'/../myproject/bootstrap/autoload.php';
8. $app = require_once __DIR__.'/../myproject/bootstrap/start.php';
for the 7 and 8 steps give the path where you source has so that file find that files
Hope this is works.
I have a problem deploying Laravel 4 on shared hosting server. Currently I have access to cpanel with PHP version is 5.3.28 ( with no ssh access ).
I created the laravel project on my localhost and it worked pretty well. Then I uploaded all laravel project files to the server and I have changed url variable in app/config/app.php from http://localhost to the new address. But when I view my page, browser shows just a blank page.
for testing that, I echoed somthing in index.php and it printed well.
but when I echoed here: Route::get('/', function(){ echo "hello"; } ); nothing appeared in the page.
here is my .htacess file beside index.php in public folder:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Have you checked the permission of your app/storage folder?
You need to make it writable by the web server.
For example, on my mac, my web user is _www. So you can use following command to make it work.
sudo chown -R _www LARAVEL_PROJECT/app/storage
or
sudo chown -R a+w LARAVEL_PROJECT/app/storage
This is a very noob question. I'm basically just trying to run the "hello world" of Silex. I've installed the silex.phar file in my directory, setup the .htaccess file as such:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
#RewriteBase /projects/silex/ ###--> commented out because file is in root dir. <--##
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
and then run these two lines of code on the index.php file:
require_once __DIR__.'/silex.phar';
$app = new Silex\Application();
I am getting a 500 internal server error. ("File does not exist")
I am running php 5.3.8 on Linux.
Is there a PHP setting I should be looking for?
Turns out there is a bug called the phar-stub bug. It will tell you that Silex\Application could not be found. A workaround is using the following include line:
require_once 'phar://'.__DIR__.'/silex.phar/autoload.php';
source