安装Nginx

# 查看相关信息
yum info nginx

yum info httpd

# 移除 httpd,也就是 Apache
yum remove httpd -y

# 安装 nginx
yum install nginx -y

#设置 nginx 自启动
chkconfig nginx on

# 查看服务自启动情况
chkconfig
# 启动nginx服务
service nginx start

# 查看端口监听状态
netstat -ntl
# 此时你可以访问试试了
# 例如: http:/IP # 如果访问不了,请 ping 一下试试
# 或者查看 firewalld 防火墙状态
启动: systemctl start firewalld
查看状态: systemctl status firewalld
停止: systemctl disable firewalld
禁用: systemctl stop firewalld

centos7用的firewalld

firewalld默认已经安装并启用了,如果需要nginx可以访问需要执行以下命令:

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --zone=trusted --add-port=/tcp




PS:如果你是用的阿里云
请到安全组里面添加一个规则 设置可访问80端口 要不然是怎么都不会OK的

配置Nginx反向代理

/etc/nginx/nginx.conf

user              nginx;
worker_processes ; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events {
use epoll;
worker_connections ;
} http {
include /etc/nginx/mime.types;
default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout ;
keepalive_timeout ; gzip on; # Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/*.conf; include upstream.conf;
include cncounter.com.conf; }

做负载的配置: /etc/nginx/upstream.conf

upstream www.cncounter.com {
server 127.0.0.1:;
}

站点配置文件: /etc/nginx/cncounter.com.conf

server
{
listen ;
server_name www.cncounter.com;
index index.jsp;
root /usr/local/cncounter_webapp/cncounter/;
location ~ ^/NginxStatus/ {
stub_status on;
access_log off;
} location / {
root /usr/local/cncounter_webapp/cncounter/;
proxy_redirect off ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 50m;
client_body_buffer_size 256k;
proxy_connect_timeout ;
proxy_send_timeout ;
proxy_read_timeout ;
proxy_buffer_size 256k;
proxy_buffers 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
proxy_pass http://www.cncounter.com;
}
}

重启服务

service nginx stop

service nginx start
 

CentOS7.3下yum练手安装Nginx的更多相关文章

  1. CentOS7.3下yum练手安装Nginx,支持php5.4

    yum install php php-devel 安装的是5.4 那么安装完毕了,怎么设置nginx和php 解析 1 添加nginx 默认主页index.php  vim .../etc/ngin ...

  2. Centos7.3下mysql5.7.18安装并修改初始密码的方法

    Centos7.3下mysql5.7.18安装并修改初始密码的方法 原文链接:http://www.jb51.net/article/116032.htm 作者:Javen205 字体:[增加 减小] ...

  3. 原创:centos7.1下 ZooKeeper 集群安装配置+Python实战范例

    centos7.1下 ZooKeeper 集群安装配置+Python实战范例 下载:http://apache.fayea.com/zookeeper/zookeeper-3.4.9/zookeepe ...

  4. centos7.5下yum 安装mariadb数据库

    前言 mariadb 和mysql就像亲兄弟的关系,各种语法.驱动啥的,在mysql上能上的,在mariadb上基本都可以直接使用.更多的细节在此不多说. 1.删除旧版本 centos7下默认安装有m ...

  5. CentOS7 linux下yum安装mysql5.7

    文章参考(https://www.cnblogs.com/jorzy/p/8455519.html) 1.创建存放安装包的位置,并且进入该目录 命令mkdir /share 命令cd /share 2 ...

  6. CentOS7.3下yum安装MariaDB10.3.12并指定utf8字符集

    添加MariaDB的yum源,指定安装的版本,然后使用 yum 工具进行安装 参考MariaDB官方网站对应安装方法和步骤 https://downloads.mariadb.org/mariadb/ ...

  7. centos7.7下docker与k8s安装(DevOps三)

    1.系统配置 centos7.7 docker 1.13.1 centos7下安装docker:https://www.cnblogs.com/pu20065226/p/10536744.html 2 ...

  8. centos6.5 64练手安装memcached,PHP调试

    思路  先安装 memcached  然后安装php的基于扩展libmemcache ,然后安装php memcache扩展包,然后把扩展添加到php.ini 1 yum安装 简单方便 yum ins ...

  9. Linux系统 Centos7/Centos6.8 yum命令在线安装 MySQL5.6

    Linux系统 Centos7 yum命令在线安装 MySQL5.6 标签: centosmysqlyum 2015-11-18 17:21 707人阅读 评论(0) 收藏 举报  分类: Linux ...

随机推荐

  1. 51Nod:1265 四点共面

    计算几何 修改隐藏话题 1265 四点共面  基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题  收藏  关注 给出三维空间上的四个点(点与点的位置均不相同),判断这4个点 ...

  2. (3)socket的基础使用(基于UDP协议)

    服务端代码 import socket server =socket.socket(socket.AF_INET,socket.SOCK_DGRAM) #SOCK_DGRAM就是数据报,UDP就是数据 ...

  3. HDU3584 Cube

    分析 三维树状数组,跟二维的差不多,只不过容斥的不一样. 更新区间\((x_1,y_1,z_1)\rightarrow(x_2,y_2,z_2)\)时,需要利用容斥原理.须要更新的节点更新如下: \[ ...

  4. WIFI学习笔记

    1.关掉网卡:sudo ifconfig eth0 down $ ifconfig -a显示出所有的网卡,down的也可以显示出来,而$ ifconfig只能显示up状态的网卡,最好先停掉网络服务再开 ...

  5. vertx.io 与nodejs 一个简单的性能比较

    vertx.io 与node 都是可以进行js运行的一个引擎,但是vertx 支持的语言相对于node 多,可以查看官网.今天下网上查询相关的信息 时来了解到vertx.io 性能比node 好,于是 ...

  6. 【转】Linux的五个查找命令:find,locate,whereis,which,type

    原文网址:http://www.ruanyifeng.com/blog/2009/10/5_ways_to_search_for_files_using_the_terminal.html 最近,我在 ...

  7. C#代码规范和质量检查工具

    代码风格检查:StyleCop The StyleCop tool provides warnings that indicate style and consistency rule violati ...

  8. C++将整型数据转换成大端或小端存储顺序

    大端和小端的概念参考之前博客: 大端/小端,高字节/低字节,高地址/低地址,移位运算 昨晚帮导师从指令中恢复图像的时候,导师要我转换成raw格式,也就是记录图像像素的二进制序列,然后反复强调让我注意大 ...

  9. 在Windows下安装Linux

    使用工具:EasyBCD,该工具支持xp/win7. 安装EasyBCD后新建一个grub启动项: 将Linux ISO文件复制到一个干净的fat分区: 将ISO中的isolinux和images目录 ...

  10. bzoj1033 杀蚂蚁

    假设游戏中的蚂蚁也是按这个规则选择路线: 1.每一秒钟开始的时候,蚂蚁都在平面中的某个整点上.如果蚂蚁没有扛着蛋糕,它会在该点留下2单位的信息素,否则它会留下5单位的信息素.然后蚂蚁会在正北.正南.正 ...