From 1243a39bab1dbb121b1b63a2023bfdf3e6fdd0ba Mon Sep 17 00:00:00 2001 From: Guobao Jiang Date: Thu, 13 Feb 2014 11:27:03 +0800 Subject: [PATCH] add nginx.conf --- nginx/nginx.conf | 142 +++++++++++++++++++++++++++++++++++++++++ vagrant/install.sh | 35 ++++++++++ vagrant/postinstall.sh | 18 ++---- 3 files changed, 184 insertions(+), 11 deletions(-) create mode 100644 nginx/nginx.conf create mode 100755 vagrant/install.sh diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..c030248 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,142 @@ + +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +#pid logs/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + #gzip on; + + server { + listen 8080; + server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + + location / { + root html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # ref http://askubuntu.com/questions/134666/what-is-the-easiest-way-to-enable-php-on-nginx + # start php5 sudo service php5-fpm restart + location ~ \.php$ { + root html; + # fastcgi_pass 127.0.0.1:9000; # ubuntu old + fastcgi_pass unix:/var/run/php5-fpm.sock; # ubuntu 12.10 or newer + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + + } + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} + + # 服务器状态信息监控,需要编译时开启--with-http_stub_status_module模块 + location /status { + stub_status on; + access_log off; +# allow 10.0.0.0/24; +# deny all; + } + } + + server + { + listen 8088; + server_name localhost; + location / { + stub_status on; + access_log off; + } + } + + # another virtual host using mix of IP-, name-, and port-based configuration + # + #server { + # listen 8000; + # listen somename:8080; + # server_name somename alias another.alias; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + + + # HTTPS server + # + #server { + # listen 443; + # server_name localhost; + + # ssl on; + # ssl_certificate cert.pem; + # ssl_certificate_key cert.key; + + # ssl_session_timeout 5m; + + # ssl_protocols SSLv2 SSLv3 TLSv1; + # ssl_ciphers HIGH:!aNULL:!MD5; + # ssl_prefer_server_ciphers on; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + +} diff --git a/vagrant/install.sh b/vagrant/install.sh new file mode 100755 index 0000000..cc23ba0 --- /dev/null +++ b/vagrant/install.sh @@ -0,0 +1,35 @@ +#!/bin/bash +############################################################### +## NAME +## install.sh install nginx in server +## +## USAGE +## ./install.sh +############################################################### + + +## following is recommanded configure and modules. +iUser="`whoami`" + +make clean + +./configure \ + --prefix=/home/${iUser}/nginx \ + --sbin-path=/home/${iUser}/nginx/sbin/nginx \ + --conf-path=/home/${iUser}/nginx/conf/nginx.conf \ + --pid-path=/home/${iUser}/nginx/pid/nginx.pid \ + --error-log-path=/home/${iUser}/nginx/log/error.log \ + --http-log-path=/home/${iUser}/nginx/log/access.log \ + --user=${iUser} --group=${iUser} \ + --with-http_ssl_module \ + --with-http_stub_status_module \ + --with-pcre=/home/${iUser}/sw/pcre-8.34 \ + --with-zlib=/home/${iUser}/sw/zlib-1.2.8 \ + --with-openssl=/home/${iUser}/sw/openssl-1.0.1c + +## compile nginx form source code +make + +## install nginx +make install + diff --git a/vagrant/postinstall.sh b/vagrant/postinstall.sh index 272a5e0..b465688 100755 --- a/vagrant/postinstall.sh +++ b/vagrant/postinstall.sh @@ -1,14 +1,15 @@ #!/bin/bash ################################################################ # NAME -# postinstall.sh post install some sw and configure after -# vagrant virtual machine installed for ubuntu +# postinstall.sh post install some sw in +# vagrant virtual machine # NOTE # the base box is ubuntu 12.04 lts, which is download from # http://files.vagrantup.com/precise32.box ################################################################ +echo +echo "-----------------------------------" echo "postinstall start." - VAGRANTPATH="/vagrant_data" # change source list @@ -17,16 +18,11 @@ cp ${VAGRANTPATH}/sources.list /etc/apt/ sudo apt-get update echo -echo "-----------------------------------" echo "install some necessary software." sudo apt-get install -y \ emacs zsh vim g++ build-essential \ make git ghostscript -iUser="`whoami`" -echo "now user: ${iUser}" -if [ ${iUser} = "root" ];then - su vagrant - echo "changed user, now: `whoami`" -fi - +echo "postinstall finished." +echo "-----------------------------------" +echo \ No newline at end of file