nginx安装配置
最近部署项目用到了nginx,下面安装过程以及安装过程遇到的问题和解决方法
1.安装支持正则的pcre模块
shell:
tar zxvf pcre-8.02.tar.gz
cd pcre-8.02
./configure
make
make install
2.安装 gcc-c++(如果不存在)
yum install gcc-c++
3.安装nginx
shell:
tar zxvf nginx-0.8.54.tar.gz
cd t
ar zxvf
nginx-0.8.54
./configure --with-http_stub_status_module --with-http_gzip_static_module --prefix=/opt/nginx
make
make install
ps: --prefix=/opt/nginx安装路径 --with-http_gzip_static_module传输压缩模块 --with-http_stub_status_module监控当前状态模块
ps:
CPU相关:
#user nobody;
#worker_processes 4;
进程位置
pid logs/nginx.pid;
4.启动&停止
/opt/nginx/sbin/nginx -V #查看编译选项,安装模块
/opt/nginx/sbin/nginx -t #查看配置文件是否正确
/opt/nginx/sbin/nginx -t -c /opt/nginx/conf/nginx.conf #指定配置文件是否正确
/opt/nginx/sbin/nginx #启动
ps -ef|grep nginx #查看pid
kill -XXX pid
-XXX : QUIT:请求处理完成后关闭进程
HUP:平滑重启
USR1,USR2
ps:其它关闭方法 /opt/nginx/sbin/nginx -s stop # 详细 -h帮助
//问题集:
安装Nginx时报错 the HTTP cache module requires md5 functions
2011-09-25 13:20
安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel
错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解决办法:
yum -y install openssl openssl-devel
-----------------------------------------------------------------------------------------------------------------------
下面的配置文件:
#user nobody;
#worker_processes 4;
#worker_cpu_affinity 0001 0010 0100 1000;
worker_processes 2;
worker_cpu_affinity 0001 0010;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 20m;
limit_rate 1024k;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
tcp_nodelay on;
client_body_buffer_size 512k;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types html css gif jpeg png js swf txt xml;
gzip_vary on;
server {
listen 80;
server_name localhost;
access_log off;
location ^~ /WEB-INF {
deny all;
}
location ~* \.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|zip|java|jar|flv|swf|mid|doc|ppt|xls|pdf|mp3|wma|css|js|txt|xml)$ {
root /usr/local/tomcatStone/webapps/ROOT;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
}
}
|
分享到:
相关推荐
2) Nginx配置 - 1 - a)对c:\nginx\conf\nginx.conf文件进行配置: - 1 - b)常用的 Nginx 参数 - 3 - c)静态文件处理 - 4 - d)动态页面请求处理 - 4 - e)下面为nginx.conf配置实例: - 5 - f)Nginx 启动,停止等命令 ...
Nginx安装配置
nginx安装配置全攻略:都是实际安装配置经验,傻瓜式步骤
nginx 安装 配置 明细文档
centos 6 nginx 安装配置手册,最适合新手的安装配置教程,从0开始。
linuxnginx安装配置文件支持php.pdf
Nginx安装配置1.源码安装上传openssl-1.0.1s.tar.gz、pcre-8.38.tar.bz2、ngx_cache_purge-2.3.tar
Linux nginx安装配置步骤.txt
linux系统下的nginx安装配置文档,nginx主要用于web服务器的负载均衡及流量代理,提高系统的安全性和稳定性。
Linux环境下nginx安装配置.docx
「linux命令大全Nginx安装配置」.docx
CentOS6环境FastDFS+Nginx安装配置笔记.pdf
Nginx安装配置PageSpeed模块实现网站加速.docx
linux下安装nginx被配置sticky模块的相关软件包,包含nginx.conf的简单实例
nginx安装、不同配置含义、常用命令、安全等方面的介绍
nginx安装、配置、负载均衡.ppt