Centos 安装 Nginx 详细过程

系统 Centos 64位

第一步,首先下载Nginx的tar包及安装依赖的工具tar包。

Nginx: http://nginx.org/en/download.html

Nginx需要依赖下面3个包 
gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ ) 
rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/ ) 
ssl 功能需要 openssl 库 ( 下载: http://www.openssl.org/ )

分别解压。 
具体命令:

wget http://nginx.org/download/nginx-1.13.2.tar.gz wget http://www.zlib.net/zlib-1.2.11.tar.gz wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz wget https://www.openssl.org/source/openssl-fips-2.0.16.tar.gz tar zxvf openssl-fips-2.0.16.tar.gz tar zxvf nginx-1.13.2.tar.gz tar zxvf zlib-1.2.11.tar.gz tar zxvf pcre-8.40.tar.gz 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

第二步 编译安装

安装顺序:先安装三个依赖包再安装nginx

cd 到各个解压目录下运行
./configure && make && make install
  • 1
  • 2

安装c++编译环境

yum install gcc-c++
  • 1

第三步 运行nginx

安装好的nginx路径在:

/usr/local/nginx
  • 1
  • 2

默认的配置文件的路径在:

/usr/local/nginx/conf/nginx.conf
  • 1

运行nginx:

/usr/local/nginx/sbin/nginx
  • 1

通过浏览器访问服务器ip,出现以下标志就是启动成功了:

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required. For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com. Thank you for using nginx.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

有问题之处烦请在留言中指出,非常感谢。

猜你喜欢

转载自www.cnblogs.com/wangluochong/p/8951756.html