php XAMPP,使用端口:81,无法运行 localhost:81/mywebsite

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30554970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 21:53:03  来源:igfitidea点击:

XAMPP, using port:81, cannot run localhost:81/mywebsite

phpwordpressapacheport80

提问by Hieu Do

XAMPP's default port:80 is occupied by System.exe, so I have to switch to port:81, as this question suggested XAMPP PORT 80 is Busy / EasyPHP error in Apache configuration file:

XAMPP 的默认端口:80 被 System.exe 占用,所以我必须切换到端口:81,因为这个问题建议XAMPP PORT 80 is Busy / EasyPHP 错误在 Apache 配置文件中:

After this change, I can access localhost:81/xampp and localhost:81/phpMyAdmin , as well as local files, like localhost:81/wordpress/Readme.html

更改后,我可以访问 localhost:81/xampp 和 localhost:81/phpMyAdmin ,以及本地文件,如 localhost:81/wordpress/Readme.html

However, I can not load other local directories in htdocs, can not install new wordpress site on my computer, and localhost:81/wordpress is auto referred back to localhost/wordpress , which is NOT FOUND

但是,我无法在 htdocs 中加载其他本地目录,无法在我的计算机上安装新的 wordpress 站点,并且 localhost:81/wordpress 被自动引用回 localhost/wordpress ,这是 NOT FOUND

Here's a list of what I tried and failed

这是我尝试和失败的列表

  1. Change all localhost options to locahost:81, in C:\xampp\apache\conf\http.conf , in C:\xampp\xampp-control.ini , in MySQL Database, Database Tables, root User, in wordpress wp-config-sample.php , wp-config.php

  2. I load localhost:81\wordpress in Chrome and it is auto referred back to localhost\wordpress , the result is NOT FOUND.

  1. 将所有本地主机选项更改为 locahost:81,在 C:\xampp\apache\conf\http.conf ,在 C:\xampp\xampp-control.ini ,在 MySQL 数据库,数据库表,root 用户,在 wordpress wp-config -sample.php , wp-config.php

  2. 我在 Chrome 中加载 localhost:81\wordpress 并且它被自动引用回 localhost\wordpress ,结果没有找到。

So I can not access to localhost:81/mywebsite because it is auto referred to the old localhost , and can not stop System.exe from using port:80. I searched almost every where, but the only solution I found is a mistyped mistake in wp-config.php - that is NOT my problem.

所以我无法访问 localhost:81/mywebsite 因为它自动引用了旧的 localhost ,并且无法阻止 System.exe 使用端口:80。我几乎搜索了所有地方,但我发现的唯一解决方案是 wp-config.php 中的输入错误 - 这不是我的问题。

Plese help.

请帮忙。

采纳答案by Hieu Do

I uninstalled ISS , uninstalled XAMPP and reinstall XAMPP again, and it worked with port:80 as default. Thank you all. About the service that occupied port:80, it is answered in this question: windows 8 NT Kernel and System using port 80

我卸载了 ISS ,卸载了 XAMPP 并再次重新安装了 XAMPP,它默认使用端口:80。谢谢你们。关于占用端口:80的服务,在这个问题中回答:windows 8 NT Kernel and System using port 80

回答by Harikrishnan

Try specifying port number in virtual host configuration. Hence you can avoid typing port number in url. Add these lines to C:/xampp/apache/config/extra/httpd-vhosts.conf

尝试在虚拟主机配置中指定端口号。因此,您可以避免在 url 中输入端口号。将这些行添加到C:/xampp/apache/config/extra/httpd-vhosts.conf

NameVirtualHost *:81
    <VirtualHost *:81>
        ServerName test.com
        DocumentRoot "C:/xampp/htdocs"

        <Directory "C:/xampp/htdocs">
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>

Edit C:\Windows\System32\drivers\etc\hosts and Add

编辑 C:\Windows\System32\drivers\etc\hosts 并添加

127.0.0.1    test.com

at the end of file. Restart apache. clear browser cache and just point to test.com.

在文件末尾。重启阿帕奇。清除浏览器缓存并指向 test.com。

回答by Vivek Bhat

