在CentOS 7 安裝 Nginx 1.10.1

  1. cd /usr/local
  2. 安裝GCC 和GCC-C++
    yum install gcc
    yum install -y gcc gcc-c++
  1. 安裝pcre庫
cd /usr/local/
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39/
./configure
make
make install
  1. 安裝zlib庫
cd /usr/local/ 
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure
make
make install
  1. 安裝ssl
cd /usr/local/
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
cd openssl-1.0.1c
./config
make
make install

按上面的操作,openssl報(bào)錯(cuò),我再次更新了一下openssl
yum -y install openssl openssl-devel

  1. 安裝nginx
cd /usr/local/
wget http://nginx.org/download/nginx-1.10.1.tar.gz
tar -zxvf nginx-1.10.1.tar.gz
cd nginx-1.10.1/

為了支持wss,我添加了--with-stream --with-stream_ssl_module

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-stream --with-stream_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre=/usr/local/pcre-8.39 --with-zlib=/usr/local/zlib-1.2.8
make
make install
  1. 啟動(dòng) nginx
    /usr/local/nginx/sbin/nginx

如果 nginx: [emerg] getpwnam("nginx") failed 執(zhí)行一下面兩行

useradd -s /sbin/nologin -M nginx
id nginx

應(yīng)該會(huì)出現(xiàn)
uid=1000(nginx) gid=1000(nginx) 組=1000(nginx)

如果 nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory) 執(zhí)行下面兩行

cd /var/tmp/
mkdir -p /var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi}

再一次,沒有任何提示就表示成功
/usr/local/nginx/sbin/nginx

  1. 輸入http://localhost/

注:配置文件在/etc/nginx/nginx.conf

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容