Nginx:
高性能的HTTP, 反向代理
[root@station230 ~]# service httpd stop
[root@station230 ~]# chkconfig httpd off
所需的软件:
开发工具,开发库,openssl-devel
部署Nginx
=====================================================
pcre: 支持正则表达式,地址重写rewrite
# tar xvf pcre-8.10.tar.gz
# cd pcre-8.10
# ./configure && make && make install
nginx:
# useradd www
# tar xvf nginx-1.2.0.tar.gz
# cd nginx-1.2.0
# ./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_ssl_module
# make
# make install
# tree /usr/local/nginx/
/usr/local/nginx/
|-- conf
| |-- fastcgi.conf
| |-- fastcgi.conf.default
| |-- fastcgi_params
| |-- fastcgi_params.default
| |-- koi-utf
| |-- koi-win
| |-- mime.types
| |-- mime.types.default
| |-- nginx.conf
| |-- nginx.conf.default
| |-- scgi_params
| |-- scgi_params.default
| |-- uwsgi_params
| |-- uwsgi_params.default
| `-- win-utf
|-- html
| |-- 50x.html
| `-- index.html
|-- logs
`-- sbin
`-- nginx
启动:
# /usr/local/nginx/sbin/nginx
# ps aux |grep nginx
root 17411 0.0 0.0 6060 700 ? Ss 13:47 0:00 nginx: master process /usr/local/nginx/sbin/nginx
www 17412 0.0 0.0 6280 1064 ? S 13:47 0:00 nginx: worker process
# netstat -tnlp |grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 17411/nginx
# links -dump 192.168.2.115
Welcome to nginx!
# echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local 开机运行
==== 基本配置Nginx= ==
# vim /usr/local/nginx/conf/nginx.conf
worker_processes 10; 初始启动的进程数
worker_connections 1024; 最大连接数
server {
listen 80; 监听的端口
server_name localhost; 站点名
location / {
root html; //root指令指定网站主目录(相对于nginx的安装目录)
index index.html index.htm;//默认主页
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
语法检查:
# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
重新加载nginx:
[root@station230 ~]# pgrep nginx //查看进程的pid
17411
17412
[root@station230 ~]# kill -HUP 17411 //kill -HUP(1) pid 更改配置而不需停止并重新启动服务。在对配置文件作必要的更改后,发出该命令以动态更新服务配置。
[root@station230 ~]# pgrep nginx
17411
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
# rm -rf /usr/local/nginx/html/* 站点默认主目录
# echo "new nginx..." > /usr/local/nginx/html/index.html
# links -dump 192.168.2.115
new nginx...
高性能的HTTP, 反向代理
[root@station230 ~]# service httpd stop
[root@station230 ~]# chkconfig httpd off
所需的软件:
开发工具,开发库,openssl-devel
部署Nginx
=====================================================
pcre: 支持正则表达式,地址重写rewrite
# tar xvf pcre-8.10.tar.gz
# cd pcre-8.10
# ./configure && make && make install
nginx:
# useradd www
# tar xvf nginx-1.2.0.tar.gz
# cd nginx-1.2.0
# ./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_ssl_module
# make
# make install
# tree /usr/local/nginx/
/usr/local/nginx/
|-- conf
| |-- fastcgi.conf
| |-- fastcgi.conf.default
| |-- fastcgi_params
| |-- fastcgi_params.default
| |-- koi-utf
| |-- koi-win
| |-- mime.types
| |-- mime.types.default
| |-- nginx.conf
| |-- nginx.conf.default
| |-- scgi_params
| |-- scgi_params.default
| |-- uwsgi_params
| |-- uwsgi_params.default
| `-- win-utf
|-- html
| |-- 50x.html
| `-- index.html
|-- logs
`-- sbin
`-- nginx
启动:
# /usr/local/nginx/sbin/nginx
# ps aux |grep nginx
root 17411 0.0 0.0 6060 700 ? Ss 13:47 0:00 nginx: master process /usr/local/nginx/sbin/nginx
www 17412 0.0 0.0 6280 1064 ? S 13:47 0:00 nginx: worker process
# netstat -tnlp |grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 17411/nginx
# links -dump 192.168.2.115
Welcome to nginx!
# echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local 开机运行
==== 基本配置Nginx= ==
# vim /usr/local/nginx/conf/nginx.conf
worker_processes 10; 初始启动的进程数
worker_connections 1024; 最大连接数
server {
listen 80; 监听的端口
server_name localhost; 站点名
location / {
root html; //root指令指定网站主目录(相对于nginx的安装目录)
index index.html index.htm;//默认主页
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
语法检查:
# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
重新加载nginx:
[root@station230 ~]# pgrep nginx //查看进程的pid
17411
17412
[root@station230 ~]# kill -HUP 17411 //kill -HUP(1) pid 更改配置而不需停止并重新启动服务。在对配置文件作必要的更改后,发出该命令以动态更新服务配置。
[root@station230 ~]# pgrep nginx
17411
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
# rm -rf /usr/local/nginx/html/* 站点默认主目录
# echo "new nginx..." > /usr/local/nginx/html/index.html
# links -dump 192.168.2.115
new nginx...