{"id":14984531,"url":"https://github.com/melihovv/initial-webserver-setup","last_synced_at":"2025-04-10T21:20:25.222Z","repository":{"id":48608394,"uuid":"98108492","full_name":"melihovv/initial-webserver-setup","owner":"melihovv","description":"Ansible playbook for initial ubuntu 16.04 webserver setup and Laravel zero time deployment","archived":false,"fork":false,"pushed_at":"2021-07-18T10:48:10.000Z","size":97,"stargazers_count":59,"open_issues_count":0,"forks_count":26,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-24T18:49:36.171Z","etag":null,"topics":["ansible","ansible-playbook","ansible-roles","ansible-vault","laravel","playbook","webserver"],"latest_commit_sha":null,"homepage":"https://medium.com/@melihovv/zero-time-deploy-of-laravel-project-with-ansible-3235816676bb","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/melihovv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-23T15:48:56.000Z","updated_at":"2024-10-23T01:18:09.000Z","dependencies_parsed_at":"2022-09-05T18:50:17.431Z","dependency_job_id":null,"html_url":"https://github.com/melihovv/initial-webserver-setup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melihovv%2Finitial-webserver-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melihovv%2Finitial-webserver-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melihovv%2Finitial-webserver-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melihovv%2Finitial-webserver-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/melihovv","download_url":"https://codeload.github.com/melihovv/initial-webserver-setup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248298782,"owners_count":21080400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ansible","ansible-playbook","ansible-roles","ansible-vault","laravel","playbook","webserver"],"created_at":"2024-09-24T14:09:13.434Z","updated_at":"2025-04-10T21:20:25.197Z","avatar_url":"https://github.com/melihovv.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Initial Ubuntu 16.04 Web Server Setup\n\nAnsible playbook to setup web server and playbook to deploy laravel project with\nzero time.\n\n## What initial-setup.yml playbook does\n\n- install python2 and aptitude\n- upgrade all software\n- create user with sudo rights\n- configure sshd: disables root login and password authentication, also allows \nto login only user created on previous step\n\n## What setup.yml playbook does\n\n- install\n  - git\n  - ntp\n  - vim\n  - tmux\n  - htop\n  - curl\n  - unzip\n- configure automatic security updates (do not reloads server, only installs updates)\n- setup timezone\n- configure iptables and fail2ban\n- create swap file\n- setup ssl certificate with letsencrypt\n- install node.js, npm and yarn\n- install nginx\n- install php and composer\n- install mysql\n- creates following folders structure for zero time deployment:\n  - `/path/to/domain`\n    - `current` -\u003e `/link/to/latest/release`\n    - `persistent`\n      - `storage`\n    - `releases`\n      - `2017-08-10-10-00-00`\n      - `2017-08-11-10-00-00`\n      - `2017-08-12-10-00-00`\n\n## What deploy.yml playbook does\n\n- clone repository\n- set correct permissions\n- link `/path/to/release/storage` to `/path/to/domain/persistent/storage`\n- install composer dependencies\n- link `/path/to/release/.env` to `/path/to/domain/persistent/.env`\n- install npm dependencies and generate assets\n- optimize laravel application\n- backup database\n- run new migrations\n- link `/path/to/domain/current` to `/path/to/domain/releases/new-release`\n- delete all, but 10 latest releases\n\nIf build fails\n\n- rollback migrations\n- remove new release folder\n- link `/path/to/domain/current` to `/path/to/domain/releases/last-success-release`\n\n## Install\n\n### Inventory file\n\nCreate `inventory` file in project root. You should specify ip address of your\nserver in this file.\n\n```\n[web]\n46.101.210.137\n```\n\n### Install dependencies\n\n```bash\nansible-galaxy install -r requirements.yml\n```\n\n### Environment variables\n\nCopy `vars/main.yml.example` to `vars/main.yml` and change variable values for\nyour needs. For security reasons you may want to encrypt this file using\nansible-vault:\n```bash\nansible-vault encrypt vars/main.yml\n```\nAnd then edit this file\nwith\n```bash\nansible-vault edit vars/main.yml\n```\n\nTo see all available variables take a look at `roles/*/defaults/main.yml`. Also\nvisit external roles github page for additional documentation.\n\nTo generate password for your user use\n\n```bash\nsudo apt-get install -y whois\nmkpasswd --method=SHA-512\n```\n\n### Nginx and php-fpm configs\n\n- Site config for nginx place in `roles/nginx/templates/yoursite.j2`\n- Php-fpm pool config place in `roles/php/templates/yoursite.conf.j2`\n- Default configs are available in this\n[gist](https://gist.github.com/melihovv/ff11a76ee8b4fba28ecb4b681cb91818)\n\n### Initial setup\n\nBy default on ubuntu 16.04 there is no python 2 and aptitude. Without those\nprograms ansible cannot work. To fix it run:\n\n```bash\nansible-playbook initial-setup.yml\n```\n\nBeside it this playbook also creates user and configures ssh server.\n\n### Provision server\n\nThis playbook setup nginx, php-fpm, mysql, nodejs, etc.\n\n```bash\nansible-playbook setup.yml\n```\n\n### To run only specific roles\n\n```bash\nansible-playbook setup.yml --tags=user,nginx\n```\n\n### To exclude specific roles\n\n```bash\nansible-playbook setup.yml --skip-tags=user,nginx\n```\n\n### Deploy\n\n```bash\nansible-playbook deploy.yml\n```\n\n## Security\n\nIf you discover any security related issues, please email amelihovv@ya.ru instead of using the issue tracker.\n\n## Credits\n\n- [Alexander Melihov](https://github.com/melihovv)\n- [All contributors](https://github.com/melihovv/initial-webserver-setup/graphs/contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelihovv%2Finitial-webserver-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmelihovv%2Finitial-webserver-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelihovv%2Finitial-webserver-setup/lists"}