I got started with Laravel 5.3 and I got my development environment working on local, but now I need to upload the app to production server. I cant found nothing about configuring two environments on same app.
I use Apache web server on both (local and production).
Any guide/doc is well received!
The docs (as pointed by Marcin) suggest to use the .env file to configure your environment. Different environments = different .env files. Thus, on local machine you'd have an .env file with your local enviroment configuration, and on production you'd have a different .env file, and a diffrent one for staging, and so on... APP_ENV=production
Which can be brought forth with App::environment()
Remember to exclude the .env from versioning, cheers.
Better to follow this blog:
https://devmarketer.io/learn/deploy-laravel-5-app-lemp-stack-ubuntu-nginx/
With that blog, if you're not using Nginx but Apache, that's fine because we are more concerned with the Laravel configuration and permissionings on files and folders than the web server.
Related
So I am setting up a laravel project on my existing Ubuntu Dev server. (So I won't need to run php artisan serve)
I managed to make it work by renaming server.php to index.php and copied the htaccess from public to project root.
However I am concerned if this might create a security issue? Is there a better way how to do this?
I believe This would also apply once the app is deployed to a live server.
Any feedback would be appreciated!
EDIT:
This is for development environment only as in my /var/www I have other projects not related to laravel and cannot change apache's virtual host to point to this laravel project. (Basically I need to run laravel in a subdirectory)
I have moved my laravel project from local to production server which is centos vps.
Strange thing I'm facing is laravel can't read from .env file, And I have tested everything to make it work but no success.
I have set it's permission to 777 and it's owner to the owner of vps.
still no success.
FYI : it is in gitignore but I have created .env file on server so this problem has nothing to do with gitignore.
Can someone walk me through step by step running laravel on production server?
Exactly what should be done and what commands do I need to execute, where should I put project and where should put public directory files ?
please help me out.
Maybe you could try to clear config cache:
php artisan config:clear
In production environments you should never have a .env file. Instead, create the appropriate environment variables and PHP will read them from there.
Taken from the official DotEnv docs:
phpdotenv is made for development environments, and generally should
not be used in production. In production, the actual environment
variables should be set so that there is no overhead of loading the
.env file on each request. This can be achieved via an automated
deployment process with tools like Vagrant, chef, or Puppet, or can be
set manually with cloud hosts like Pagodabox and Heroku.
Have you tried this-
Copied from the official Documentation
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.
I have a VPS on Godaddy with CentOs6 and I want to setup a testing environment for my project.
I got myself a free domain and set it up on my VPS with no problems. I uploaded my CakePHP Project to my testing environment with my new domain, so far so good.
The problems come when I realize that my testing environment which is running on the same server with a different domain and a different account is using my Production files. If a check my APP Global Variable it returns /home/production/public_html/app/ and it should return /home/testing/public_html/app/.
If I delete bootstrap.php I get an error that the file couldn't be found but if it is found the files that are used are the ones from my production environment.
I hope I've explained myself well.
Probably a caching problem. If you're using cakephp 2.x make sure that you clear the files in app/tmp.
My web application is up and running on production. But I lost my development sources due to laptop got formatted. Can I recreate my development environment from production environment?
I tried following steps but no success:
Installed Laravel 4.0 server.
Copied public html folder content.
ran composer
copied /app/config/ to /app/config/local/
modified /bootstrap/start.php to local host name.
But still when start my local server it is not able to map path of files correctly.
If your development and production server is same version then you should just change the url, database credentials etc.,
If the versions are different versions then you should place the views, controllers, then in the controller you should require all the stuffs that you need
I believe you should have same versions of laravel in production and development.
So, you should probably change only the db credentials.
Note : Clear the views and sessions in the storage after you change the credentials
Advice :
Please use SVN to avoid such happenings in future
I have some questions about development and deployment. I'll try to be clear:
Notes:
1- I'm using Codeigniter for my project. I have in my database.php config file set up two environments: development and production with two different settings, of course.
2- I have two domains in the same server, one is for development (dev.domain.com) and the other one for production (domain.com)
3- The SVN repository is on the same server and it is under a subdomain too (svn.domain.com)
4- Locally, Im using MAMP server and I have a virtual Host for testing. Also, I'm using Netbeans and Git for managing the repo (git-svn commands)
5- I read the other similar posts, but I think my project have some differences to take into account
Questions:
I want to make changes locally and then, using Phing, deploy the changes to the development environment. This environment is just for testing purposes, I want to keep my production environment running, but if I add some new features, I want to test them in a real environment (server) before add them to the production environment.
1- What happens with the config files? If I deploy the development environment, the database config should change aswell. I can do this with Phing, but then I'll have changes on my working tree and I'll need to commit it first and change them again when working locally.
2- Should I work with branches for every release to production? I can do a git svn rebase on the development environment, but what happens with the production one?
I have kind of mess on my head about all of this. Can you clear my mind a little bit, please?
Thanks in advance.
Just use 2 separate branches for DEV and PROD (or trunk+branch) with different configs and different deploy targets for Phing (per "branches")
Merge tested changes from DEV to PROD after debug, tag merged (and working) revisions in PROD tree without additional branching
PS - using both Git and SVN seems as excess solution for me