Skip to content

Instantly share code, notes, and snippets.

@IlyaZha
Created December 20, 2016 09:49
Show Gist options
  • Save IlyaZha/2071aa3f721f4b11d016f886159ca274 to your computer and use it in GitHub Desktop.
Save IlyaZha/2071aa3f721f4b11d016f886159ca274 to your computer and use it in GitHub Desktop.
Create host for laravel-project for Ubuntu.
#!/bin/bash
#Create project folders first. Than run this script
parametr1=$1
projectPath=/home/userName/PhpstormProjects
cp /etc/nginx/example.conf /etc/nginx/conf.d/$parametr1.conf
rpl -iqR example $parametr1 /etc/nginx/conf.d/$parametr1.conf
sed -i -e '1 s/^/127.0.0.1 '$parametr1'.local\n/;' /etc/hosts
service nginx restart
chown www-data $projectPath/$parametr1/bootstrap/cache/
chown www-data $projectPath/$parametr1/storage/
server {
listen 80;
server_name example.local;
root "/home/userName/PhpstormProjects/example/public";
index index.html index.htm index.php;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mp4|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
root /home/zhernosekim/PhpstormProjects/example/public;
expires 31536000s;
try_files $uri @fallback;
}
charset utf-8;
location / {
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\. {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment