centos6.8 安装nginx

14次阅读

共计 662 个字符,预计需要花费 2 分钟才能阅读完成。

centos6.8 安装 nginx 需要编译 nginx 源码,不过没啥大不了的,按照步骤来,肯定能成功。1. 安装必要的依赖:
yum install -y gcc-c++

yum install -y pcre pcre-devel

yum install -y zlib zlib-devel

yum install -y openssl openssl-devel

2. 下载 nginx 源码并编译:nginx 下载地址可以取官网找。我这是当前的最新版,1.13.
wget http://nginx.org/download/nginx-1.13.5.tar.gz

tar zxvf nginx-1.13.5.tar.gz

cd nginx-1.13.5

./configure –prefix=/usr/local/nginx –with-http_ssl_module –with-http_stub_status_module –with-pcre

make && make install
iptables -F(不然无法远程访问)

3. 编译完成后,我们去启动 nginx 通过命令 whereis nginx , 查看 nginx 的安装目录,可以看到路径是 nginx: /usr/local/nginx 然后 cd /usr/local/nginx/sbin 执行命令 ./nginx 这样就把 nginx 启动起来了。然后在浏览器里直接访问 localhost, 或者访问你的服务器 ip。就可以看到 nginx 的欢迎页了。关闭 nginx,执行命令 ./nginx -s stop 重启 nginx,执行命令 ./nginx -s reload

正文完
 0