Skip to content

Instantly share code, notes, and snippets.

@sfelix-martins
Last active February 26, 2018 13:23
Show Gist options
  • Save sfelix-martins/3dc3b6dec4fdc8f406c979094638f92e to your computer and use it in GitHub Desktop.
Save sfelix-martins/3dc3b6dec4fdc8f406c979094638f92e to your computer and use it in GitHub Desktop.
Envoy script to create virtual host configuration in your server with nginx. The structure `/srv/site.com/www` is used.

Configure nginx server

On folder that your Envoy.blade.php script is saved run:

$ envoy run up --site=example.com

Observations:

  • You need to have ssh access on server
  • To run this script you need to install before the Envoy installed
  • After success to create your site structure maybe you just set the necessary permissions to your site folder
@servers(['server' => '[email protected]']) {{-- Your server ip address --}}
@task('up', ['on' => 'server'])
cd /etc/nginx/sites-available
echo -e "server {
\t listen 80;
\t listen [::]:80;
\t root /srv/{{ $site }}/www;
\t index index.html index.htm;
\t server_name {{ $site }} www.{{ $site }};
\t location / {
\t\t try_files \$uri \$uri/ =404;
\t }
}" > {{ $site }}
nginx -t
ln -s /etc/nginx/sites-available/{{ $site }} /etc/nginx/sites-enabled/{{ $site }}
mkdir -p /srv/{{ $site }}/www
systemctl restart nginx.service
@endtask
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment