nginx安装配置
nginx安装
//安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel //安装 PCRE 让 Nginx 支持 Rewrite 功能 wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz tar zxvf pcre-8.35.tar.gz cd pcre-8.35 ./configure make && make install pcre-config --version //安装 Nginx wget http://nginx.org/download/nginx-1.6.2.tar.gz tar zxvf nginx-1.6.2.tar.gz cd nginx-1.6.2 ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35 make && make install /usr/local/webserver/nginx/sbin/nginx -v //创建 Nginx 运行使用的用户 www: /usr/sbin/groupadd www /usr/sbin/useradd -g www www //启动 /usr/local/webserver/nginx/sbin/nginx -t # 检查配置文件nginx.conf的正确性 /usr/local/webserver/nginx/sbin/nginx # 启动 /usr/local/webserver/nginx/sbin/nginx -s reload # 重新载入配置文件 /usr/local/webserver/nginx/sbin/nginx -s reopen # 重启 Nginx /usr/local/webserver/nginx/sbin/nginx -s stop # 停止 Nginx
nginx虚拟域名配置文件
server { listen 80; server_name www.xxx.cn; root /www/wwwroot/www.xxx.cn; #access_log logs/host.access.log main; error_page 404 /404.html; error_page 502 /502.html; location / { index index.html index.htm; } }?
Nginx 反向代理负载均衡配置文件
upstream m.godehi.cn{ server 127.0.0.1:123 weight=8; server 127.0.0.1:124 weight=2; } server { listen 80; server_name m.xxx.cn; #root /www/wwwroot/m.xxx.cn; #access_log logs/host.access.log main; error_page 404 /404.html; error_page 502 /502.html; location / { proxy_pass http://m.xxx.cn;#这个名称和upstream的名称保持一致 index index.html index.htm; } }?
Nginx php 利用fastcgi 解析 开启fpm配置文件
server{ listen 80; server_name www.xxx.cn; root /www/wwwroot/www.xxx.cn; # 该项要修改为你准备存放相关网页的路径 location / { index index.php index.html index.htm; #如果请求既不是一个文件,也不是一个目录,则执行一下重写规则 if (!-e $request_filename) { #地址作为将参数rewrite到index.php上。 rewrite ^/(.*)$ /index.php/$1; #若是子目录则使用下面这句,将subdir改成目录名称即可。 #rewrite ^/subdir/(.*)$ /subdir/index.php/$1; } } #proxy the php scripts to php-fpm location ~ \.php { include /usr/local/nginx/conf/fastcgi_params; ##pathinfo支持start #定义变量 $path_info ,用于存放pathinfo信息 set $path_info ""; #定义变量 $real_script_name,用于存放真实地址 set $real_script_name $fastcgi_script_name; #如果地址与引号内的正则表达式匹配 if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { #将文件地址赋值给变量 $real_script_name set $real_script_name $1; #将文件地址后的参数赋值给变量 $path_info set $path_info $2; } #配置fastcgi的一些参数 fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; ###pathinfo支持end fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; } location ^~ /data/runtime { return 404; } location ^~ /application { return 404; } location ^~ /simplewind { return 404; } }
相关推荐
nginxs 2020-11-14
Guanjs0 2020-11-13
小木兮子 2020-11-11
yserver 2020-11-11
ssihc0 2020-11-11
windle 2020-11-10
HanksWang 2020-11-10
liuchen0 2020-11-10
Freshairx 2020-11-10
ccschan 2020-11-10
liwf 2020-11-10
Guanjs0 2020-11-09
AderStep 2020-11-09
zrtlin 2020-11-09
mqfcu 2020-11-10
windle 2020-10-29