apache和nginx虚拟主机配置文件示例

2017/2/28 posted in  Apache/Nginx

apache虚拟主机配置文件示例

<VirtualHost *:80>
 ServerName  test.com
 DocumentRoot  "d:\www\test"  
 DirectoryIndex   index.php
 <Directory "d:\www\qlmall">
     Options +FollowSymLinks
     Order Allow,Deny
     allow from all
     AllowOverride All
 </Directory>
</VirtualHost>

nginx配置文件示例

server {
    server_name test.com;
    listen 80;
    root /data/webroot/test;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
            index index.php index.html index.htm;
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
            fastcgi_pass 127.0.0.1:9000;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }

    error_log /var/log/nginx/test.com.error.log;
    access_log /var/log/nginx/test.com.access.log;
}