Skip to content

Instantly share code, notes, and snippets.

@sfelix-martins
Created February 26, 2018 15:40
Show Gist options
  • Save sfelix-martins/b627c355ee2871ae2e9ce194e99df88b to your computer and use it in GitHub Desktop.
Save sfelix-martins/b627c355ee2871ae2e9ce194e99df88b to your computer and use it in GitHub Desktop.
Envoy script to create virtual host to up Laravel applications configuration in your server with nginx. The structure `/srv/site.com/www` is used.

Configure nginx server to Laravel

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

$ envoy run up --site=api.example.com

Observations:

  • On line 22 of Envoy.blade.php file you should set the path to file of your php version
  • 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/public;
\t index index.php index.html index.htm;
\t server_name {{ $site }} www.{{ $site }};
\t location / {
\t\t try_files \$uri \$uri/ /index.php?\$query_string;
\t }
\t location ~ \.php$ {
\t\t include snippets/fastcgi-php.conf;
\t\t fastcgi_pass unix:/run/php/php7.2-fpm.sock;
\t }
\t location ~ /\.ht {
\t\t deny all;
\t }
\t location ~ /.well-known {
\t\t allow all;
\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