linux 全新编译安装,全新linux中通过编译方式安装nginx
先去官網下載linux.tar.gz包 http://nginx.org/en/download.html
傳到linxu中
解壓tar包
在軟件包nginx-1.15.9目錄下對NGINX進行配置
./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
執行以上命令,提示這個信息:說明沒有安裝編譯器
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
在執行以上命令提示這個信息
./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
配置執行成功:
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"
執行編譯:make
編譯安裝:make install
到NGINX目錄下啟動:./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()
原因:可能是進程已經啟動,或者是端口被占用
解決方式:先查看進程是否啟動:ps -ef |grep nginx。如未啟動,就是原因二。
原因二解決方式:到安裝目錄下打開配置文件:vi nginx.conf。將修改為8080,再次啟動即可
啟動成功后瀏覽器中輸入ip和端口訪問。
提示“無法訪問此網站”
原因:linux中啟動了防火墻,可通過:systemctl status firewalld命令查看防火墻狀態
解決方式:systemctl stop firewalld 使用該命令禁用防火墻
再次訪問ok
總結
以上是生活随笔為你收集整理的linux 全新编译安装,全新linux中通过编译方式安装nginx的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux 修改用户名 终端,如何修改U
- 下一篇: linux下实现dns服务器,linux