前期准备
在开始之前,保证你的系统准备了gcc、make、wget,g++ 这些软件。 创建一个目类用来存放下载文件,进入目录中下载依赖库源文件
安装gcc
apt-get install gcc
pcre、pcre-devel安装:来实现对地址重定向,地址重写功能和localtion指令以及正则表达式的支持
apt-get install libpcre3 libpcre3-dev
zlib安装:gzip压缩模块
apt-get install zlib1g zlib1g-dev
openssl安装:主要用于ssl模块加密,支持htps
apt-get install openssl openssl-dev
1.没有找到该文件,服务器启动失败
Failed to start A high performance web server and a reverse proxy server.
nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
解决办法:可能是你不在默认路径下安装的,而它默认路径下配置文件是/etc/nginx/nginx.conf
转到sbin下面,指定配置文件,我的安装路径是/usr/local/nginx
执行 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
2.指定配置文件时,英文提示地址正在使用中
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
解决办法:去查看Nginx进程 ps -ef|grep nginx
带有master的杀掉重新运行 kill -HUP14278(示例进程号) 重新启动即可 ./nginx -s reload
3. make: *** No rule to make target 'build', needed by 'default'. Stop.
安装Nginx之前需要把前期那些东西安装好,然后执行 ./configure,再执行make就不会报错了
4.nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
没有/usr/local/nginx/logs/nginx.pid 文件,在sbin里面指定配置文件
[root]/usr/local/nginx/sbin: $/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
5.Nginx在执行make时
ubuntu src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=] h ^= data[2] << 16; ~~^~~~~~~~~~~~~~~~ src/core/ngx_murmurhash.c:38:5: note: here case 2: ^~~~ src/core/ngx_murmurha
找到它,或者用vim编辑器打开它进行编辑
打开
删掉 -Werrori,我的已经删掉了就这个位置, 再重新执行make
7.在执行./nginx
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2020/04/13 14:48:20 [emerg] 2717#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)
由于缺少 error文件夹和error.log ,access文件夹和access.log
需要在/usr/local/nginx中 执行
mkdir logs cd logs touch access.log touch error.log
然后返回/usr/local/nginx/sbin 执行./nginx