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.
Related
I have a laravel application that I made changes to the folder structure, I have been working with laragon and everything works fine but on my local environment and live server.
However, when i user php artisan serve, the generated url doesn't load assets in the public folder.
E.g
https://livewebsite.com // [live server] works.
https://myproject.local // [laragon] works.
http://localhost/myproject // [laragon /xampp] works
http://127.0.0.1:8000 // artisan [doesn't load assets, assets in the public directory returns 404
//e.g http://127.0.0.1:8000/public/assets/themes/cryptic/style/bgs.css would return 404
Changes I made,
|-core
|-public
|-.htaccess
|-index.php
I have moved all laravel core folders and files to the core folder,
moved the .htaccess and index.php to the root directory.
From my debugging so far, I understand that laravel built in server redirects requests to the public folder where the index.php file is located.
What changes can I make so that the request is not sent to the public folder,
i.e http://127.0.0.1:8000/public/assets/themes/cryptic/style/bgs.css should just be allowed to be without be redirected.
The entire thing works on various environments except when I'm using laravel built-in PHP server with the artisan command.
EDIT
Folder structure
|-project
|-core
|-app
|-bootstrap
|-config
|-database
|-lang
|-etc
|-public
|-assets
|-test-folder
|-img.png
|-.htacess
|-index.php
in this setup, laravel base_path() is project/core . This where all laravel core files and folders are stored.
Now I have folder test-folder with an image img.png . If i go to http://localhost/project/new-folder/img.png it will return the image but if i go http://127.0.0.1:8000/new-folder/img.png will return 404. If i use a live server and go http://livewebsite.com/new-folder/img.png , it loads.
I can't comment due to reputation, but what you're doing might be unsafe!
This way all your project files will be public, which can expose credentials and exposes Composer packages to the public as well. This means any PHP file in any Composer package can be executed, which can lead to remote code execution, which has happened before here and is described here.
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 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 symfony2 project that somehow was running fine while it was outside the public_html directory, but now it's not working (the path is not allowed anymore, apparently).
Now I need to move the symfony2 directory into public_html, but when I do, the website is still not working (the page is blank).
I modified app.php so the include path is the correct one, and I also modified the projectConfiguration class so it has the right WebDir. What am I missing?
alternatively, how can I make it work outside the public_html directory?
for the record, I'm completely new to symfony.
The cache was the culprit.
I cleaned symfony's cache (removed all the contents residing in the cache folder) and the website came back to normal.
thanks to fos.alex for the comment/answer.
I need to setup Symfony on a shared host that runs on windows IIS. The domain directs to the root folder of the host. Which means no /public_html or /htdocs.
Is there any way to configure Symfony in a way that if I move the contents in "/web" to the root folder of my shared hosting account with the rest of the folders (app, config, tests etc...) , it would still work ?
Yes definitely you can do this.
Just do:
Open - lib\symfony\config\sfProjectConfiguration.class.php
Find - $this->setWebDir($rootDir.DIRECTORY_SEPARATOR.'web'); function
Modify - "web" folder by whatever path or directory you want
On linux, you can do symbolic links to a directory. The windows equivalent of a symlink to the root directory named web would solve your problem I guess...
Symfony on IIS
In the first case, the webserver is only used for our symfony project, and the URL is something like http://myproject/.
Assuming the directory in which you created the directory myapp is c:\myproject\, configure the root directory of your server to be c:\myproject\web (in IIS administration console).