Skip to content

Instantly share code, notes, and snippets.

@s4l1h
Created December 20, 2012 16:14
Show Gist options
  • Select an option

  • Save s4l1h/4346278 to your computer and use it in GitHub Desktop.

Select an option

Save s4l1h/4346278 to your computer and use it in GitHub Desktop.
nginx için virtual host oluşturmaya yarar.
<?php
/*
Template sistemi entegre edilebilinir.
Kullanımı:
php make.php site.com
*/
$domain=trim($argv['1']);
$template='server {
server_name www.domain.com domain.com;
access_log off;
error_log /var/www/www.domain.com/logs/error.log;
root /var/www/www.domain.com/public_html;
location ~* \.(ico|css|js|gif|jpe?g|png)$ {
expires max;
}
location / {
index index.php;
}
#rewrite ^/cached/js/(.*)\.js$ /js.php?cachefile=$1 last;
#rewrite ^/cached/css/(.*)\.css$ /css.php?cachefile=$1 last;
#if (!-e $request_filename)
#{
# rewrite ^/(.*)$ /index.php?/$1 last;
# break;
#}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_read_timeout 1200;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/www.domain.com/public_html$fastcgi_script_name;
}
}';
$data=str_replace('domain.com',$domain,$template);
file_put_contents('/etc/nginx/sites-available/www.'.$domain,$data);
$komuts[]="mkdir -p /var/www/www.".$domain."/public_html/";
$komuts[]="mkdir -p /var/www/www.".$domain."/logs/";
$komuts[]="touch /var/www/www.".$domain."/logs/error.log";
$komuts[]="ln -s /etc/nginx/sites-available/www.".$domain." /etc/nginx/sites-enabled/www.".$domain;
foreach($komuts AS $komut){
echo $komut."\n";
passthru($komut);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment