一. 首先 修改 C:\Windows\System32\drivers\etc\hosts 文件 加一行
127.0.0.1 www.tpshop.com // 這里可以改成你想要的域名
二. 修改你的 apache的 httpd-conf 文件 加入如下代碼
<VirtualHost *:80>DocumentRoot "D:\wamp\www\tpshop" // 這里換成你TPshop 解壓的目錄ServerName www.tpshop.com // 這里改成你上面對應的域名ServerAlias 127.0.0.1</VirtualHost>
三 重啟你的 apache 瀏覽器輸入 www.tpshop.com? 測試,

對於nginx 安裝用戶,?? 如果你是在 http://lnmp.org/? 安裝的用戶, 並且嚴格按照 http://lnmp.org/ 官網上要求安裝的, 那么恭喜你, 這里配置起來非常容易,? 因為虛擬主機配置文件:/usr/local/nginx/conf/vhost/域名.conf?? 你只需要將 TPshop 根目錄下的 nginx.conf2 文件內代碼 復制到 替換你的? /usr/local/nginx/conf/vhost/域名.conf 內容, 然后把里面的域名?? "www.tp-shop.cn" 換成你的 域名, 路徑換成你的路徑 重啟 nginx 即可,? 具體說明? nginx.conf2 文件內 注釋寫的很詳細.
tpshop根目錄下的 nginx.conf2 文件? 此配置文件由PHP大牛 QQ名為 "木偶人" 提供.
如果你的 nginx 不是用? http://lnmp.org/ 安裝的也沒關系, 參考這個 nginx.conf2文件配置一下 即可.
server{listen 80;#listen [::]:80;server_name www.tp-shop.cn;index index.html index.htm index.php default.html default.htm default.php;root /home/wwwroot/www.tp-shop.cn;location / {index index.htm index.html index.php;if (!-e $request_filename){#地址作為將參數rewrite到index.php上。tp框架接收s參數為controller和action,不少框架都利用這種方式來實現偽pathinfo模式(pathinfo為php功能,nginx並不支持)rewrite ^/(.*)$ /index.php?s=$1 last;break;}}#上面的正則能解決不帶xx.php的,這條正則是為了rewrite url中帶index.php/admin/admin/login這種,思路是一樣的,將index.php后的字符串當成參數location ~ /.*\.php/ {rewrite ^(.*?/?)(.*\.php)(.*)$ /$2?s=$3 last;break;}location ~ \.php/?.*$ {root /home/wwwroot/www.tp-shop.cn;fastcgi_pass unix:/tmp/php-cgi.sock;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;#set $path_info "";#定義變量 $real_script_name,用於存放真實地址#set $real_script_name $fastcgi_script_name;#如果地址與引號內的正則表達式匹配#if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {#將文件地址賦值給變量 $real_script_name#set $real_script_name $1;#將文件地址后的參數賦值給變量 $path_info#set $path_info $2;#}#配置fastcgi的一些參數#fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;#fastcgi_param SCRIPT_NAME $real_script_name;#fastcgi_param PATH_INFO $path_info;}location ~.*\.(jpg|png|jpeg)${root /home/wwwroot/www.tp-shop.cn;#expires 30d;}# js css緩存一小時location ~.*\.(js|css)$ {root /home/wwwroot/www.tp-shop.cn;#expires 1h;}include other.conf;#error_page 404 /404.html;include enable-php.conf;location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires 30d;}location ~ .*\.(js|css)?${expires 12h;}location ~ /\.{deny all;}error_log /home/wwwlogs/www.tp-shop.cn.err;access_log /home/wwwlogs/www.tp-shop.cn.log;}
