A basic and simplistic way of generating development, staging and live environments on one nginx server configuration.
These instructions will get you a copy of the automated deployment project up and running on your Linux machine.
What things you need to install the software and how to install them
-- nginx 1.14.0 or above --
$ sudo apt update
$ sudo apt install nginx -y
This project follows the file structure of:
├┬ /var/sites/
│ └┬ development
│ ├ staging
│ └ live
│
└┬ /etc/sites/
└┬ development/
├ staging/
└ live/
If you haven't already got the file structure as listed above, please create the missing directories.
sudo nano /etc/nginx/nginx.conf
Within http {...}, underneath the title of "Virtual Host Configs" add:
include /etc/sites/*/*;
Clone this repository, and then copy the contents of the created directory (AutoSiteDeploy
) to /var/sites
:
# Clone repository
cd /path/to
git clone https://github.com/reecebenson/AutoSiteDeploy.git
# Move contents
mv /path/to/AutoSiteDeploy/* /var/sites
# If the . files do not move, use the below commands
mv /path/to/AutoSiteDeploy/.deploy/ /var/sites
mv /path/to/AutoSiteDeploy/.git/ /var/sites
mv /path/to/AutoSiteDeploy/.gitignore /var/sites
Please ensure that the Nginx configuration matches your requirements, feel free to edit the default .deploy/nginxsite
file to your liking but maintain the practices for:
server {
...
server_name SITEURL www.SITEURL;
root /var/sites/SITETYPE/SITENAME/public;
...
error_log /var/sites/SITETYPE/SITENAME/logs/error.log;
access_log /var/sites/SITETYPE/SITENAME/logs/access.log;
...
}
The nginx configuration is set to be connected to PHP 7.2's FPM socket, you can configure that in the above file.
server {
...
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
...
}
This creates the following directories & files:
/var/sites/{ development, staging, live }/{ logs, public }/
/etc/sites/{ development, staging, live}/{ dev, stg, live }.{ sitename }
$ ./deploy.sh
Please enter the site name:
> example
Please enter the site URL:
> example.com
This cleans up files within:
/var/sites/{ development, staging, live }
/etc/sites/{ development, staging, live}/{ dev, stg, live }.{ sitename }
$ ./remove.sh
Please enter the site name:
> example
- Reece Benson - @reecebenson
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details