1.nginx介绍
2,nginx编译安装
上传nginx包 nginx-1.12.2.tar.gz
1.安装nginx依赖
yum install lrzsz gcc gcc-c++ pcre-devle zlib-devel
2.解压nginx包
tar -xvf nginx-1.12.2.tar.gz
3.配置和检测环境
./configure --prefix=/usr/local/nginx #配置nginx安装目录
这种报错就是确实pcre库,,一般就是因为没有安装
yum install pcre-devel 安装一下就好
.
4. 编译 安装
make && make install
5. 启动nginx
[root@localhost nginx-1.12.2]# /usr/local/nginx/sbin/nginx
[root@localhost nginx-1.12.2]# netstat -pltun|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 16659/nginx: master
6.关闭防火墙,访问
7.做软连接
[root@localhost nginx-1.12.2]# ln -sv /usr/local/nginx/sbin/nginx /usr/bin/nginx
‘/usr/bin/nginx’ -> ‘/usr/local/nginx/sbin/nginx’
[root@localhost nginx-1.12.2]# ln -sv /usr/local/nginx/sbin/nginx /usr/bin/nginx
可以直接启动nginx
[root@localhost nginx-1.12.2]# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
8.启停检测语法
nginx -t 检测nginx是否正常 出现isoknginx 即可
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 nginx-1.12.2]# nginx -s stop
netstat -pltu|grep nginx 查看端口是否存在
nginx -s reload #当子配置文件发生变化,重新载入配置文件 这个报错是因为没有启动nginx
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
nginx
nginx -s reload
下一章节 nginx负载均衡+反向代理