nginx 安装
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
mkdir /usr/local/nginx
cd /usr/local/nginx/
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar zxvf nginx-1.18.0.tar.gz
cd /nginx/nginx-1.18.0
./configure
make
make install
报错
cc1:所有的警告都被当作是错误 make[1]: *** [objs/Makefile:431:objs/src/core/ngx_murmurhash.o] 错误 1 make[1]: 离开目录“/opt/nginx-1.8.1” make: *** [Makefile:8:build] 错误 2 原因:将警告当成错误处理
解决
进入到nginx-1.6.3目录下(解压的目录)
找到当前目录下找到objs文件夹,并进入,打开文件Makefile,找到有一下内容的这行:
[root@lnmp nginx-1.8.1]# vim objs/Makefile
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g
-Werror: gcc将所有的警告当成错误进行处理把这行内容中的 “-Werror”去掉
报错
报错
**Nginx [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)**
查看端口占用情况,杀死已占用的80 一般为nginx重复启动占,用netstat -ltunp命令
查找到pid kill -9 pid
重启即可。
不放心可在查看 ps -ef | grep nginx
**检测是否安装成功**
cd /usr/local/nginx/sbin/
sudo ./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
启动
cd /usr/local/nginx/sbin
./nginx
./nginx -s reload 重启命令
报错403
1:配置启动用户和访问用户一致
nginx配置文件conf 第一行 user nobody改为和启动用户一致 我的为root 第一行改成对应 user root
2:server下配置
listen 80;
server_name www.****.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/ucan/xaucan;
index index.html index.htm;
}
报错没有sbin目录的 一般是nginx1.2.1版本参考下面链接nginx下无sbin目录