Create projext nginx php
<?php
/*
* Template of virtual host
* {$argv[1]} : nome do projeto
* {$argv[2]} : diretorio do projeto
* @example sudo php create-project.php nome_projeto /var/diretorio/
* created by André Felipe (www.trezo.com.br)
*/
$template = "server {\n";
$template .= " listen 80;\n";
$template .= " server_name {$argv[1]};\n";
$template .= " root {$argv[2]};\n";
$template .= " index index.php;\n";
$template .= " server_name_in_redirect off;\n";
$template .= " port_in_redirect off;\n\n";
$template .= " access_log /var/log/nginx/{$argv[1]}.access.log;\n";
$template .= " error_log /var/log/nginx/{$argv[1]}.error.log notice;\n\n";
$template .= " location / {\n";
$template .= ' try_files $uri $uri/ /index.php?$args;' . "\n";
$template .= " proxy_read_timeout 900;\n";
$template .= " }\n\n";
$template .= " location ~ \.php$ {\n";
$template .= ' try_files $uri $uri/ /index.php?$args;' . "\n";
$template .= ' #try_files $uri =404;' . "\n";
$template .= " fastcgi_read_timeout 3000;\n";
$template .= " fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;\n";
$template .= " proxy_read_timeout 900;\n";
$template .= " fastcgi_index index.php;\n";
#$template .= " fastcgi_param APPLICATION_ENVIRONMENT dev;\n";
$template .= " fastcgi_param SCRIPT_FILENAME \$document_root/\$fastcgi_script_name;\n";
$template .= " fastcgi_param MAGE_RUN_CODE '';\n";
$template .= " fastcgi_param MAGE_IS_DEVELOPER_MODE 1;\n";
$template .= " fastcgi_param MAGE_RUN_TYPE store;\n";
$template .= " include /etc/nginx/fastcgi_params;\n";
$template .= " }\n";
$template .= "}\n";
echo $template;
$file = fopen("/etc/nginx/sites-available/{$argv[1]}.conf", 'x');
fwrite($file, $template);
fclose($file);
exec("ln -s /etc/nginx/sites-available/{$argv[1]}.conf /etc/nginx/sites-enabled/{$argv[1]}.conf");
$file = fopen("/etc/hosts", 'a+');
fwrite($file, "127.0.0.1 {$argv[1]}\n");
fclose($file);
exec('/etc/init.d/nginx restart');
echo 'Created with success the config for: ', $argv[1] . "\n" ;