Nginx安装配置的详细教程
今天小编跟大家分享一篇关于Nginx安装配置的详细教程,感兴趣的朋友跟小编一起来了解一下吧!
Nginx服务器的安装和配置
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
-----------------------------------------------------------------------------------------------------------
下面这个错误时nginx版本有问题,换成最新的 nginx-1.0.10 就可以!
src/core/ngx_resolver.c: In function ‘ngx_resolver_process_ptr’:
src/core/ngx_resolver.c:1425:43: error: variable ‘qclass’ set but not used [-Werror=unused-but-set-variable]
src/core/ngx_resolver.c:1425:36: error: variable ‘qtype’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[1]: *** [objs/src/core/ngx_resolver.o] Error 1
-----------------------------------------------------------------------------------------------------------
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/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
2)平滑重启
kill -HUP Nginx主进程号
如果配置文件不正确,nginx将仍旧使用修改前的配置文件
nginx基本配置
通过配置文件示例可知,nginx.conf配置文件结构主要构成:
....
events
{
...
}
http
{
....
server
{
...
}
server
{
...
}
...
}
虚拟主机配置
#server {
# listen 8000;
# server_name localhost;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
#server {
# listen 8080;
# server_name localhost;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
以上就是关于Nginx安装配置的详细教程了,想必都了解了吧,更多相关内容请继续关注爱站技术频道。