nginx的安装及启动

来源:互联网 发布:淘宝儿童电动车 编辑:程序博客网 时间:2024/06/05 20:00

1、我安装的nginx1.8版本


2、安装环境(gcc,pcre,zlib,openssl)

yum install gcc-c++ yum install -y pcre pcre-develyum install -y zlib zlib-develyum install -y openssl openssl-devel


3、解压nginx压缩包,然后进入nginx目录,执行如下命令

./configure \--prefix=/usr/local/nginx \--pid-path=/var/run/nginx/nginx.pid \--lock-path=/var/lock/nginx.lock \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--with-http_gzip_static_module \--http-client-body-temp-path=/var/temp/nginx/client \--http-proxy-temp-path=/var/temp/nginx/proxy \--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \--http-scgi-temp-path=/var/temp/nginx/scgi注意:上边将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录


4、编译,安装

 1)make

 2)make install


5、启动

cd /usr/local/nginx/sbin/./nginx 

可以使用 ps-ef | grep nginx 查看nginx是否正常启动 有2个进程


注意:执行./nginx启动nginx,这里可以-c指定加载的nginx配置文件,如下:

./nginx-c /usr/local/nginx/conf/nginx.conf

如果不指定-c,nginx在启动时默认加载conf/nginx.conf文件,此文件的地址也可以在编译安装nginx时指定./configure的参数(--conf-path= 指向配置文件(nginx.conf))


6、停止(安全停止 kill -9 进程id 暴力停止)
./nginx -s quit


7、重启(建议先退出在启动

./nginx -s reload


8、访问ip地址,能够看到网页上显示welcome to nginx!表示启动成功



原创粉丝点击