So, the best solution like EL.Web.ID and Geethika says, is to reconfigure the XAMPP Apache server to listen and use different port numbers. Here is how you do it:

因此,像 EL.Web.ID 和 Geethika 所说的最佳解决方案是重新配置 XAMPP Apache 服务器以侦听和使用不同的端口号。这是你如何做到的:

1) First, you need to open the Apache “httpd.conf” file and configure it to use/listen on a new port no.'

1) 首先,您需要打开 Apache“httpd.conf”文件并将其配置为在新端口号上使用/侦听。

Setup Xampp Apache

设置 Xampp Apache

To open httpd.conf file, click the “Config” button next to Apache “Start” and “Admin” buttons. In the popup menu that opens, click and open httpd.conf

要打开 httpd.conf 文件,请单击 Apache“开始”和“管理”按钮旁边的“配置”按钮。在打开的弹出菜单中,单击并打开 httpd.conf

2) Within the httpd.conf file search for “listen”. You'll find two rows with something like;

2) 在 httpd.conf 文件中搜索“listen”。你会发现两行类似的东西;

Listen 12.34.56.78:80

听 12.34.56.78:80

Listen 80

听 80

Change the port no to a port no. of your choice (e.g. port 1234) like below

将端口号更改为端口号。您选择的(例如端口 1234)如下所示

Listen 12.34.56.78:1234

听 12.34.56.78:1234

Listen 1234

听 1234

3) Next, in the same httpd.conf file look for “ServerName localhost:” Set it to the new port no.

3) 接下来,在同一个 httpd.conf 文件中查找“ServerName localhost:”,将其设置为新的端口号。

ServerName localhost:1234

服务器名称本地主机:1234

4) Save and close the httpd.conf file.

4) 保存并关闭httpd.conf 文件。

5) Now click the Apache config button again and open the “httpd-ssl.conf” file.

5) 现在再次单击 Apache 配置按钮并打开“httpd-ssl.conf”文件。

6) In the httpd-ssl.conf file, look for “Listen” again. You may find:

6) 在 httpd-ssl.conf 文件中,再次查找“Listen”。你可能会发现:

Listen 443

第 443 章

Change it to listen on a new port no of your choice. Say like:

将其更改为侦听您选择的新端口。像这样说:

Listen 1443

听 1443

7) In the same httpd-ssl.conf file find another line that says, “”. Change this to your new port no. (like 1443)

7) 在同一个 httpd-ssl.conf 文件中找到另一行写着“”。将此更改为您的新端口号。(如 1443)

7) Also in the same httpd-ssl.conf you can find another line defining the port no. For that look for “ServerName”. you might find something like:

7) 同样在同一 httpd-ssl.conf 中,您可以找到定义端口号的另一行。为此,请查找“ServerName”。你可能会发现类似的东西:

ServerName www.example.com:443 or ServerName localhost:433

ServerName www.example.com:443 或 ServerName localhost:433

Change this ServerName to your new port no.

将此 ServerName 更改为您的新端口号。

8) Save and close the httpd-ssl.conf file.

8) 保存并关闭 httpd-ssl.conf 文件。

9) Finally, there's just one more place you should change the port no. For that, click and open the “Config” button of your XAMPP Control Panel. Then click the, “Service and Port Settings” button. Within it, click the “Apache” tab and enter and save the new port nos in the “main port” and “SSL port” boxes. Click save and close the config boxes.

9)最后,还有一个地方你应该改变端口号。为此,单击并打开 XAMPP 控制面板的“配置”按钮。然后单击“服务和端口设置”​​按钮。在其中,单击“Apache”选项卡,然后在“主端口”和“SSL 端口”框中输入并保存新端口号。单击保存并关闭配置框。

That should do the trick. Now “Start” Apache and if everything goes well, your Apache server should start up.

这应该够了吧。现在“启动”Apache,如果一切顺利,您的 Apache 服务器应该会启动。

You will also see the Apache Port/s no in the XAMPP control panel has change to the new port IDs you set

您还将看到 XAMPP 控制面板中的 Apache Port/s no 已更改为您设置的新端口 ID

Write on URL Like localhost:1234 then eter it....

写在 URL 像 localhost:1234 然后等它......