標籤:
windows下配置
1.找到apache的設定檔,httpd.conf2.找到 LoadModule rewrite_module modules/mod_rewrite.so 去掉前邊的#3.找到 Include conf/extra/httpd-vhosts.conf 去掉前邊的#4.找 conf/extra/httpd-vhosts.conf 這個檔案5.加NameVirtualHost *:80<VirtualHost *:80> ServerAdmin [email protected] #管理郵箱 DocumentRoot "D:/phpStudy/WWW” #工作目錄,也就是代碼位置 ServerName www.excel.com #虛擬網域名稱 ErrorLog "logs/dummy-host2.example.com-error.log" //apache中的錯誤記錄檔 CustomLog "logs/dummy-host2.example.com-access.log" common</VirtualHost>6. 在httpd.conf中找<Directory "D:/phpStudy/WWW"> ----工作目錄 Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all ---------存取權限
Require all granted</Directory>7.在hosts中(windows目錄 C:\Windows\System32\drivers\etc)加127.0.0.1 www.excel.com #指向虛擬網域名稱8.重啟apache 訪問www目錄下的檔案可以看到效果 mac nginx配置虛擬機器主機1. 開啟 /usr/local/etc/nginx/nginx.conf 注意許可權,用sudo vi nginx.conf 開啟2. 在http中 最後加上 include vhosts/*.conf;如果有,請忽略,可以第三步了3. 在 /usr/local/etc/nginx/vhosts 目錄下,建立檔案,以.com.conf結束,比方說baidu.com.conf,此處命名自己最好以網域名稱命名,因為我們在這個目錄下可以配置很多個虛擬機器主機,一個檔案就是一個虛擬機器主機4.sudo vi xx.com.conf 5. 注意紅色的幾處地方就好了upstream baidu(和檔案名稱相同) { server 127.0.0.1:80; #自己的ip及連接埠 }
server { listen 80; charset utf-8; server_name www.baidu.com; #虛擬機器主機名 #access_log logs/apicloud-access.log ; #error_log logs/apicloud-error.log ; root /Users/www; #代碼存放目錄 if ( $http_cookie ~* "(.*)$")
{
set $meilishuo_cookie $1;
}
location / {
index index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php last;
}
}
try_files $uri /index.php?$args;
#location /index.php {
location ~* \.php$ {
fastcgi_pass apicloud;
fastcgi_next_upstream error timeout invalid_header http_500;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}} 6.配hosts,開啟 /etc/hosts,用命令sudo vi /etc/hosts7. 加上dns解析 127.0.0.1 www.baidu.com8.重啟nginx (sudo pkill -9 /usr/local/opt/nginx/bin 重啟命令 sudo nginx /usr/local/opt/nginx/bin)然後訪問對應目錄 /Users/www 下的php檔案就可以了
windows和mac下分別配置虛擬機器主機