I have tested my Laravel 5 project on localhost its working fine with this url - http://localhost/project-name/public/
Then I uploaded my project on shared hosting, I have made desirable changes for database on .env file then trying to access it with the url - http://companysite.com/folder/innerFolder/public/
but not working and getting 500 internal server error
I have gone through with other questions with the related but no answer lead me to my solution. I have done following steps
upload my project on root directory parallel to public_html
update to project/public/index.php
try to create subdomain pointing to my project but didn't succeed
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at
webmaster#techphant.techphant.com to inform them of the time this
error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error
log.
Additionally, a 500 Internal Server Error error was encountered while
trying to use an ErrorDocument to handle the request.
I have referred this link laravel.io
Finally, I did the job on my shared hosting. This is what I did
Setup a project Laravel 5 in localhost correctly configured
Double check the server configuration of PHP 5.4 (this because every
little change on .htaccess file may change that config)
Create a directory in the same level of public_html and put the
project inside of that folder.
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"... 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]
and update [framework-folder]/server.php
From this
require_once __DIR__.'/public/index.php';
To this
require_once __DIR__.'/public_html/index.php';
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
thanks to Neeraj Rathod, but I found this article more useful, and of course simple more!
WHY AM I GETTING A 500 INTERNAL SERVER ERROR MESSAGE?
in my case, by reading that article I found out from my "error pages" that the "group writable" permission must not be set for "index.php" file inside "public" folder and also for all folders through route. also you have to check that your shared hosting php version is more than 7.0
Everything Neeraj Rathod said, but also go to your project in vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php
In line number 1337, you can find the below code inside the addWhereExistsQuery method
$this->wheres[] = compact('type', 'operator', 'query', 'boolean');
you just remove the 'operator' parameter.
Thanks to this link:
compact(): Undefined variable: operator
now my laravel test project blog is online.
Related
Hello everyone i am new to laravel and i hope someone can help me about my problem. I created a laravel project. After that I import it to cpanel using softaculous. Then, I made some changes base on what i research in the net to avoid showing important file like .env . I created a folder relative to public_html, let say the folder name is 'tamangbilang' where i put almost all of my code except the index.php. Inside my public_html folder, I have another folder named as 'tamangbilang' where my index.php resides. I have followed this instruction https://dev.to/pushpak1300/deploying-laravel7-app-on-shared-hosting-hostinger-31cj the only difference is that I put another folder inside public_html.I also did some changes on the index.php code
require __DIR__.'/../../tamangbilang/vendor/autoload.php';
$app = require_once __DIR__.'/../../tamangbilang/bootstrap/app.php';
Everything is working fine on my login page(my first page) but when I try to login, an error occur.
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
It seems like the connection between routes was lost. I did further testing and I notice that the code is working well only if there is an index.php, before the route in the url. example
http://my-sample-domain.org/tamangbilang/index.php/login
P.S. I don't have access for ssh.
go to bootstrap folder & open cache folder then delete config. after that please check your routes this error basically arises due to routes not found for that go to your project installed on local and write php artisan route: list check if the route is present or not.
I made a laravel project on my localserver. I just copy the project folder and pasted on my web server in public_html folder. It's giving an error when i open it.
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Can anyone please let me know step by step how to put my laravel project on web serve?
Well there are three ways to upload and make workable on shared hosting which I came to know.
Rename server.php file to index.php (which is not the correct way)
Shift public/* to root (also, its not the correct way)
Need to add a line in public/index.php after initialization of $app
$app->bind('path.public', function() {
return _DIR_;
});
and that's proper way as per my knowledge.
(My last answer was deleted before I could submit my edits, so here's another, more complete answer)
There is an easy answer, and a long answer.
Long answer
The most important part to know is that the only part of Laravel that should be accessible to the public is in the public folder. Which means that, on your shared host, the content of public should reside in whatever folder is the public on your host (they usually are named "www", or "public_html", but it can be anything, really).
I'm going to assume here that you have only one project on your account and say that, if it's the case, you now only need to upload every other file and folder at the same level as the public folder you have and set the correct permission to the storage folder.
In the end, if the only thing you do is upload all of your project to the root folder of your account, then rename Laravel's public folder to public_html, this is supposed to work (of course, assuming that you can also use the CLI and call artisan and composer commands).
Easy answer
If you can use the command line and create synlinks on your host, you can simplify your life by uploading all of your project into a folder outside of the public_html folder and symlink public to your public_html like so: ln -s /full/path1/project/public /full/path/to/public_html
Detailed answer and more tips
You can read this article that goes into more detail and gives commands to achieve everything. I tried to keep my answer as concise as possible, so if you want a more step by step approach, this link or a bit of google searching will do the trick!
In my main domain I have created a sub domain where I have uploaded my files of ZF2 but it it not allowing me to access the home page.
If I type <submdomainname>.<domainname>.com it is saying that:
Forbidden:
You don't have permission to access / on this server.
Additionally:
a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Sounds indeed like a server configuration issue.
Try once to put a simle index.php in your folder and see if you can open it:
index.php:
<?php
echo("Hello world");
And add it to your public folder and try to browse to it:
http://www.example.com/public/index.php
If that doesn't work, then you know at least that it is not related to ZF2.
After you tried this you can come back with more details on your problem.
You should add reading permission to the folder where you host your subdomain.
I am trying to deploy my laravel application on a shared hosting. It should be deployed in www.subdomain.something.com
My folder structure is:
/laravel
app/
vendor/
bootstrap/
server.php
artisan
composer.json
composer.lock
phpunit.xml
/public_html
subdomain/
index.php
My index.php have the following paths:
require '/../../laravel/bootstrap/autoload.php';
$app = require_once '/../../laravel/bootstrap/start.php';
My paths.php
'app' => __DIR__.'/../../laravel/app',
'public' => __DIR__.'/../../public_html/subdomain',
'base' => __DIR__.'/../../laravel',
'storage' => __DIR__.'/../../laravel/app/storage',
Can anyone see what I am missing? I tried google, and found a bunch of step-by-step explanations but nothing seems to work - It results in a 500 internal server error.
Thanks for any feedback
Wesley
Follow the first rule here.
If you use the first rule then everything should work fine. But somehow if you face 500 Internal Server Error then login to ur server public_html directory through ssh and give the following command.
sudo chmod 755 -R laravel
chmod -R o+w laravel/storage
Here laravel is your Laravel project directory.
Make sure you have write permissions to app/storage/ and all the sub directories. This sounds like the culprit but if not then see if you get any errors in the app/storage/logs dir. If not see if you can parse the server logs.
I was having similar problem and found the solution.Maybe someone can get help with this,
Install LARAVEL 5 Locally Same as Share Hosting Directory (Deploy L5 Share Hosting Solution)
I tried to deploy my first Laravel 8 application on shared hosting on DreamHost, and did encounter some issues.
First I was not able to use composer. Composer 1 was available however, I was unable to upgrade it to Composer 2. ( Was getting errors)
Finally, I ended up uploading all files from my local system to the subdomain root folder (e.g. cota.mydomain.com)
When I tried cota.mydomain.com, I got 404 error.
When I changed url to cota.mydomain.com/public/index.php, the application started working. However, all href links which were defined like href="/home" or href="/client/create" started giving 'not found' errors. To fix this issue I had to use named routes in href, e.g. href=" {{ route('client.show',['id'=>$client->id]) }}". This solved the issue, however, the URL displayed included public/index.php, e.g. cota.mydomain.com/public/index.php/client/show/1.
To further fix the problem, I changed the web folder (root folder) for my subdomain to include public, i.e. cota.mydomain.com/public
Next I added an index.php in cota.mydomain.con with the following contents
header("Location: http://www.cota.mydomain.com/public/index.php"); die();
This fixed all issues, including remving public and index.php from link URLs.
I have a problem when upload laravel project on my shared hosting. On that hosting I have two addon domains with separate folders in document root. But when I put laravel project in document root and move everything from public folder in root to remove that "/public" from url, I cant access to my addon domains. I'm getting 500 Internal service error. When I remove .htaccess file I can access to my other domains, but I can't access to my Laravel project. How can I change default laravel .htaccess file?
Well, you should not move everything from public folder, this is a very important part of your Laravel application, it was built this way to separate your application source code from the public files anyone can access, if you make your application root also your public folder, anyone will be able to access any php files from your application, and this is so unsafe...
What you need to do is to point your document root to /serverRoot/applicationRoot/public.
If you really cannot do that, I'm afraid you'll have to edit index.php and try to change thos two lines:
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';
to
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/start.php';
And see if it works for you.
EDIT
Laravel's default .htaccess file is there just for rewriting your URLs, so you dont see aindex.php` on them. Basically it does 2 things:
1) If you access your site using http://www.site.com/, internally it will point to http://www.site.com/index.php.
2) When you access your site using http://www.site.com/index.php it hides the index.php part.
This is kind of recursive, because the first step leads to the second one.
Now you have to think and see how this is conflicting with your other domains, because the files you are serving in those domains matters and since we are not aware of what they are, helping more is kind of difficult.