简体   繁体   English

更改httpd.conf中的端口号

[英]Change port number in httpd.conf

I wanted to change my port from 80 to some other number as I could not install/start Apache. 我想将端口从80更改为其他号码,因为我无法安装/启动Apache。 I know that the changes need to be done in the httpd.conf. 我知道需要在httpd.conf中进行更改。 So i found the line: 所以我找到了这一行:

# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 0.0.0.0:80
Listen [::0]:80

How do I change this part to a new port number? 如何将这部分更改为新的端口号? Will the following be efficient? 以下效率高吗?

# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:81
Listen 0.0.0.0:81
Listen [::0]:81

If you are not "root", you cannot bind to ports below 1024... presuming the situation isn't just that port 80 is already in use, this seems like the next-most-likely candidate. 如果您不是“ root”用户,则不能绑定到低于1024的端口...假定情况不仅是端口80已在使用中,这似乎是下一个最有可能的选择。

Note that you will also likely need to change any or similar blocks to refer to the new port. 请注意,您可能还需要更改任何或类似的块以引用新端口。

You generally don't need (or want, because it's confusing) to specify a port number in "ServerName" and "ServerAlias" lines. 通常,您不需要(或因为混乱而需要)在“ ServerName”和“ ServerAlias”行中指定端口号。 So if you have any there, I'd remove them and leave just the actual domain name(s). 因此,如果有,我将删除它们,仅保留实际的域名。

This is what i have 这就是我所拥有的

#Change this to Listen on specific IP addresses as shown below to 

#prevent Apache from glomming onto all bound IP addresses.

#Listen 12.34.56.78:8080

Listen 8080

There's your answer!!!! 有你的答案!!!

This is what you have 这就是你所拥有的

# prevent Apache from glomming onto all bound IP addresses.

#Listen 12.34.56.78:81

Listen 0.0.0.0:81

Listen [::0]:81 <- REMOVE THIS 

this is my fix for localhost not working (going to.com) wampserver3.0.6_x64_apache2.4.23_mysql5.7.14_php5.6.25-7.0.10 这是我对本地主机无法正常工作的修复(前往.com)wampserver3.0.6_x64_apache2.4.23_mysql5.7.14_php5.6.25-7.0.10

make a copy first of C:\\wamp64\\bin\\apache\\apache2.4.23\\conf\\httpd.conf 首先复制C:\\ wamp64 \\ bin \\ apache \\ apache2.4.23 \\ conf \\ httpd.conf

Look for Listen 12. 寻找听12。

then edit original httpd.conf in text editor (notepad) 然后在文本编辑器(记事本)中编辑原始的httpd.conf

Lines 70 or so: 第70行左右:

71      #Listen 12.34.56.78:80
72      Listen 0.0.0.0:80
73      Listen [::0]:80

Replace with 用。。。来代替

    #Listen 12.34.56.78:80
    #Listen 0.0.0.0:80      commented out for below
    Listen 8080
    #Listen [::0]:80        commented out for below
    Listen [::0]:8080   

Save... Restart Wampserver 保存...重新启动Wampserver

By default, Apache server listens to port 80. However, in some cases the port 80 is used by other programs such as Skype. 默认情况下,Apache服务器侦听端口80。但是,在某些情况下,其他程序(例如Skype)使用端口80。 In that case you need to change your port number. 在这种情况下,您需要更改端口号。 So, look out for httpd.conf file which is placed inside of conf directory in Apache installation directory (therefore you are on right path). 因此,请注意httpd.conf文件,该文件位于Apache安装目录的conf目录中(因此,您位于正确的路径上)。 Then just change the port number, save your changes and restart your service. 然后只需更改端口号,保存更改并重新启动服务即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM