linux 全新编译安装,全新linux中通过编译方式安装nginx
先去官網(wǎng)下載linux.tar.gz包 http://nginx.org/en/download.html
傳到linxu中
解壓tar包
在軟件包nginx-1.15.9目錄下對(duì)NGINX進(jìn)行配置
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-http_stub_status_module --with-stream
執(zhí)行以上命令,提示這個(gè)信息:說明沒有安裝編譯器
checking for OS
+ Linux 3.10.0-957.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
解決:yum -install gcc
在執(zhí)行以上命令提示這個(gè)信息
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl= option.
解決:yum -y install openssl openssl-devel
配置執(zhí)行成功:
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/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx"
nginx configuration file: "/usr/local/nginx/nginx.conf"
nginx pid file: "/usr/local/nginx/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"
執(zhí)行編譯:make
編譯安裝:make install
到NGINX目錄下啟動(dòng):./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)
nginx: [emerg] still could not bind()
原因:可能是進(jìn)程已經(jīng)啟動(dòng),或者是端口被占用
解決方式:先查看進(jìn)程是否啟動(dòng):ps -ef |grep nginx。如未啟動(dòng),就是原因二。
原因二解決方式:到安裝目錄下打開配置文件:vi nginx.conf。將修改為8080,再次啟動(dòng)即可
啟動(dòng)成功后瀏覽器中輸入ip和端口訪問。
提示“無法訪問此網(wǎng)站”
原因:linux中啟動(dòng)了防火墻,可通過:systemctl status firewalld命令查看防火墻狀態(tài)
解決方式:systemctl stop firewalld 使用該命令禁用防火墻
再次訪問ok
總結(jié)
以上是生活随笔為你收集整理的linux 全新编译安装,全新linux中通过编译方式安装nginx的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux 修改用户名 终端,如何修改U
- 下一篇: linux下实现dns服务器,linux