nbuntu安装配置ngnix
nginx 下载地址在 http://nginx.org/download/
首先下载nginx包
wget http://nginx.org/download/nginx-1.13.2.tar.gz 我这边下载的是1..13.2
下载完成后解压 tar -zxvf nginx-1.13.2.tar.gz
执行./configure 不过这部报错
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
表示需要安装pcre包。
你可能还需要安装
sudo apt-get install openssl libssl-dev
执行 ./configure --with-http_ssl_module
正常情况显示
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
执行make
make install
修改
(1)在线安装的启动过程
$sudo /etc/init.d/nginx start
(2)源代码安装的启动过程
$cd /usr/local/nginx
$sbin/nginx
然后就可以访问了,http://localhost/ , 一切正常!如果不能访问,先不要继续,看看是什么原因,
二、重启
更改配置重启nginx
kill -HUP 主进程号或进程号文件路径 或者使用 cd /usr/local/nginx/sbin ./nginx -s reload
判断配置文件是否正确
nginx -t -c /usr/local/nginx/conf/nginx.conf 或者 cd /usr/local/nginx/sbin ./nginx -t
查询nginx主进程号
ps -ef | grep nginx
从容停止 kill -QUIT 主进程号
快速停止 kill -TERM 主进程号
强制停止 kill -9 nginx
若nginx.conf配置了pid文件路径,如果没有,则在logs目录下
kill -信号类型 '/usr/local/nginx/logs/nginx.pid'