玉兰养生馆 發表於 2020-4-1 19:30:00

XAMPP 设置域名

<p>&nbsp;</p>
<p>找到XAMPP安装目录,</p>
<p>F:\xampp\apache\conf\extra\httpd-vhosts.conf</p>
<p>添加一段配置</p>
<div class="cnblogs_code">
<pre>&lt;VirtualHost *:端口&gt;<span style="color: rgba(0, 0, 0, 1)">
    ServerAdmin webmaster</span>@<span style="color: rgba(0, 0, 0, 1)">你的域名
    DocumentRoot </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">F:/xampp/htdocs/你的域名</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
    ServerName 你的域名
    ServerAlias 你的域名
    ErrorLog </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">logs/你的域名-error.log</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
    CustomLog </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">logs/你的域名-access.log</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)"> common
&lt;</span>/VirtualHost&gt;</pre>
</div>
<p><span style="color: rgba(255, 0, 0, 1)">注意:把网站放到 "F:/xampp/htdocs/你的域名"&nbsp; 下,之前放在"F:/xampp/htdocs/"下导到报错“找不到对象!”,一直找不到原因。后来在百度看到了</span></p>
<p>https://zhidao.baidu.com/question/1048485850522142779.html</p>
<div class="cnblogs_code"><img id="code_img_closed_582f3de3-d2cc-45fc-ba5c-bcbbe16f0744" class="code_img_closed lazyload" alt="" data-src="http://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif"><img id="code_img_opened_582f3de3-d2cc-45fc-ba5c-bcbbe16f0744" class="code_img_opened lazyload" style="display: none" alt="" data-src="http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif">
<div id="cnblogs_code_open_582f3de3-d2cc-45fc-ba5c-bcbbe16f0744" class="cnblogs_code_hide">
<pre><span style="color: rgba(0, 0, 0, 1)">因素其实不多的:
</span>1<span style="color: rgba(0, 0, 0, 1)"> D:\xampp\apache\conf 在这个文件夹下 httpd.conf 这个配置文件你要确定没改过

其中的
ServerRoot </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">/xampp/apache</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
还有监听的80端口也是很重要的
如果你之前装过SQL 服务器他会占用的你的80端口,可以修改文件里面的80改成 (例如81)

</span>2<span style="color: rgba(0, 0, 0, 1)"> D:\xampp\apache\conf\extra 这里有个httpd.vhost文件也是一个重要的配置
&lt;VirtualHost </span>*:80&gt;<span style="color: rgba(0, 0, 0, 1)">
Options None
DocumentRoot D:\xampp\htdocs 确定这个下面 有Index.php 才能找到
ServerName 你配置的虚拟域名
DirectoryIndex index.php index.html index.htm
&lt;Directory </span>/&gt;<span style="color: rgba(0, 0, 0, 1)">
AllowOverride All
Order deny,allow
Allow from all
&lt;</span>/Directory&gt;<span style="color: rgba(0, 0, 0, 1)">
&lt;Directory </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">D:\xampp\htdocs\</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;<span style="color: rgba(0, 0, 0, 1)"> 确定这个下面 有Index.php 程序才能找到
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
&lt;</span>/Directory&gt;<span style="color: rgba(0, 0, 0, 1)">
&lt;</span>/VirtualHost&gt;

3,没有东西的话,试试在Localhost/<span style="color: rgba(0, 0, 0, 1)">你的控制器的名字
例如localhost</span>/<span style="color: rgba(0, 0, 0, 1)">message

万分不行,重装,然后在htdocs文件夹下,先删掉所有,再把你的东西放进去 </span></pre>
</div>
<span class="cnblogs_code_collapse">View Code</span></div>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/xiaoruilin/p/12615003.html
頁: [1]
查看完整版本: XAMPP 设置域名