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.
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).
More and more projects are starting to pile up and I want some workflow and also version control over the different projects. I'm trying to set the "right" workflow with Xampp, Git, GitDesktop and PhpStorm on a Windows 2012r2 machine.
Xampp base: d:\xampp
http://localhost = d:\xampp\htdocs
Dev repositories: d:\xampp\htdocs\repositories\dev\GitDemo
Live repositories: d:\xampp\htdocs\repositories\live\GitDemo
Live folder: d:\xampp\htdocs\GitDemo
Live URL: http://servername/GitDemo (intranet use only)
Right now I have my repositories folder inside the htdocs folder, otherwise I would need another alias/copy action to be able to see what I'm developing. But at the same time the repositories folder is exposed. How to hide this? htaccess?
I've ran git init --bare inside the live folder for this project. With GitDesktop I've created the repository for GitDemo inside d:\xampp\htdocs\repositories\dev.
Using PhpStorm I've created a project based upon local files and pointed it towards d:\xampp\htdocs\repositories\dev\GitDemo. I'm able to see the changes made using git status, add them using git add . and commit them succesfully with git commit -m "my commit..".
I've created a remote server git remote add live master and created a post-receive to checkout the files inside d:\xampp\htdocs\repositories\live\GitDemo to d:\xampp\htdocs\GitDemo.
This all feels like a "ton" of work to set up initially and somewhat redundant (having the same files in 3 locations).
Is this the ideal way to set this up, or do you suggest an alternative approach? Thanks for sharing your thoughts!
I've been thinking about the most logical solution (to my opinion at this moment). Here's how I solved my unclear items as described:
I've optimized it by:
Bringing the repositories directory outside htdocs to d:\repositories\dev\ and d:\repositories\live.
I've set up a symlink to http://localhost/dev/GitDemo that links to
d:\repositories\dev\GitDemo. In this way I don't need to place the
repositories folder inside the htdocs folder and still benefit from
Apache being able to serve the content, which actually resides outside the htdocs folder.
The live version is now placed at http://localhost/GitDemo and with a post-receive hook it gets deployed from d:\repositories\live\GitDemo.git to d:\xampp\htdocs\GitDemo.
If you think I made a mistake or have mistaken something from the way it's supposed to be, please correct me as I'm still not sure this is the correct way but at least it seems like it to me.
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
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'm not sure if I'm missing the point here...
Our devs want the following...
On a LAMP server with SVN/WebDAV they want the root Apache directory to be a repository that they can all work on. However, setting the default Apache directory to a repo doesn't work as the files aren't stored as html/php files, instead in the SVN db structure to handle changes/revisions/etc.
Is there any way to do this? or would we have to have a separate repo that they copy files to/from the web root when developing?
You have to setup a separate svn repository and Hook Scripts. This hook scripts can checkout the code on every code change to your apache root. This is quite common an also used for automatic testing etc.