I'm trying to copy an existing Symfony project to another directory, so I can test changes before applying them to the live version.
I get a 404 error whenever I try to access the project on the copy via app.php or app_dev.php, and I can't pin down why. The live project is in a folder called representation/mvcrep and the copy is in a folder called representation_dev/mvcrep, and they are both on the same hierarchy in the directory tree.
I've already successfully cleared the cache for both the dev and prod environments in the copy, with no decipherable result. There are no errors in the Symfony logs, and the 404 is one for the site not for Symfony, so I'm assuming it's a problem with the server. Both projects have the exact same permissions as well.
Anyone have any clue to what the problem could be?
Edit: To clarify, the web directory has not been renamed or modified.
As you reported that you use two subfolders in the same virtual host, the web server configuration is probably not the issue here.
Since I suspect permissions issues, I suggest you to debug by creating a base text file in the /representation_dev/mvcrep/web folder, e.g. hello.txt, and see if you can get that via browser.
If not, check the permissions on the newly created folder.
There is not enough info for a precise answer, but this sounds definitely more like a server configuration issue than a Symfony issue,
If you make a copy of your Symfony folder, you also need to create a new web site that points to the new installation.
I.e. previously you browsed the site
http://representation.local/
which has its web root in
.../representation/mvcrep/web
Now you need to create a new site
http://representation_dev.local/
which has its web root in
.../representation_dev/mvcrep/web
Related
I've recently taken over a project from another developer, let's call it EBAY. I'm struggling to get their live site up and running on my local server for testing and debugging. They've built a web app using CodeIgniter. In their file manager on cPanel they've placed the ci folder at the root, not in the public_html folder.
I've copied their public_html files and their ci folder into my xampp's htdocs folder. The issue is that the site only loads when the ci folder is placed WITHIN the folder for EBAY. Oherwise when I load the localhost site it gives an error message that it cannot find the codeigniter folder inside EBAY folder.
How is this? How can the application run with the ci folder at the root on the live site, but when I have migrated it to the htdocs of xampp it is expecting the ci folder to be inside the EBAY folder?
This kind of configuration is quite common nowadays, and if you look at Linux or Pear you'll discover that PHP files sometimes are completely in other directories than the webserver.
The ideas behind this are pretty simple but effective:
Any files can't be reached from the network / internet.
So they can't be altered, downloaded or even just viewed.
PHP (or other) Libraries are clearly separated from individual code and can't be easily mixed up or accidentally be deleted.
Access rights are easier to control and perhaps even that differently than the files in the webfolder.
Ok, so far an explanation. Now about your issue with it:
You've currently a webfolder htdocs in Xampp and in general you can use a subfolder as the webfolder and in htdocs directly you place the project files that are not public. You've to adjust then where the domain is pointing (docroot and/or virtual hosts).
I developed application in laravel 5.2. I was using the Virtual host on local and pointing publice/index.php easily.
But on production why we need to using the put index.php & all stuff out of public folder. Is this best practice to deploy on production?
I copied whole in project folder and public folder stuff copied on the root(public_html) of server.
I changed the index.php accordingly and its working fine.
require __DIR__.'/project/bootstrap/autoload.php';
$app = require_once __DIR__.'/project/bootstrap/app.php';
Issue is When i use auto deployment tool, It pushes whole code in project folder. Every time I move assets by ssh from project/public/assets to root/assets manually.
Main Issue
I am also facing issue, saving profile picture in assets folder. But it save picture in project/public/asset instead it should in root/assets. I am really confused on this issue too.
Advise me
Please recommend me the best practice, where should i keep public folder stuff and how to manage auto deployment.
Can we keep index.php inside public and point directly index.php here. In this way auto deployment work fine.
Issue in after deployment commands
I am using DeployHQ.com to deploy my code. It execute ssh commands, but unfortunatly my command doesn't work because artisan file is inside of root/abc/project folder. I dont know where this shell execute commands. or How to point project folder directly to execute these commands.
Bitbucket webhook return 422 error code
I am using bitbucket webhook on approve event. I have given it deployment url and auto deployment is switched on. Hook triggerred as well, but it didn't deploy any thing, It shows error code 422 and error "Could not decode the deployement".
The index.php file should be in the public folder. Everything else should not. Your web server should be configured to point to this directory.
The index.php file bootstraps the Laravel framework. The framework files should sit in a directory outside of the publicly accessible folder. This is usually in the directory above the public/ folder.
You shouldn't work around your deployment tool. It should be configured to maintain this directory structure. Once there is no confusion as to where files should be pushed, you can begin to solve your other path related deployment problems. To avoid future pain, I'd recommend setting up your dev environment as close to production as possible.
A year ago, I decided to go with codeigniter instead of laravel, because codeigniter prooved to be easier to setup. I am now preparing for my next project and it seems as if codeigniter is now obsolete (at least most of the people seem to recommend laravel over codeigniter).
Now to my problem: I use a virtual ubuntu machine for developing web apps so I have a dev environment similar to the production environment (this helps me to avoid some problems (especially case-sensitivity...;)))
I installed composer and laravel and created a new laravel project named "quickstart" in /var/www/quickstart. I then followed their "getting started guide" (here: Guide). So far everything worked.
But here come the problems:
I have two other web applications in /var/www, so when I enter the ip of the machine I see the 3 directories.
Issue 1:
Normaly I'd expect that as soon as if I click on the "quickstart"-Directory in my browser, the webapp would get displayed, but I have to click a second time on "public", and then the webapp is displayed.
Issue 2: Of course, the links on the page are wrong too, because they reeer to (for example) "/task", which can't be found on the server.
The problem is that I'm not really experienced with apache configuration. I suspect it has something to do with VirtualHosts, but AFAIK you need to have root access to configure virtual hosts, and I do not have root rights on the dev environment.
Could you point out a way to me how I can make laravel work in a subdirectory in a way that I can just move the files and folders to my hoster as soon as I have finished the project? I'd like to then change only one file, and not all paths and URLs in all files ;)
Regards,
Christian
Thanks to Bogdan, I was able to figure it out. My hoster allows symlinks, so I did it like so:
I put the laravel installation in
/srv/web/quickstart
(quickstart is the name of the project). I then created the following symlink:
ln -s /srv/web/quickstart/public /srv/web/www/public
The document root of the apache is configured to
/srv/web/www/public
After that I just got a blank page. That was because I forgot to set the correct permissions on the storage-folder. So I set the following permissions
chmod -R 777 /srv/web/quickstart/storage
This is fine for a development environment. For production I'd recommend to only allow the webserver-user to write into that directory.
And voilĂ : Everything works!
Thank you for your help bogdan.
Christian
I want to deploy a Laravel 5 project to shared hosting from my localhost but I am facing so many problems. I have uploaded all files in a subfolder of my shared hosting (PHP 5.5) and when I try http://domain.com/subfolder/public its showing me 500 error. I check the laravel.log but found nothing, set the storage/ to 777 but still no changed (showing last error from localhost).
I also check .htaccess and it seems good. I search a lot and try so many thing but still facing same problem.
Now, my shared hosting give access of SSH so I have installed a new Laravel project. Then copy my edited and added file except vendor from my localhost to Hosting. Then I update the composer and dump-autoload, Now my application is working file.
But I am not sure about the process I did. Is it the right way (I don't think so)? Please let me know what was the problem of directly uploaded file and is there any problem if I use second system for my production app.
There are chances that your route cache is messed up. It is safe to artisan route:clear, artisan cache:clear, and artisan view:clear before uploading your files to ensure that no compiled script left - which usually tied to specific path.
But it is unclear, could you share your stacktrace for your error (and if possible share where your .htaccess file and it's content)?
sorry i can't comment, need higher point. However, by looking at your statement that it works by moving your files (controller, views, public, etc) but not the entire project, i believe clearing caches is the best to try.
As for the deployment of laravel project, there are methods suggested in laravel.io. It is not a good idea to expose your entire laravel files in public folder. Nevertheless, there are many ways to deploy it.
I know it's a little late but you need to either:
1. Make laravel's public folder the root folder of your domain or
2. Make a sub-domain and point the root folder to your projects public folder. The disadvantage with this is that your sessions cannot be connected directly to your main domain's sessions.
I am having xampp.
I installed laravel using composer, and there is directory 'laravel-test'
When I go to
http://[localhost]/laravel-test/
then I just see folders.
But when I go to some other - like http://[localhost]/darzelis/ which is written on codeigniter, it works. So it means xammp is working, but somehow laravel does not start.
I am going though http://laravel.com/docs/quick
and am stuck after creating first route - users.
Mate, firstly Laravel's entry point is the /public/ directory. It contains the index.php file, try pointing your browser to http://[localhost]/laravel-test/public to check if things work.
Seeing the folders is also dependable on you server configuration, it's good to block that Apache behaviour.
Last but not least, deploying laravel in production environment , make sure that the users can access ONLY the public directory not the whole structure of your laravel folder (in your case laravel-test), which again is dependable on the Apache configuration (vhost doc root).