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.
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 set up laravel Nova locally last night, tested it, used it, everything works great on my local machine.
Uploaded it to the server, and everything works great except when i head to /nova which rightfully redirects me to /nova/login but then presents me with this error
The Mix manifest does not exist. (View: /home/loanappboi/nova/resources/views/auth/layout.blade.php)
i'm using shared hosting, and i uploaded the files to the root, and uploaded the public folder content, into public_html (i did the necessary file updates to reflect this change)
What could be the cause of this?
i need help
I got this same error. Running php artisan nova:publish fixed it for me. You need to have the nova resources generated.
mix() helper function use /public/manifest-json.js
Set it in config
mix.setPublicPath('public_html/')
OR
use link to public
ln -s ./public ./public_html
For Apache Options FollowSymLinks
Make sure that you are adding '/vendor' in your .gitignore and not 'vendor'. Adding just 'vendor' will ignore all folders named vendor in your codebase and nova resources are in the vendor folder in public folder.
I am migrating from shared web hosting to Heroku and can't figure out how to user Composer properly.
I have my app pointing to public_html folder, with the composer.json file in the root folder above this. This would generate a vendor folder in the root folder, which (for reasons I don't understand) I was unable to access when I tried including the autoload.php file in my code (e.g. require_once('../vendor/autoload.php')).
My solution to this was to move composer.json into public_html, but that caused no end of problems with Heroku not finding it, so I moved it back. I then changed the vendor directory in composer.json to point to public_html/vendor.
This had the desired effect, except now my app won't run because it can't find PHP, presumably something to do with the new location of vendor.
Is there a way to either:
Configure composer.json to have Heroku put everything except PHP in public_html/vendor, and put PHP into a root vendor directory, or
Access files above public_html from within my code to allow me to include autoload.php?
OK, it turns out it was a relatively simple fix that I just figured out myself. I'll post it here in case anybody else happens to make the same mistake.
If you change vendor-dir in composer.json, you also need to change the Procfile from
web: vendor/bin/heroku-php-apache2 public_html/
to
web: public_html/vendor/bin/heroku-php-apache2 public_html/
I created an app on my localhost using symfony 3. Stuff works perfectly well on my local host. Now my main problem is moving it to my shared hosting (cPanel). Moved the files to the public_html folder, then I moved the .exe, bin, src, var, etc folders to the parent folder (The folder containing the public_html folder) while leaving the 'web' folder in the public_html. I then moved everything from the 'web' folder (Which is inside the public_html folder) into the public_html folder. Making me have the following directory structure:
cpanel-root-directory<br>
---/app<br>
---/bin<br>
---/src<br>
---/tests<br>
---/var<br>
---/vendor<br>
---/public_html<br>
------/bundles<br>
------/css<br>
------/dist<br>
------/fonts<br>
------/img<br>
------/js<br>
------/plugins<br>
------/uploads<br>
------.htaccess<br>
------app.php<br>
------app_dev.php<br>
------apple-touch-icon.png<br>
------config.php<br>
------robots.txt<br>
<br>
When I go to the domain name, I keep getting this annoying HTTP 500 error. Then on both localhost and on the server (at different times), I created a fresh new symfony project, dumped it in the server and got the "Welcome to Symfony 3" page quite alright. But, when I tried putting my controller files, and going to the routes defined in them (I use annotations in the Sensio bundle to define routes), I get that HTTP 500 error. Then, in the default controller that works, I try defining a new action 'testAction'. When I go to the route for the test action, I still get the HTTP 500 error, but going to the '/' route, I see the symfony welcome page correctly.
My clients have seen that the stuff works perfectly well on my localhost, but now moving it to the server is the issue.
If you can (have access), just keep your web dir, and then make public_html a symlink to your web dir.
If you need to change the name of your "web" dir, you need to follow this instructions:
http://symfony.com/doc/current/configuration/override_dir_structure.html
You should check this paragraph from Symfony documentation
This part seems to describe exactly your problem:
Some shared hosts have a public_html web directory root. Renaming your web directory from web to public_html is one way to make your Symfony project work on your shared host. Another way is to deploy your application to a directory outside of your web root, delete your public_html directory, and then replace it with a symbolic link to the web in your project.
Eh, I think that's because, now, you are online, so you need to clear the cache for the prod environment:
$ php bin/console cache:clear --env=prod
But you say you are on a shared hosting, so unless you have some available tools to access the terminal (and run the above command), then you need to manually delete the var/cache/prod directory if present.
Or if this doesn't work, I usually, don't upload the var/cache + var/logs + var/sessions directories at all, but create them manually as empty ones, and then let Symfony do its job with them by default.
LE
Maybe you have another problem, and the one with the cache you've solve it already.
So, to check if there is something wrong with your app, enable the dev mode ( app_dev.php ), by modifying, locally, your public_html/app_dev.php file, and comment out these lines:
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(#$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
And then, copy this file over the one on the server, and then access a route with app_dev.php in front, and see if there is an error (eg):
http://www.domain.com/app_dev.php/existing_route
After you are done, don't forget to uncomment the code inside app_dev.php,and re-upload the file on the server.
I just installed laravel following the instruction on Larvel docs. I chose to use install via composer create project command.
In the routes. php i created a dummy route
Route::get('/', function(){
return 'Front Page';
});
When i access http://localhost/mysite/ It shows directory listing of mysite folder. However when i use http://localhost/mysite/server.php It runs my route closure.
I also tried alternate .htaccess code provided at Laravel's docs but that doesn't work either.
I want to remove the server.php from url.
Thanks in advance for help.
This behavior is expected and this is how Laravel works. The public folder is meant for assets and is also (supposed to be) the webservers root directory.
If you are working on localhost that is not the case and the root directory contains multiple projects.
In order to get rid of public you would have to change virtual host settings.
As mentioned here in the site.
The problem with doing virtual hosts is that other projects in localhost will become inaccessible.