安装环境
- ubantu16
- nginx安装包 下载地址
安装依赖
首先执行同步最新
apt-get update
安装gcc g++的依赖库
apt-get install build-essential
安装PCRE,perl 兼容的正则表达式库
apt-get install libpcre3 libpcre3-dev
安装zlib
apt-get install zlib1g-dev
安装OpenSSL
apt-get install openssl libssl-dev
配置configure
创建服务的各项目录:
mkdir -p /opt/nginx-server/{configure,log,temp}
执行如下命令
./configure \
--prefix=/opt/nginx-server \
--pid-path=/opt/nginx-server/configure/nginx.pid \
--lock-path=/opt/nginx-server/configure/nginx.lock \
--error-log-path=/opt/nginx-server/log/error.log \
--http-log-path=/opt/nginx-server/log/access.log \
--with-http_gzip_static_module \
--with-http_ssl_module \
--http-client-body-temp-path=/opt/nginx-server/temp/client \
--http-proxy-temp-path=/opt/nginx-server/temp/proxy \
--http-fastcgi-temp-path=/opt/nginx-server/temp/fastcgi \
--http-uwsgi-temp-path=/opt/nginx-server/temp/uwsgi \
--http-scgi-temp-path=/opt/nginx-server/temp/scgi
配置中的/opt/nginx-server/…/…目录应自己配置,否则报错
nginx: [emerg] mkdir() “/var/temp/nginx/client” failed (2: No such file or directory)。
安装编译
输入命令
make && makeinstall
查看自己配置的服务目录
配置文件在conf文件夹下,启动文件在sbin下
测试
配置好配置文件后,执行命令:./nginx -t
,确认无误后执行命令:./nginx
启动nginx访问自己配置好的端口及可正常显示nginx的默认页面(此处无图)。
常用命令
关闭命令
./nginx -s stop
退出命令
./nginx -s quit [等程序执行完毕后关闭,建议使用此命令。]
加载非默认配置文件命令
./nginx -c [/var/user/conf/nginx.conf]
重新加载
./nginx -s reload
查看版本号
./nginx -v
设置开机启动请参考
https://www.cnblogs.com/EasonJim/p/7806879.html