CentOS7 yum 安装 Nginx最新版本

来源:互联网 发布:淘宝快速提升信誉 编辑:程序博客网 时间:2024/05/17 05:06
下载对应当前系统版本的nginx包(package)
# wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm


建立nginx的yum仓库
# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm


下载并安装nginx
# yum install nginx


启动nginx服务
systemctl start nginx


配置
默认的配置文件在 /etc/nginx 路径下,使用该配置已经可以正确地运行nginx;如需要自定义,修改其下的 nginx.conf 等文件即可。


测试

在浏览器地址栏中输入部署nginx环境的机器的IP,如果一切正常,应该能看到如下字样的内容。


user  nginx;worker_processes  1;error_log  /var/log/nginx/error.log warn;pid        /var/run/nginx.pid;events {    worker_connections  1024;}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  65;    #gzip  on;    #include /etc/nginx/conf.d/*.conf; #设定负载均衡服务器列表    upstream group1{        #后端服务器访问规则        #ip_hash;        #weight参数表示权重值,权值越高被分配到的几率越大#PC_Local        server 192.168.187.133:80 weight=5;        #PC_Server        server 192.168.187.134:80 weight=5;                    }server {listen       81;#设置对外端口server_name  192.168.187.133 ; #设置识别请求域名location / {#定义服务器的默认网站根目录位置            #root html;            #定义首页索引文件的名称            #index index.html index.htm index.php;proxy_pass  http://group1 ;#分流到group1集群}    }}


1 0
原创粉丝点击