apache和nginx配置

在注册完域名后,怎么配置apache和nginx呢?

一、配置example.com的apache

<VirtualHost *:80>
    ServerAdmin email@email.com
    DocumentRoot "/usr/local/apache/docs/i/"
    DirectoryIndex index.html index.php
    ServerName example.com
    ErrorLog "logs/example.com-error_log"
    CustomLog "logs/example.com-access_log" common
</VirtualHost>

二、配置nginx

server {
       listen      80;
       server_name  examle.com;
       access_log /usr/local/nginx/logs/examle.com.log;
       location /        {
           proxy_pass  http://127.0.0.1:88;
           proxy_set_header Accept-Encoding 'gzip';
           proxy_set_header   Host   $host;
           proxy_set_header   X-Real-IP        $remote_addr;
           proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
           proxy_hide_header X-Powered-By;
           client_max_body_size 10M;
       }
}

三、搭建CI框架测试环境

<VirtualHost *:88>
    ServerName m.example.com
    ServerAlias *.m.example.com

    DocumentRoot /usr/local/path

    ErrorLog logs/m.example.com-error_log
    CustomLog "|/usr/local/sbin/cronolog /usr/local/path/m.example.com-access.%m%d" combined

    SetEnv CI_ENV development

    RewriteEngine On
    RewriteCond %{HTTP_HOST} [\w_]+.m.example.com
    RewriteCond %{REQUEST_URI} !static.*
    RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
    RewriteRule ([\w_]+).m.example.com(.*) /$1/webroot/index.php/$2 [L]

    RewriteCond %{HTTP_HOST} [\w_]+.m.example.com
    RewriteCond %{REQUEST_URI} static.*
    RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
    RewriteRule ([\w_]+).m.example.com(.*) /$1/webroot/$2 [L]

    <Directory "/usr/local/path">
        Options FollowSymLinks
        AllowOverride all
        order allow,deny
        allow from all
    </Directory>
</VirtualHost>
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 撸撸猫 设计师:C马雯娟 返回首页