1.cd /etc/apache2/sites-available/php
2.sudo gedit demo.conflinux
內容以下 <VirtualHost wechat_pay:80> DocumentRoot /home/lin/文檔/test/ ServerName wechat_pay:80 <Directory "/home/lin/文檔/test/"> Options Indexes FollowSymLinks AllowOverride All Require all granted AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>apache
3.禁用默認的虛擬主機配置 sudo a2dissite 000-default.confide
4.啓用新建的虛擬主機配置 sudo a2ensite demo.conf測試
5.根據提示進行從新加載 service apache2 reloadui
6.修改系統的hosts文件,將新設定的虛擬主機域名配置進去 sudo gedit /etc/hostshtm
127.0.0.1 wechat_pay文檔
7.到你指定的目錄下(/home/lin/文檔/test/)新建個test.phpget
8.進行瀏覽測試 訪問http://wechat_pay/test.php域名