{"id":26085280,"url":"https://github.com/codezero-be/laravel-cap-deploy","last_synced_at":"2026-03-11T02:02:03.432Z","repository":{"id":83382271,"uuid":"89755429","full_name":"codezero-be/laravel-cap-deploy","owner":"codezero-be","description":"Zero-downtime deployment script for Laravel apps, using Capistrano.","archived":false,"fork":false,"pushed_at":"2017-04-29T00:59:38.000Z","size":5,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-29T08:38:24.629Z","etag":null,"topics":["capistrano","deploy","deployment","laravel","zero-downtime"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codezero-be.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-04-29T00:59:19.000Z","updated_at":"2023-03-09T01:26:31.000Z","dependencies_parsed_at":"2023-03-05T07:45:35.530Z","dependency_job_id":null,"html_url":"https://github.com/codezero-be/laravel-cap-deploy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codezero-be/laravel-cap-deploy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Flaravel-cap-deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Flaravel-cap-deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Flaravel-cap-deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Flaravel-cap-deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codezero-be","download_url":"https://codeload.github.com/codezero-be/laravel-cap-deploy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Flaravel-cap-deploy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30367799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"online","status_checked_at":"2026-03-11T02:00:07.027Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capistrano","deploy","deployment","laravel","zero-downtime"],"created_at":"2025-03-09T05:58:13.344Z","updated_at":"2026-03-11T02:02:03.388Z","avatar_url":"https://github.com/codezero-be.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Capistrano Deploy Script for Laravel\n\n##### Zero-downtime deployment script for Laravel apps, using [Capistrano](http://capistranorb.com/).\n\nDisclaimer: I'm not a Capistrano guru and not a server admin. I do know enough to get around and the strategy below works for me. If you encounter problems, feel free to create an issue. I will do my best to help you out, but can't make any promises :)\n\n\u003e   If you want to learn more about servers or zero-downtime deployments, be sure to check out [ServersForHackers.com](https://serversforhackers.com).\n\n## Requirements\n\n- [Ruby](https://www.ruby-lang.org) 2.0 or newer (should be pre-installed on a Mac)\n- A server to deploy to\n- Some knowledge about servers and SSH\n\n## Installation\n\nThe script is based on version 3.4.0 of Capistrano. It might not work on older or newer versions that have breaking changes.\n\n```\ngem install capistrano -v 3.4.0\ngem install capistrano-composer\n```\n\nYou might need to use `sudo` if you get a permission error.\n\n## Server Access\n\nYour deploy user will need access to the webserver. Capistrano will use your Mac's `~/.ssh/config` file and use your SSH keys. Check out [these free tutorials](https://serversforhackers.com/series/ssh-usage-tips-and-tricks) to learn how to create and use an SSH key to login to a server. You should end up with something like this in your `~/.ssh/config` file:\n\n```\nHost your-server.com\n  HostName your-server.com\n  Port 22\n  User forge\n  IdentitiesOnly yes\n  IdentityFile ~/.ssh/id_rsa\n```\n\nIf you are using [Laravel Forge](https://forge.laravel.com/), your deploy user will likely be `forge` and the SSH port `22`.\n\nMake sure you can connect by running `ssh your-server.com` in the terminal.\n\n\u003e   Don't forget you need to store the public key on the server. See the [tutorials](https://serversforhackers.com/series/ssh-usage-tips-and-tricks) for more info.\n\n## Server Preparation\n\n#### Point your website to the correct directory\n\nConfigure your webserver so your website's `public` folder is within a `current` folder, for example:\n\n```\n/home/forge/your-website.com/current/public\n```\n\n#### Allow the deploy user to reload PHP without password\n\nTo reload PHP after a deployment, we need to allow the deploy user to do this without the need to enter the sudo password. To achieve this, SSH into your server and run:\n\n```\nsudo visudo\n```\n\nYou will be prompted for the sudo password.\n\nNext, search the text for:\n\n```\n# User privilege specification\nroot    ALL=(ALL:ALL) ALL\n```\n\nAnd add this below it: (make sure the username and reload command is valid for your server)\n\n```\nforge  ALL=(ALL:ALL) NOPASSWD:/usr/sbin/service php7.1-fpm reload\n```\n\n\u003e   If you want to know a bit more about these user privileges, refer to [this post on ServersForHackers.com](https://serversforhackers.com/video/sudo-and-sudoers-configuration).\n\n## Deployment Settings\n\nCopy the `Capfile` and `deploy` folder from this repo into the root folder of your Laravel app.\n\nIn the `deploy/stages` folder, you will find 2 example files: `production.rb` and `staging.rb`. Each represents a server to deploy your app to and holds specific deployment settings for that server.\n\nRunning `cap production deploy` would use the `production.rb` settings, and `cap staging deploy` would use the `staging.rb` settings. Just update `your-server`, `your-website` and `your-account` to your needs.\n\n```ruby\nserver 'your-server.com', roles: %w{web}\n\nset :application, 'your-website.com'\nset :repo_url, 'git@github.com:your-account/your-website.git'\nset :deploy_to, '/home/forge/your-website.com'\nset :keep_releases, 3\n\nset :laravel_artisan_flags, '--env=production'\nset :reload_command, 'sudo service php7.1-fpm reload'\n```\n\nAlso make sure the PHP reload command is valid for your server.\n\n## Before Your First Deploy\n\nFirst, add a `.env` file to your website's `current` folder on the server, already containing the required passwords. If important passwords are missing (like the database password), deployment will fail, because the database migration step will fail.\n\nNext, on your local machine, `cd` into the root folder of your project and run (for production):\n\n```\ncap production deploy:setup\n```\n\n**You need to do this once for every new website you set up.**\n\nThis will create a `releases` and `shared` folder, move your `.env` file into the `shared` folder and turn the `current` folder into a symlink to the latest `release` folder. Something like this (and a few more):\n\n```\n~/your-website.com/current -\u003e ./releases/1234/\n~/your-website.com/releases/1234/\n~/your-website.com/shared/.env\n~/your-website.com/shared/storage/\n```\n\nEverything in the `shared` folder will exist throughout deployments.\n\n## Deploy\n\nTo deploy your latest code to the server, push it up to GitHub or BitBucket and run:\n\n```\ncap production deploy\n```\n\nYou will be asked what branch you wish to deploy, just press `enter` to accept the default (`master`).\n\nThis will now:\n\n-   connect to your server\n-   fetch the latest changes from your (online!) git repo\n-   create a release folder\n-   run a production version of `composer install`, without the dev stuff\n-   run `php artisan optimize`\n-   migrate the database\n-   update the current symlink to the new release folder\n-   reload PHP-FPM\n-   clear the cache\n-   recache the routes and config\n-   restart the queue daemon (if any)\n\n## Rollback\n\nTo rollback to the previous release, run:\n\n```\ncap production deploy:rollback\n```\n\nThis will not rollback the database, as this might not be needed.\n\nIf you do want to rollback the database, run:\n\n```\ncap production db:rollback\n```\n\nJust be careful with that, especially in production :)\n\n## Other Commands\n\n##### Clear the cache\n\n```\ncap production cache:clear\n```\n\n##### Cache routes and config\n\n```\ncap production cache:routes\ncap production cache:config\n```\n\n##### Refresh the cache\n\n```\ncap production cache:refresh\n```\n\n##### Restart the queue daemon\n\n```\ncap production queue:restart\n```\n\n##### Reload PHP\n\n```\ncap production server:reload\n```\n\n##### Database\n\n```\ncap production db:migrate\ncap production db:rollback\ncap production db:refresh\ncap production db:reset\ncap production db:seed\n```\n\n##### Maintenance mode\n\n```\ncap production deploy:down\ncap production deploy:up\n```\n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n---\n[![Analytics](https://ga-beacon.appspot.com/UA-58876018-1/codezero-be/laravel-cap-deploy)](https://github.com/igrigorik/ga-beacon)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodezero-be%2Flaravel-cap-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodezero-be%2Flaravel-cap-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodezero-be%2Flaravel-cap-deploy/lists"}