Laravel blank white screen in deploy website - php

Please, some help for deploy Laravel 5.2 website, in below error message in public_html/error_log :
[21-Mar-2017 07:39:30 America/Chicago] PHP Fatal error: require(): Failed opening required '/home/exoweb/public_html/allos/bootstrap/autoload.php' (include_path='.:/opt/alt/php55/usr/share/pear:/opt/alt/php55/usr/share/php') in /home/exoweb/public_html/index.php on line 22
I succeeds to start my web site, by changing the index.php file in public_html
require DIR.’/../allos/bootstrap/autoload.php’;
$app = require_once DIR.’/../allos/bootstrap/app.php’;
BUT I have an error when my controller uses a request with Eloquent, by against it works very well with query builder!

run composer update in the application directory. Always run composer update when you move an application which has composer as its dependency manager.

If there are still errors and you dont have access on Ssh , maybe tray to delete the cache files :
Bootstrap : services.php, settings.php Delete
Storage/Framework/Cache Delete all files
Storage/Framework/session Delete all files
Storage/Framework/views Delete all files
And refresh the site.
good luck :)

Have you try to access your website like your-site-url/public?
If it is running successfully in public directory then you just have a problem of redirecting.
So, place this .htaccess file into your root directory.
If your application is built in php version 7 then use this .htaccess file.
AddHandler application/x-httpd-php70 .php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
for rest of the php version<7, use this .htaccess file.
AddHandler application/x-httpd-php56 .php .php5 .php4 .php3
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Related

Laravel site down, .htaccess file keeps reappearing every time I delete it

I have a Laravel website that has been hacked in some way.
In the root directory, there now appears what looks like a Wordpress installation. I've deleted all those Wordpress files (along with my Laravel files), but there's an .htaccess file that keeps reappearing every time I delete it.
The contents of this file:
<FilesMatch ".(PhP|php5|suspected|phtml|py|exe|php)$">
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch "^(votes.php|index.php|wjsindex.php|lock666.php|font-editor.php|contents.php|wp-login.php|load.php|themes.php|admin.php|settings.php|bottom.php|years.php|alwso.php|service.php|license.php|module.php)$">
Order allow,deny
Allow from all
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
When I try to edit the file and save the changes, the next second it has the old content again.
How can I solve this? Other sites I have on the same server are not affected. This particular site had debug=true in .env so that might be how the breach happened.
I had this same issue on my laravel 7 hosted on namecheap. If your host is namecheap, you can follow the steps below.
Zip your project and download it.
Delete the rest of the files from the server. (note that, index.php and .htaccess won't delete but do not worry,
Contact namecheap to help you delete the two files (.htaccess and index.php).
Delete every instance of .htaccess on the local project you pulled down because this virus duplicated .htaccess file on every folder and sub folder of your project. On mac, you can simply run the code below
find websitefolder -name .htaccess -delete
The virus is been created in a folder called css in the root directory. It contains two files. index.html and load.php. Delete the entire folder to wipe the virus away.
Recreate a new .htaccess. You can simply copy from another laravel project as they are always the same.
After making sure that the public_folder of your Cpanel is empty, you can reupload your website. I'm still researching personally on the very attack that caused this issue at my own end. Maybe when I find it I can share it with you.

Laravel 8 application shows blank page on webserver

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?

Accesing laravel public folder using root index file

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>

Remove public from URL Laravel 5.3

I'm using Laravel 5.3 is there a easy way to remove public from URL? is it necessary to add a htacces. when I change the htacces it is getting a n error like below,
copy both htaccess and index.php file from public folder to root directory and then change root index.php code as below
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
After installing Laravel, you should configure your web server's document / web root to be the public directory. The index.php in this directory serves as the front controller for all HTTP requests entering your application.
https://laravel.com/docs/5.3/installation#configuration
Do not edit .htaccess or Laravel related files, just point web server to a public directory instead of Laravel project directory:
DocumentRoot "/path_to_laravel_project/public"
<Directory "/path_to_laravel_project/public">
Then restart Apache.
Add a .htaccess file in root which contains -
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
Yes it is very simple no need to add extra htaccess,
Create a new folder in your laravel project folder.
Name it whatever you like. Example :- source
Move all the files from root into 'source' folder except 'public' folder.
4 . Move all the files from public folder to root.
5 . Change the autoload.php path
6 . Thats all. remove public folder if necessary.
In the root directory create a .htaccess file and put the following in
it
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Even above solution(s) work(s) for you,but I would recommend not to do this.
Here is the reason why.
-You should be pointing your Apache host root to the $LARAVEL_PATH/public directory instead of $LARAVEL_PATH.
-you have to configure apache for user not access .env, git files , config folder's file
public directory is there for reason to make project a bit more secure. Solve the actual problem and don't try to break this simple but nice security addition.
Copy all files and folder from public folder to root folder and edit your .htaccess file as
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
And dont forget to change the paths in index.php file.
For details refere following links
Installing Laravel in a subfolder
https://ellislab.com/forums/archive/viewthread/151342/#734511

How to use separate php version for different php files

I have a site (based on ZEND framework) and hosted on 1and1 server.
1and1 server uses PHP version 5.2.17 and 5.4.5. I need to use PHP version 5.4.5 for a few files only. This is because some of my other files show a errors if I use PHP 5.4.5 but they execute fine using PHP 5.2.17.
On my .htaccess file the line below was written earlier to use PHP 5.2.17
AddType x-mapp-php5 .php
To use PHP 5.4.5 I have to use the the line below (instructions to use this code will be found on the 1and1 faq page)
AddHandler x-mapp-php6 .php
FAQ url(s):
http://faq.1and1.com/scripting_languages_supported/php/7.html
http://faq.1and1.com/scripting_languages_supported/php/6.html
Is there any way to use PHP 5.4.5 for those specific files only?
I tried to use the line below in .htaccess, but it's not working:
AddType x-mapp-php5 .php
AddHandler x-mapp-php6 FilenameController.php
EDIT
I tried to edit the 5.2 code. I am using PEAR packages to create Excel sheet which is working fine with PHP 5.2.17 but displaying the error below on PHP 5.4.5
Fatal error: Cannot redeclare _PEAR_call_destructors()
Addendum
This change to the .htaccess file
AddType x-mapp-php5 .php
AddHandler x-mapp-php6 .php6
SetEnv APPLICATION_ENV development
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^FilenameController\.php$ FilenameController.php6 [L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
generates 404 "Page not found" error if I change the filename of FilenameController.php to FilenameController.php6 and when I am trying to visit the page its generating.
Why not just
AddHandler x-mapp-php6 .php6
And rename your 5.4 scripts to php6? You can even hide this from the user by doing the following in your .htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^FilenameController\.php$ FilenameController.php6 [L]
This does an internal direction to a .php6 extension for that one script file. :-)
However, let me emphasise: you can only choose which scripting engine to use on a per request basis not on a per file basis. For example: http:/yourdomain.com/FilenameController.php will be handled by the PHP 5.4 RTS and all included files will be compiled and executed using PHP 5.4; http:/yourdomain.com/index.php will be handled by the PHP 5.2 RTS and all included files will be compiled and executed using PHP 5.2.
You can't use 5.4 to compile on file within an application and 5.2 to compile the rest.
1and1 server uses PHP version 5.2.17 and PHP version 5.4.5.
I'd be curious as to the details of this.
Assuming you run php as an Apache module (mod_php), you can only have one version running on the same installation of Apache at a time. Are you sure that your server even allows to use both at the same time? More likely, you can restart Apache and have it run with a different version. If that is the case, you can't really configure your way out of this, lest you want to set up php over cgi.

Categories