如何更改 XAMPP apache 服务器端口? [英] How to change XAMPP apache server port?

查看:43
本文介绍了如何更改 XAMPP apache 服务器端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 Apache httpd.conf 设置:

听8012服务器名称本地主机:8012

每次我通过 XAMPP 启动 Apache 时,我都会看到这条消息:

状态检查OK忙碌的…Apache 启动 [端口 80]

任何人,请帮我更改任何其他设置吗?

解决方案

回答原问题:

要在此处更改 XAMPP 以检查它是否有效.

如果没有,您必须编辑 http-ssl.conf 文件,如下面的步骤 3 所述.↓

3.编辑文件http-ssl.conf"

<块引用>

这个文件应该在Windows上的C:\xampp\apache\conf\extra中找到,或者查看这个链接 Linux.

找到以下几行:

听443<VirtualHost _default_:443>服务器名称本地主机:443

将它们替换为其他端口号(在本例中为 8013):

听8013<VirtualHost _default_:8013>服务器名称 本地主机:8013

保存文件.

重启 Apache 服务器.

访问:http://localhost:8012 以检查它是否有效.

4.配置 XAMPP Apache 服务器设置

如果您想访问 localhost 而无需在 URL 中指定端口号
http://localhost 而不是 http://localhost:8012.

  • 打开Xampp 控制面板
  • 转到配置服务和端口设置Apache
  • Main PortSSL Port 值替换为选择的值(例如80128013).
  • 保存服务设置
  • 保存控制面板的配置
  • 重启 Apache 服务器现在应该可以使用了.

4.1.网络浏览器配置

如果此配置未在 URL 中隐藏端口号,那是因为您的网络浏览器未配置.请参阅:工具 ► 选项 ► 常规 ► 连接设置... 将允许您选择不同的端口或更改代理设置.

4.2.对于极少数的极端厄运

如果第 4 步和 Web 浏览器配置对您不起作用,唯一的方法是更改​​回 80,或者在端口 80(如代理)上安装一个侦听器,将您的所有流量重定向到端口 8012.

回答您的问题:

如果您在控制面板控制台中仍然有此消息:

<块引用>

Apache 启动 [端口 80]

  • 找到xampp-control.exe文件的位置(可能在C:\xampp)
  • 在该目录下创建一个文件XAMPP.INI(所以XAMPP.inixampp-control.exe 在同一目录中)

XAMPP.INI 文件中加入以下几行:

[端口]阿帕奇 = 8012

现在,你将永远得到:

<块引用>

Apache 启动 [端口 8012]

请注意,这仅用于显示目的.它与您的 httpd.conf 无关.

This is my Apache httpd.conf settings :

Listen 8012
ServerName localhost:8012

Every time I start Apache via XAMPP I see this message:

Status Check OK
Busy…
Apache Started [Port 80]

Anybody, please help me can I change any other settings ?

解决方案

To answer the original question:

To change the XAMPP Apache server port here the procedure :

1. Choose a free port number

The default port used by Apache is 80.

Take a look to all your used ports with Netstat (integrated to XAMPP Control Panel).

Then you can see all used ports and here we see that the 80port is already used by System.

Choose a free port number (8012, for this exemple).

2. Edit the file "httpd.conf"

This file should be found in C:\xampp\apache\conf on Windows or in bin/apache for Linux.:

Listen 80
ServerName localhost:80

Replace them by:

Listen 8012
ServerName localhost:8012

Save the file.

Access to : http://localhost:8012 for check if it's work.

If not, you must to edit the http-ssl.conf file as explain in step 3 below. ↓

3. Edit the file "http-ssl.conf"

This file should be found in C:\xampp\apache\conf\extra on Windows or see this link for Linux.

Locate the following lines:

Listen 443
<VirtualHost _default_:443>
ServerName localhost:443

Replace them by with a other port number (8013 for this example) :

Listen 8013
<VirtualHost _default_:8013>
ServerName localhost:8013

Save the file.

Restart the Apache Server.

Access to : http://localhost:8012 for check if it's work.

4. Configure XAMPP Apache server settings

If your want to access localhost without specify the port number in the URL
http://localhost instead of http://localhost:8012.

  • Open Xampp Control Panel
  • Go to ConfigService and Port SettingsApache
  • Replace the Main Port and SSL Port values ​​with those chosen (e.g. 8012 and 8013).
  • Save Service settings
  • Save Configuration of Control Panel
  • Restart the Apache Server It should work now.

4.1. Web browser configuration

If this configuration isn't hiding port number in URL it's because your web browser is not configured for. See : Tools ► Options ► General ► Connection Settings... will allow you to choose different ports or change proxy settings.

4.2. For the rare cases of ultimate bad luck

If step 4 and Web browser configuration are not working for you the only way to do this is to change back to 80, or to install a listener on port 80 (like a proxy) that redirects all your traffic to port 8012.

To answer your problem :

If you still have this message in Control Panel Console :

Apache Started [Port 80]

  • Find location of xampp-control.exe file (probably in C:\xampp)
  • Create a file XAMPP.INI in that directory (so XAMPP.ini and xampp-control.exe are in the same directory)

Put following lines in the XAMPP.INI file:

[PORTS]
apache = 8012

Now , you will always get:

Apache started [Port 8012]

Please note that, this is for display purpose only. It has no relation with your httpd.conf.

这篇关于如何更改 XAMPP apache 服务器端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