CentOS 7.3 x64 安装 Nginx

前端之家收集整理的这篇文章主要介绍了CentOS 7.3 x64 安装 Nginx前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

GCC & GCC-C++

  1. [root@jdu4e00u53f7 ~]# yum install gcc
  2. [root@jdu4e00u53f7 ~]# yum install gcc-c++
  1. 若未安装GCC,后续安装Nginx时会报如下错误
  2. ./configure: error: C compiler cc is not found
  3. 若未安装GCC-C++,后续安装PCRE库时会报如下错误
  4. configure: error: You need a C++ compiler for C++ support.

PCRE library

  1. [root@jdu4e00u53f7 centos]# wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
  2. [root@jdu4e00u53f7 centos]# tar -zxf pcre-8.41.tar.gz
  3. [root@jdu4e00u53f7 centos]# cd pcre-8.41
  4. [root@jdu4e00u53f7 pcre-8.41]# ./configure
  5. [root@jdu4e00u53f7 pcre-8.41]# make
  6. [root@jdu4e00u53f7 pcre-8.41]# make install
  1. 可在 [https://ftp.pcre.org/pub/pcre/](https://ftp.pcre.org/pub/pcre/) 查看最新版本。
  2. 若未安装PCRE库,后续安装Nginx时会报以下错误
  3. ./configure: error: the HTTP rewrite module requires the PCRE library.
  4. You can either disable the module by using --without-http_rewrite_module
  5. option,or install the PCRE library into the system,or build the PCRE library
  6. statically from the source with Nginx by using --with-pcre=<path> option.

ZLIB Library

  1. [root@jdu4e00u53f7 centos]# wget http://www.zlib.net/zlib-1.2.11.tar.gz
  2. [root@jdu4e00u53f7 centos]# tar -zxf zlib-1.2.11.tar.gz
  3. [root@jdu4e00u53f7 centos]# cd zlib-1.2.11
  4. [root@jdu4e00u53f7 zlib-1.2.11]# ./configure
  5. [root@jdu4e00u53f7 zlib-1.2.11]# make
  6. [root@jdu4e00u53f7 zlib-1.2.11]# make install
  1. 可在 [http://www.zlib.net/](http://www.zlib.net/) 查看最新版本。
  2. 若未安装ZLIB库,后续安装Nginx时会报以下错误
  3. ./configure: error: the HTTP gzip module requires the zlib library.
  4. You can either disable the module by using --without-http_gzip_module
  5. option,or install the zlib library into the system,or build the zlib library
  6. statically from the source with Nginx by using --with-zlib=<path> option.

Nginx

  1. [root@jdu4e00u53f7 centos]# wget http://Nginx.org/download/Nginx-1.13.4.tar.gz
  2. [root@jdu4e00u53f7 centos]# tar -zxf Nginx-1.13.4.tar.gz
  3. [root@jdu4e00u53f7 centos]# cd Nginx-1.13.4
  4. [root@jdu4e00u53f7 Nginx-1.13.4]# ./configure
  5. [root@jdu4e00u53f7 Nginx-1.13.4]# make
  6. [root@jdu4e00u53f7 Nginx-1.13.4]# make install
  1. 可在 [http://Nginx.org/download/](http://Nginx.org/download/) 查看最新版本。
  2. Nginx的默认安装位置为 /usr/local/Nginx
  1. [root@jdu4e00u53f7 centos]# cd /usr/local/Nginx/
  2. [root@jdu4e00u53f7 Nginx]# ls
  3. conf html logs sbin
  4. [root@jdu4e00u53f7 Nginx]# ./sbin/Nginx
  5. [root@jdu4e00u53f7 Nginx]# ps -ef | grep Nginx
  6. root 30325 1 0 23:47 ? 00:00:00 Nginx: master process ./sbin/Nginx
  7. nobody 30326 30325 0 23:47 ? 00:00:00 Nginx: worker process
  8. root 30328 14495 0 23:47 pts/1 00:00:00 grep --color=auto Nginx
  1. 当前工作路径为 /user/local/Nginx
  2. ./sbin/Nginx 启动 Nginx,默认端口为80
  3. 修改端口号可编辑 ./conf/Nginx.conf 中的"listen 80;",如可以修改"listen 8080;"
  4. 35 server {
  5. 36 listen 8080;
  6. 37 server_name localhost;
  7. 38
  8. 39 #charset koi8-r;
  9. 40
  10. 41 #access_log logs/host.access.log main;
  11. 42
  12. 43 location / {
  13. 44 root html;
  14. 45 index index.html index.htm;
  15. 46 }
  16. 保存退出后使用 "./sbin/Nginx -s reload" 重新加载配置文件

猜你在找的CentOS相关文章