一. 首先 修改 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;
}
轉載于:https://www.cnblogs.com/luhouxiang/p/7702402.html