var*_*ius 60 php apache xampp webserver
Web目录是所有应用程序的公共和静态文件的主页.包括图像,样式表和JavaScript文件.它也是前端控制器所在的位置.
所以问题是当我安装和设置xampp我的web目录是:
xampp\htdocs
Run Code Online (Sandbox Code Playgroud)
我想为它设置:
xampp\htdocs\myproject\web
Run Code Online (Sandbox Code Playgroud)
怎么做?现在当我在浏览器中输入地址时:http://localhost/
我输入xampp\htdocs目录
,我想在浏览器中键入地址:http://localhost/
并输入xampp\htdocs\myproject\web目录
小智 95
您可以通过单击(在xampp控制面板中)更改Apaches httpd.conf apache/conf/httpd.conf并调整条目DocumentRoot和相应的Directory条目.只需Ctrl+ F"htdocs"并将条目更改为新路径.
LAL*_*NAL 29
现在找到标签并将其更改为<Directory"C:/ xampp/htdocs/myproject/web">
重启你的Apache
小智 10
我将我的 htdocs 文件夹从 C:\xampp\htdocs 移动到 D:\htdocs 而不编辑 Apache 配置文件 (httpd.conf)。
步骤 1) 将C:\xampp\htdocs文件夹移动到D:\htdocs
步骤 2) 使用 mklink 命令在 C:\xampp\htdocs 中创建链接到 D:\htdocs 的符号链接。
D:\>mklink /J C:\xampp\htdocs D:\htdocs
Junction created for C:\xampp\htdocs <<===>> D:\htdocs
D:\>
Run Code Online (Sandbox Code Playgroud)
第 3 步)完成!
小智 10
如果有人喜欢更简单的解决方案,特别是在Linux(例如Ubuntu)上,一个非常简单的方法是创建一个指向htdocs文件夹中目标文件夹的符号链接.例如,如果我希望能够从名为"/ home/some/projects/testserver /"的文件夹中提供文件,而我的htdocs位于"/ opt/lampp/htdocs /"中.只需像这样创建一个符号链接:
ln -s /home/some/projects/testserver /opt/lampp/htdocs/testserver
Run Code Online (Sandbox Code Playgroud)
符号链接的命令如下所示:
ln -s target source
where,
target - The existing file/directory you would like to link TO.
source - The file/folder to be created, copying the contents of the target. The LINK itself.
Run Code Online (Sandbox Code Playgroud)
有关更多帮助,请参阅ln --help来源:在Ubuntu中创建符号链接
这就完成了.只需访问http:// localhost/testserver / 实际上,您甚至不需要重新启动服务器.
您还可以在
c:\xampp\apache\conf\httpd-vhosts.conf
喜欢:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:/xampp/htdocs/myproject/web"
ServerName localhost
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)