Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

WebServer 閰嶇疆

涓轰簡浣跨敤PhpBoot锛屼綘闇瑕侀厤缃 WebServer锛屽皢鎵鏈夊姩鎬佽姹傛寚鍚 index.php

1. Nginx

鑻ヤ娇鐢 Nginx 锛屼慨鏀逛綘鐨勯」鐩搴旂殑閰嶇疆锛

server {
    listen 80;
    server_name example.com;
    index index.php;
    error_log /path/to/example.error.log;
    access_log /path/to/example.access.log;
    root /path/to/public;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ \.php {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        fastcgi_pass 127.0.0.1:9000;
    }
}

2. Apache

Apache 鐨勯厤缃◢寰鏉傦紝棣栧厛浣犻渶瑕佸惎 mod_rewrite 妯″潡锛岀劧鍚庡湪 index.php 鐩綍涓嬫坊鍔 .htaccess 鏂囦欢锛

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

鍙﹀杩橀渶瑕佷慨鏀硅櫄鎷熶富鏈虹殑AllowOverride閰嶇疆

AllowOverride All

娉ㄦ剰锛氱敱浜 WebServer 鐗堟湰鐨勫樊寮傦紝 浠ヤ笂閰嶇疆鍙兘涓嶈兘鎸夐鏈熷伐浣滐紝浣嗚繖鏄娇鐢ㄥ鏁 PHP 妗嗘灦绗竴姝ラ渶瑕佽В鍐崇殑闂锛 缃戜笂鏈変細鏈夊緢澶氳В鍐虫柟妗堬紝鐢ㄥソ鎼滅储寮曟搸鍗冲彲