在源码安装Nginx时,出现以下错误信息:
[root@localhost nginx-1.16.1]# make && make install
make: *** 没有规则可以创建“default”需要的目标“build”。 停止。
Nginx所需依赖包:
gcc
功能:预处理、编译、连接、汇编
openssl
功能:用于网站加密通讯。
pcre
功能:用于支持解析正则表达式。
zlib
功能:用于对数据进行解压缩。网站之间通信时,数据先压缩再传输,通过消耗CPU的方式来节省网络带宽。
安装Nginx相关依赖包:
[root@localhost nginx-1.16.1]# yum -y install gcc openssl openssl-devel pcre-devel zlib zlib-devel
安装后验证:
[root@localhost nginx-1.16.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module
...
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@localhost nginx-1.16.1]# make && make install //编译和安装
...
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
|| cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
make[1]: 离开目录“/root/nginx-1.16.1”
启动Nginx
[root@localhost nginx-1.16.1]# /usr/local/nginx/sbin/nginx
[root@localhost nginx-1.16.1]# ss -antulp | grep :80
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=15686,fd=6),("nginx",pid=15685,fd=6))
tcp LISTEN 0 50 :::8080 :::* users:(("java",pid=3207,fd=161))
其他:
- 如果这个方法还是不行,可以检查 ./configure后面的选项是否有误,或者选项中的路径是 否正确,也可以看一下系统提示哪些是 —not found的,看缺少哪些依赖包。
↓↓↓↓↓↓
最近刚申请了个微信公众号,上面也会分享一些运维知识,大家点点发财手关注一波,感谢大家。 【原创公众号】:非著名运维 【福利】:公众号回复 “资料” 送运维自学资料大礼包哦!
如果你觉得这篇文章还不错,就请动动你的发财手为本文留个言,点个在看,或者转发一下吧,因为这将是我持续输出更多优质文章的最强动力!