是否可以配置xampp来提供htdocs目录之外的文件?
例如,假设我有一个文件的位置如下:
C: \ \ transitCalculator \树干\ TransitCalculator.php项目
我的xampp文件通常从:
C:\xampp\htdocs\
(因为这是默认配置)是否有一些方法让Apache识别和服务我的TransitCalculator.php文件,而不移动到htdocs下?最好我想Apache提供/有权访问项目目录的全部内容,我不想移动htdocs下的项目目录。
edit:编辑后将Apache添加到问题标题中,使Q/A更“可搜索”
好的,根据pix0r, Sparks和Dave的回答,看起来有三种方法可以做到这一点:
虚拟主机
Open C:\xampp\apache\conf\extra\httpd-vhosts.conf.
Un-comment ~line 19 (NameVirtualHost *:80).
Add your virtual host (~line 36):
<VirtualHost *:80>
DocumentRoot C:\Projects\transitCalculator\trunk
ServerName transitcalculator.localhost
<Directory C:\Projects\transitCalculator\trunk>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Open your hosts file (C:\Windows\System32\drivers\etc\hosts).
Add
127.0.0.1 transitcalculator.localhost #transitCalculator
to the end of the file (before the Spybot - Search & Destroy stuff if you have that installed).
Save (You might have to save it to the desktop, change the permissions on the old hosts file (right click > properties), and copy the new one into the directory over the old one (or rename the old one) if you are using Vista and have trouble).
Restart Apache.
现在您可以通过浏览http://transitcalculator.localhost/访问该目录。
制作别名
Starting ~line 200 of your http.conf file, copy everything between <Directory "C:/xampp/htdocs"> and </Directory> (~line 232) and paste it immediately below with C:/xampp/htdocs replaced with your desired directory (in this case C:/Projects) to give your server the correct permissions for the new directory.
Find the <IfModule alias_module></IfModule> section (~line 300) and add
Alias /transitCalculator "C:/Projects/transitCalculator/trunk"
(or whatever is relevant to your desires) below the Alias comment block, inside the module tags.
更改文档根目录
在C:\xampp\apache\conf\httpd.conf中编辑~第176行;更改DocumentRoot“C:/xampp/htdocs”为#DocumentRoot“C:/Projects”(或任何你想要的)。
编辑~ 203行以匹配新位置(在本例中是C:/Projects)。
注:
你必须使用前斜杠“/”而不是后斜杠“\”。
不要包括结尾的“/”。
重新启动服务器。