您的位置:首页 > 运维架构 > Nginx

nginx安装方法

2017-04-29 14:35 85 查看
nginx安装
准备安装包
pcre-8.40.tar.gz
nginx-1.8.0.tar.gz

[root@localhost soft]# tar -zxf pcre-8.40.tar.gz
cd pcre-8.40
./configure && make && make install
[root@localhost soft]# tar -zxf nginx-1.8.0.tar.gz

[root@localhost soft]# useradd nginx -s /sbin/nologin -M
cd nginx-1.8.0
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module

检查语法
[root@localhost local]# ./nginx/sbin/nginx -t
libpcre.so 没有指定这个库
[root@localhost local]# find / -name libpcre.so*

[root@localhost local]# find / -name libpcre.so*
/soft/pcre-8.40/.libs/libpcre.so.1
/soft/pcre-8.40/.libs/libpcre.so.1.2.8
/soft/pcre-8.40/.libs/libpcre.so
/usr/local/pcre/lib/libpcre.so.0.0.1
/usr/local/pcre/lib/libpcre.so.0
/usr/local/pcre/lib/libpcre.so
/usr/local/lib/libpcre.so.1
/usr/local/lib/libpcre.so.1.2.8
/usr/local/lib/libpcre.so
/tar/pcre-8.10/.libs/libpcre.so.0.0.1
/tar/pcre-8.10/.libs/libpcre.so.0
/tar/pcre-8.10/.libs/libpcre.so
/lib/libpcre.so.0.0.1
/lib/libpcre.so.0

[root@localhost local]# vim /etc/ld.so.conf
/usr/local/lib
wq
ldconfig #使用库文件再次生效

[root@localhost local]# ./nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

启动nginx注意
[root@localhost local]# ./nginx/sbin/nginx
[root@localhost local]# ps -ef | grep ngins
root 11957 1679 0 19:30 pts/0 00:00:00 grep ngins
[root@localhost local]# ps -ef | grep nginx
root 11954 1 0 19:30 ? 00:00:00 nginx: master process ./nginx/sbin/nginx
nginx 11955 11954 0 19:30 ? 00:00:00 nginx: worker process
root 11959 1679 0 19:30 pts/0 00:00:00 grep nginx

[root@localhost local]# lsof -i tcp:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 11954 root 6u IPv4 32485 0t0 TCP *:http (LISTEN)
nginx 11955 nginx 6u IPv4 32485 0t0 TCP *:http (LISTEN)

[root@localhost local]# curl -I 172.20.100.134
HTTP/1.1 200 OK
Server: nginx/1.8.0
Date: Mon, 24 Apr 2017 11:33:10 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Mon, 24 Apr 2017 11:21:55 GMT
Connection: keep-alive
ETag: "58fddfd3-264"
Accept-Ranges: bytes

安装完成 HTTP/1.1 200 OK
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx 服务安装