每次在Linux搭建web環境都要一頓google求參考文檔,此次索性寫個簡單的文章記錄一下。其實Linux下編譯安裝主要就是這幾個步驟。
linux
安裝編譯工具、依賴包及下載源碼包nginx
解壓編譯c++
安裝web
啓動centos
$ yum -y install gcc gcc-c++ autoconf automake $ yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
以上安裝的是一些主要的依賴包,具體可根據本身狀況或者報錯信息提示安裝或修改bash
新建的用戶組和用戶主要是在編譯配置的時候指定nginx運行的用戶和用戶組。這樣指定後之後配置使用也方便。工具
$ sudo groupadd -r nginx $ sudo useradd -s /sbin/nologin -g nginx -r nginx
我通常從官網下載google
wget http://nginx.org/download/nginx-1.10.0.tar.gz
tar -zxvf nginx-1.10.0.tar.gz
./configure \ --prefix=/usr/local/nginx \ --conf-path=/etc/nginx/nginx.conf \ --user=nginx \ --group=nginx \
配置沒毛病的話能夠看到這些信息centos7
Configuration summary + using system PCRE library + OpenSSL library is not used + md5: using system crypto library + sha1: using system crypto 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: "/etc/nginx" nginx configuration file: "/etc/nginx/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"
以上編譯參數只是配置了主要的東西,所有配置參數說明你能夠經過這個命令查看./configure --help
code
$ make && make install
啓動等命令
須進入到/usr/local/nginx/sbin
目錄下
$ nginx
$ nginx -s stop
$ nginx -s reload
以上各個步驟報錯的話根據報錯提示缺啥裝啥,不犯幾回錯誤都很差意思說本身配過環境。PS:有問題可留言討論哦