centos6.x yum默认没有nginx的软件包
安装方式:
到nginx下载页面http://nginx.org/en/linux_packages.html#stable,复制CENTOS 6的nginx软件源安装包
运行命令:wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
安装rpm包 yum install nginx-release-centos-6-0.el6.ngx.noarch.rpm -y , 此步实际只是加入了nginx的软件包源
执行 yum install nginx -y 就可以安装好nginx了

nginx默认安装为linux的服务
使用service nginx start, stop, restart, try-restart, reload, force-reload, status来操作nginx

nginx的配置文件默认读取/etc/nginx/nginx.conf文件
nginx的配置都是由 directives组成,directives由简单指令或者区块指令组成
简单指令:listen 80;
区块指令由{}包含,区块指令又可以包含多个简单指令和区块指令:

http {
    server {
    }
}
登录后复制

http可以有多个server,多个server可以监听多个端口在同一服务器为多个应用提供服务。
但如果你同时有多个域名www.you.com,news.you.com, mail.you.com在同一个服务器进行服务,那么www.you.com,mail.you.com:8080, news.you.com:81这样的访问方式显然是不合适显然是不合适的,幸运的是nginx已经提供了通过域名过滤的规则

server
{
    listen 80;
    server_name www.you.com;
    location / {
        #....
        proxy_pass http://localhost:8880;
    }
    ##### other directive
}

server
{
    listen 80;
    server_name news.you.com;
    location / {
        #....
        proxy_pass http://localhost:8881;
    }
    ##### other directive
}

server
{
    listen 80;
    server_name mail.you.com;
    location / {
        #....
        proxy_pass http://localhost:8882;
    }
    ##### other directive
}
登录后复制

最终分别运行各个应用监听对应端口即可。

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

    以上就介绍了 nginx的安装及基本配置,及多个域名服务,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

  • 09-06 09:47