Laravel Project Not Running On Server - laravel-6

I have deployed my laravel project on server. When I hit the url it gives me error but no log is generated in log folder.
This page isn’t working
[Domain Name] is currently unable to handle this request.
HTTP ERROR 500
I have moved the public folder contents to root directory and edited the index.php.
I checked the permission for storage, vendor and bootstrap folder and they have required permission.
index.php
<?php
define('LARAVEL_START', microtime(true));
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
Server.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
The project is hosted on shared hosting and I've used filezilla to upload it on server. What else I need to do to make it work. This is my first uploading the project on the server.

Related

404 Not Found - on Laravel 5.8 when the route already exists

I have a laravel 5.8 project on a hosted site and I recently added JWT Authentication in order to create APIs for mobile applications. Every API I have created is working fine and sending a proper response, except sometimes I am getting a 404 Not Found error even when the route exists in api.php which I'm calling as https://app.mydomain.com/api/apiname.
Here's how my .htaccess file looks as below.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# 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}]
</IfModule>
and my api.php in Routes is as below,
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ApiAuthController;
use App\Http\Controllers\ApiSettingsController;
use App\Http\Controllers\ApiManageUsersController;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
//api test
Route::get('/my-api-endpoint', function (Request $request) {
return response()->json(['Hello Laravel 7']);
});
//Auth Routes
Route::post('login', 'ApiAuthController#login');
Route::post('logout', 'ApiAuthController#logout');
Route::post('refresh', 'ApiAuthController#refresh');
Route::post('/rest/re_login', 'ApiAuthController#re_login');
Route::GET('/language_json', 'ApiAuthController#language_json');
//Settings Routes
Route::GET('/branding_info', 'ApiSettingsController#branding_info');
Route::POST('/update_branding_info', 'ApiSettingsController#update_branding_info');
Route::GET('/grading_master', 'ApiSettingsController#grading_master');
Route::POST('/grad_cat_active_inactive', 'ApiSettingsController#grad_cat_active_inactive');
Route::GET('/grading_master/view_lessons', 'ApiSettingsController#view_lessons');
Route::POST('/lesson_active_inactive', 'ApiSettingsController#lesson_active_inactive');
Route::GET('/driving_conditions', 'ApiSettingsController#grading_master');
//Manage Users Routes
Route::GET('/Manage_users/{user_type}', 'ApiManageUsersController#Manage_users');
Note: I am using Plesk to access my server.
Please help me out with this situation.
and here's a screenshot of 404 error which I get in postman,
Thanks in advance....

Laravel Project - After upload hosting server faced the issue for 500 Server Error and website menu link issue

