码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS6.8安装Nginx

时间:2020-03-22 17:33:27      阅读:67      评论:0      收藏:0      [点我收藏+]

标签:not   tab   inf   input   alt   mit   filter   recommend   top   

一、安装编译工具及库文件

[root@centos ~]# yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

二、首先要安装PCRE

PCRE 作用是让 Nginx 支持 Rewrite 功能。

下载、解压、编译安装、查看版本

 [root@centos ~]# cd /usr/local/src/
 [root@centos src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.44/pcre-8.44.tar.gz
 [root@centos src]# tar -zxvf pcre-8.44.tar.gz 
 [root@centos src]# cd pcre-8.44
 [root@centos pcre-8.44]# ./configure
 [root@centos pcre-8.44]# make && make install
 [root@centos pcre-8.44]# pcre-config --version
 8.44

三、安装Nginx

下载、解压、编译安装、查看版本、启动、访问

 [root@centos src]# cd /usr/local/src/
 [root@centos src]# wget http://nginx.org/download/nginx-1.14.2.tar.gz
 [root@centos src]# tar -zxvf nginx-1.14.2.tar.gz
 [root@centos src]# cd nginx-1.14.2
 [root@centos nginx-1.14.2]# ./configure --with-pcre=/usr/local/src/pcre-8.44
 [root@centos nginx-1.14.2]# make && make install
 [root@centos nginx-1.14.2]# cd /usr/local/nginx
 [root@centos nginx]# ./sbin/nginx -v
 nginx version: nginx/1.14.2
 [root@centos nginx]# ./sbin/nginx
 [root@centos nginx]# ps -ef|grep nginx
 root       2291      1  0 17:04 ?        00:00:00 nginx: master process ./sbin/nginx
 nobody     2292   2291  0 17:04 ?        00:00:00 nginx: worker process
 root       2294   2266  0 17:04 pts/0    00:00:00 grep nginx

此时,输入ip:端口可以访问,访问之前要配置防火墙,开发80端口

 [root@centos nginx]# vim /etc/sysconfig/iptables
 # Firewall configuration written by system-config-firewall
 # Manual customization of this file is not recommended.
 *filter
 :INPUT ACCEPT [0:0]
 :FORWARD ACCEPT [0:0]
 :OUTPUT ACCEPT [0:0]
 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
 -A INPUT -p icmp -j ACCEPT
 -A INPUT -i lo -j ACCEPT
 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
 -A INPUT -j REJECT --reject-with icmp-host-prohibited
 -A FORWARD -j REJECT --reject-with icmp-host-prohibited
 COMMIT
 [root@centos sbin]# service iptables restart

 技术图片技术图片

参考文档:https://www.runoob.com/linux/nginx-install-setup.html

CentOS6.8安装Nginx

标签:not   tab   inf   input   alt   mit   filter   recommend   top   

原文地址:https://www.cnblogs.com/ddstudy/p/12547056.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!