1.安装
1)在Windows环境下的安装
下载windows版本的nginx后,解压,然后进入到目录中,运行:start nginx
其他命令:nginx -s [ stop|quit|reopen|reload ]
2)在linux下的安装
复制代码代码如下:
tar zxvf pcre-8.21.tar.gz(安装nginx必需)
./configure
make
make install
cp /usr/local/lib/libpcre.so.1 /usr/lib
tar zxvf nginx..../tar.gz
cd nginx...
./configure
make
make install
2.nginx的启动
linux下命令:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
(-c是指定配置文件的意思)
3.nginx的停止
复制代码代码如下:
ps -ef |grep nginx
找到master process的id
kill -QUIT nginx的id
快速停止
kill -TERM nginx的id
强制关闭nginx的所有进程
pkill -9 nginx
4.nginx的重启
1)检查配置文件是否正确
/usr/local/nginx/sbi
....
events
{
...
}
http
{
....
server
{
...
}
server
{
...
}
...
}
虚拟主机配置
复制代码代码如下:
#server {
# listen 8000;
# server_name localhost;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# } www.jb51.net
#}
#server {
# listen 8080;
# server_name localhost;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}