[root@localhost nginx-1.4.7]# yum install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel -y
[root@localhost pcre-8.33]# ./configure --enable-utf8 --enable-rebuild-chartables --enable-newline-is-any --enable-pcregrep-libz
[root@localhost nginx-1.4.7]# yum install perl perl-devel perl-ExtUtils-Embed
[root@localhost nginx-1.4.7]# yum install libxslt libxslt-devel -y
[root@localhost nginx-1.4.7]# ./configure --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --user=nginx --group=nginx --with-rtsig_module --with-select_module --with-poll_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_flv_module --with-http_perl_module --with-perl=/usr/bin/perl --http-log-path=/var/log/nginx/access.log --with-pcre --with-pcre=/softs/pcre-8.33/ --with-http_stub_status_module
[root@localhost nginx-1.4.7]# make
[root@localhost nginx-1.4.7]# make install
修改nginx配置文件
[root@localhost conf]# cat /usr/local/nginx/conf/nginx.conf| more
user nginx; ##指定运行的用户
worker_processes 4; ##启动的进程数目
error_log /var/log/nginx/error.log error; ###重新定义错误日志的路径和级别
pid /var/run/nginx/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 /var/log/nginx/access.log main; ###定义日志格式
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65; #会话保持时间
gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /www; ####DocumentRoot
index index.html index.htm index.php;
}
#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;
}
}
[root@localhost nginx]# ps -ef |grep nginx
root 14416 1 0 15:56 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx 14417 14416 0 15:56 ? 00:00:00 nginx: worker process
nginx 14418 14416 0 15:56 ? 00:00:00 nginx: worker process
nginx 14419 14416 0 15:56 ? 00:00:00 nginx: worker process
nginx 14420 14416 0 15:56 ? 00:00:00 nginx: worker process
root 15619 35790 0 16:00 pts/0 00:00:00 grep nginx
这里总共四个进程,就是前面配置文件中的所指定的process。