I have faced the issue for website not working properly.[Project file uploaded in sub folder].
Folder Path : example.com->public_html->lrvproject
Please note the below issues:
Home Page - 500 Server Error. https://www.example.com/lrvproject/
Sub Pages open - I have manually enter page path it's showing page.
Example: https://www.example.com/lrvproject/contact
After loading subpages Menu link URL showing is "https://www.example.com/contact".
I have refer the tutorial inside public(folder copy all file and paste outside public folder).
index.php [https://www.example.com/lrvproject/index.php]
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
}
require __DIR__.'/../lrvproject/vendor/autoload.php';
$app = require_once __DIR__.'/../lrvproject/bootstrap/app.php';
$kernel = $app->make(Kernel::class);
$response = tap($kernel->handle(
$request = Request::capture()
))->send();
$kernel->terminate($request, $response);
web.php (routes)
use Illuminate\Support\Facades\Route;
//use App\Http\Controllers\UserAuthController;
Route::get('/','HomeController#index');
Route::get('/about', function () {
return view('pages/about');
});
Route::get('/gallery','ImageGalleryController#index');
Route::get('/contact','ContactController#index');
Route::post('/contact','ContactController#sendmail');
server.php [https://www.example.com/lrvproject/server.php]
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
//require_once __DIR__.'/index.php';
.htaccess [https://www.example.com/lrvproject/.htaccess]
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
# Disable Directory listing
Options -Indexes
# block files which needs to be hidden, specify .example extension of the file
<Files ~ "\.(env|json|config.js|md|gitignore|gitattributes|lock)$">
Order allow,deny
Deny from all
</Files>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Already Server Folder Permission enabled. PHP extensions enabled.
How to solve the issue. please help.
I have solved the issue. I have updated the below steps.
.env file database details updated, now my home page worked.
index.php [https://www.example.com/lrvproject/index.php] -Edit
require DIR.'/vendor/autoload.php';
$app = require_once DIR.'/bootstrap/app.php';
Web menu links URL-Edit
href="/lrvproject/contact" link path update "Contact US"
Clear Cache in Server
My Laravel Application Running in Server (Sub-folder directory)

Allow php files to be accessed in laravel public folder

I have a Laravel project that using Roxy Fileman as file manager. I put the files of Roxy Fileman under the public folder
/public/fileman
so I can access it by
<ifarame src="my.domain/fileman/index.html"></iframe>
the iframe will load data from PHP files in the plugin folder which located at
/public/fileman/php
It works well on my local XAMPP server but says E_LoadingAjax php/dirtree.php on my linux server, and returns 404 when I try directly access these files
I assume it is because PHP files are blocked from direct access for security reasons.
Then how can I allow this specific folder to be accessed? or what is a better approach to use Roxy Fileman in laravel?
.htaccess comes with Laravel:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Open up composer.json and find section with autoload, and add files array, see example below (I created folder folder inside public folder which contains file tst.php) so I have public/folder/tst.php
Now when I visit 1.1.1.1/folder/tst.php PHP interprets me the code.
.
.
.
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
},
"files": [
"public/folder/"
]
},
.
.
.

Codeigniter 404 page not found

I have been developing a Codeigniter website locally for with a WAMP server on Windows, everything working fine. I uploaded the files to a Ubuntu server to a virtual directory and configuration the URL and .htaccess. The rewrite rule works like it should but now I get 404 when I try to access the site or any other controller link. The logs state that it cannot find the controller, I checked the files to make sure they were uploaded correctly.
At this point and I at a loss, I have a hunch that it is a configuration issue with Apache but I have checked all the configs that I know. What would cause a 404 error?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
You have activated the module rewrite? If not, turn it on and restart wamp.
Also try to put index.php before the controller, may resolve the problem.
In CI 3.0, All Class names must have the first letter capitalized with the rest of the name lowercase.
Example: Where Model_name is the name of your class, this is how the class should be;
class User_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
}
Then, the model should be loaded like this in the controller;
$this->load->model('user_model');
Please refer to this link: http://www.codeigniter.com/userguide3/general/models.html

Htaccess mod rewrite don't work

I have a project with two applications: a frontend (in AngularJs) and a backend (in Phalcon). I my server document root i have two folders and one htaccess:
public_html
- api
- controllers
- index.php
- app
- .htaccess
The .htaccess have the next configuration:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/(.*)$ api/index.php?_url=/$1 [QSA,L]
</IfModule>
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
So, when i send a POST request (for example) to http://mydomain/api/sessions, the result is 404 not found. The router configuration is:
$router->addPost('/sessions', array(
'controller' => 'sessions',
'action' => 'post'
));
In my localhost works fine with this configuration. But, in my VPS not.
Any ideas ?
Update 1:
If i don't use any REST service, accessing via http://mydomain/api the Phalcon index controller is loaded.
Update 2:
If i try to access a REST service using a Phalcon url like http://mydomain/api/index.php?_url=/licenses works fine.
i found the problem. the virtual host configuration file had not the next lines:
<Directory "/var/www/domain/public_html">
Options All
AllowOverride All
Allow from all
</Directory>
You can sometimes get away with relative path substitutions in the document root, however, you should make the RewriteRule substitution root-relative (starts with a slash), or specify a RewriteBase / directive after you enable the rewrite engine in order to explicitly specify the URL prefix.
RewriteRule ^api/(.*)$ api/index.php?_url=/$1 [QSA,L]
Becomes:
RewriteRule ^api/(.*)$ /api/index.php?_url=/$1 [QSA,L]