㈠ 如何更改linux下的Apache http端口号
你好,
Apache的端口号是在其目录下的 httpd.conf这个文件中设置的。
Apache是跨平台的软件,在linux/windows/unix下都有相应的版本。
找到apache目录下的httpd.conf, 使用vi打开,找到port=80 这一行,把80改成在此服务器上没有用到的端口号,保存退出。
然后重新启动apache进程即可。
如果你用rpm包安装的apache,那么你的主配置文件应该是在/etc/httpd/conf/httpd.conf这里;
如果你用tar包安装的apache,那么应该在你apache安装目录下的conf/httpd.conf这里;
如果apache是在/usr/local/apache2安装的,那么主配置文件就在/usr/local/apache2/conf/httpd.conf这里.
㈡ 如何更改linux下的Apache端口号
1
停止httpd服务
2
查看httpd的状态,确认httpd服务已经停止
3
查找httpd.conf配置文件的存放路径
4
编辑httpd.conf配置文件
5
查找Listen配置段
6
修改Listen后面的端口,默认是80,这里修改为8080
7
输入英文的冒号+wq,保存并退出
8
修改后需要再次启动httpd服务
9
这里使用localhost或者127.0.0.1登录,也就是默认使用80端口登录,提示不能建立连接,因为端口已经更改为8080
10
这里使用8080端口后,经过验证能够登录成功,说明httpd端口已经更改
并且httpd能够正常工作。
㈢ 如何更改linux下的Apache http端口号
# vi /etc/httpd/conf/httpd.conf 文件
修改两个地方
#Listen 12.34.56.78:80
Listen 80
#把80改为你设置的端口,我设置端口为82
Listen 82
NameVirtualHost *:80
#把80改为你设置的端口,我设置端口为82
NameVirtualHost *:82
保存修改,退出。
//如果没有semanage命令,则执行:
# yum -y install policycoreutils-python
# semanage port -a -t http_port_t -p tcp 5555 #输入这个命令 要不httpd 会启动失败
# /etc/rc.d/init.d/httpd start #启动httpd
㈣ 如何更改linux下的Apache端口号
使用vim编辑Apache http的配置文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@Linuxprobe ~]# vim /etc/httpd/conf/httpd.conf
前文省略……………………………………
ServerRoot "/etc/httpd"
32
33 #
34 # Listen: Allows you to bind Apache to specific IP addresses and/or
35 # ports, instead of the default. See also the <VirtualHost>
36 # directive.
37 #
38 # Change this to Listen on specific IP addresses as shown below to
39 # prevent Apache from glomming onto all bound IP addresses.
40 #
41 #Listen 12.34.56.78:80
42 Listen 80 #这是Apache的默认监听端口,修改你想要修改的端口就可以了
43
44 #
45 # Dynamic Shared Object (DSO) Support
46 #
47 # To be able to use the functionality of a mole which was built as a DSO you
:wq #退出并保存
2.使用重新启动httpd服务:systemctl restart httpd (PS:这里使用的是RHEL 7.0系统)如果是7以下的系统,这里有详细介绍Apache的配置服务http://www.linuxprobe.com/chapter-09/。或者可以使用service httpd restart重启即可。
1
2
[root@Linuxprobe ~]# systemctl restart httpd
[root@Linuxprobe ~]#
㈤ 如何修改Linux系统下的Apache服务器运行端口
Apache的端口号是在其目录下的 httpd.conf这个文件中设置的。
Apache是跨平台的软件,在linux/windows/unix下都有相应的版本。
找到apache目录下的httpd.conf, 使用vi打开,找到port=80 这一行,把80改成在此服务器上没有用到的端口号,保存退出。
然后重新启动apache进程即可。
如果你用rpm包安装的apache,那么你的主配置文件应该是在/etc/httpd/conf/httpd.conf这里;
如果你用tar包安装的apache,那么应该在你apache安装目录下的conf/httpd.conf这里;
如果apache是在/usr/local/apache2安装的,那么主配置文件就在/usr/local/apache2/conf/httpd.conf这里.
㈥ 如何更改linux下的Apache端口号
Apache的端口号是在其目录下的 httpd.conf这个文件中设置的。
Apache是跨平台的软件,在linux/windows/unix下都有相应的版本。
找到apache目录下的httpd.conf, 使用vi打开,找到port=80 这一行,把80改成在此服务器上没有用到的端口号,保存退出。
然后重新启动apache进程即可。
如果你用rpm包安装的apache,那么你的主配置文件应该是在/etc/httpd/conf/httpd.conf这里;
如果你用tar包安装的apache,那么应该在你apache安装目录下的conf/httpd.conf这里;
如果apache是在/usr/local/apache2安装的,那么主配置文件就在/usr/local/apache2/conf/httpd.conf这里.
㈦ 如何更改linux下的Apache端口号
apache默认端口是80,当被占用时就会关闭,可以把端口改为8090,然后重启apache
㈧ 如何更改linux下的apache端口号
如何更改linux下的Apache端口号
一、修改
/etc/httpd/conf/httpd.conf
文件中的监听端口号
Listen 80
把
80
修改成需要的号,如
8000
,即
Listen 8000
二、查看
SELinux
下
http
相关端口
# semanage port -l|grep http
http_cache_port_t tcp 3128, 8080, 8118, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
发现
8000
不在其范围之内,所以需要另外添加,方法如下:
# semanage port -a -t http_port_t -p tcp 8000
再次查看,
# semanage port -l|grep http
http_cache_port_t tcp 3128, 8080, 8118, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 8000, 80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
三、在防火墙中开放新添加的端口
修改
/etc/sysconfig/iptables
文件,在文件中添加如一行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8008 -j ACCEPT
2
四、重启防火墙和
Apache
# service iptables restart
# service httpd restart
五、正常情况下,应该可以通过新端口访问
WEB
服务了。
注:
1
、第二、三、四步骤是在系统已经开启
SELinux
和防火墙的情况下设置的,如果已经关闭此两
个服务,修改端口后直接重启
Apache
即可;
2
、修改的端口号可以是执行
#semanage port -l|grep http
后,默认已经有的端口,如
8443
,这样
可以省略额外添加
SELinux
端口操作;
3
、第三步操作可以图形界面下完成。
参考资料
1
、
Permission denied: make_sock: could not bind to address
http://emmune.blogspot.com/2009/07/permission-denied-makesock-could-not.html
不熟悉
python
、
plone
、
zope
,想用
apache
。
80
端口已经不在,就征用
81
端口凑合吧。修改
httpd.conf
后
apachectl start
,结果:
(13)Permission denied: make_sock: could not bind to address [::]:81
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:81
查一下
SELinux
下
http
相关端口
semanage port -l|grep http
,结果:
http_cache_port_t tcp 3128, 8080, 8118, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
直接用
man semanage
最后例子中的一句
# Allow Apache to listen on port 81
semanage port -a -t http_port_t -p tcp 81
3
然后再
apachectl start
,
OK
。使用域名
:81
能够访问啦。
注:
semanage
semanage is used to configure certain elements of SELinux policy without requiring modification
to or recompilation from policy sources. This includes the mapping from Linux usernames to
SELinux user identities (which controls the initial security context assigned to Linux users when
they login and bounds their authorized role set) as well as security context mappings for various
kinds of objects, such as network ports, interfaces, and nodes(hosts) as well as the file context
mapping. See the EXAMPLES section below for some examples of common usage. Note that
the semanage login command deals with the mapping from Linux usernames (logins) to
SELinux user identities, while the semanage user command deals with the mapping from
SELinux user identities to authorized role sets. In most cases, only the former mapping needs to
be adjusted by the administrator; the latter is principally defined by the base policy and usually
does not require modification.
2
、
linux
下
apche
无法监听端口解决办法
http://www.zzxj.net/blog/fxs_2008/archive/2010/07/05/187.html
想建立一个测试用的虚拟主机,遇到了这个问题:
[root@localhost html]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using
localhost.termwikidev for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:81
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:81
no listening sockets available, shutting down
Unable to open logs
解决办法:
semanage port -l|grep http
semanage port -a -t http_port_t -p tcp 81
这个两个命令一是查看,一个是添加,添加完再查看一遍,如果有
81
,则成功。另可能要以
root
用户运行。
此外,如果要外网访问,还要打开
linux
的防火墙:
4
[root@localhost html]# vim /etc/sysconfig/iptables
[root@localhost html]# service iptables restart
重启
apache.
相关资料:
starting httpd 13 permission denied make_sock could not bind to address2010
年
01
月
19
日
星
期二
11:33In Fedora Core 5/6 and RHEL 5. We have made it easier to customize certain
common parts of SELinux. In previous releases of SELinux if you wanted to change simple
things like which port a daemon could listen to, you would need to write policy. Now we have the
semanage utility.
SELinux assigns types to all network ports on a system. By default all ports are less then 1024
are labeled reserved_port_t and all ports > 1024 are labeled port_t. If a port is assigned to a
particular type
say the http port 80, it has an assigned type of http_port_t. If you want to look at all the assigned
ports in SELinux, you can use the semanage tool, semanage port -l.
So if you executed
semanage port -l | grep http
http_cache_port_t tcp 3128, 8080, 8118
http_cache_port_t udp 3130
http_port_t tcp 80, 443, 488, 8008, 8009, 8443
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
Here we see http_port_t is assigned to ports 80, 443, 488, 8008, 8009, 8443
The policy is written to allow httpd_t http_port_t:tcp_socket name_bind;
This means the apache command can "bind" to an port that is labeled http_port_t.
So lets say you want to run httpd on port 81.
So you edit /etc/httpd/http.conf
and change this line
Listen 80
to
Listen 81
Now restart the daemon.
service httpd restart
Stopping httpd: [ OK ]
Starting httpd: (13)Permission denied: make_sock: could not bind to address [::]:81
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:81
no listening sockets available, shutting down
Unable to open logs
[FAILED]
Now the daemon fails to start because it can not bind to port 81.
This generates an AVC that looks like
----
time->Tue Dec 12 17:37:49 2006
type=SYSCALL msg=audit(1165963069.248:852): arch=40000003 syscall=102 success=no
exit=-13 a0=2 a1=bf96a830 a2=b5b1e8 a3=9e58b68 items=0 ppid=3 pid=4
auid=3267 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts10 comm="httpd"
exe="/usr/sbin/httpd" subj=user_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1165963069.248:852): avc: denied { name_bind } for pid=4
comm="httpd" src=81 scontext=user_u:system_r:httpd_t:s0
tcontext=system_u:object_r:reserved_port_t:s0 tclass=tcp_socket
To fix this you can use semanage to add the port
semanage port -a -t http_port_t -p tcp 81
㈨ 如何修改Apache的默认端口号
一、修改Apache的默认端口号
在WEB SERVER界,不管是微软的IIS还是世界排名第一的Apache,它们安装好后默认的网页服务端口号都是80。有必要指出的是,如果你的电脑中已经安装有某种WEB SERVER软件(如IIS),想要再增加一种WEB SERVER软件(如Apache)的话,那么必须先修改前者默认的网页服务端口80,否则可能会无法完成安装(见图2)。其它主流的和非主流的WEB SERVER也都如此。当然,今天的主角是Apache,如何修改它的默认网页服务端口号?且看下面细细道来:
Apache安装好后,在其安装目录下的conf文件夹内会有httpd.conf这样一个文本文档,它是Apache的配置文件,用于指挥Apache的运行,Apache默认的网页服务端口号固然就在这个里头配置(修改)。要修改这个文件,肯定首先要打开它,直接双击就行,然后同时按下键盘上的Ctrl+F组合键,在弹出的“查找”对话框中输入Listen 80(如下图3):
在查找出来的“Listen 80”字符串中(仅此一处),将80改为8000或8080,总之只要是你们喜欢的数字都可以(关于端口号的知识不是此文要讲解的范围,自己去了解一下,端口也不能随意乱用哦)。在“Listen 80”的上方还有“#Listen 12.34.56.78:80”这样一串字符,这儿的80不是一定要随“Listen 80”中的80而变化,可改可不改,这只是一个样例。
结束上述操作后,同时按下键盘上的Ctrl+S组合键进行保存,然后关闭即完成对Apache默认网页服务端口号的修改,一定记得要停止(STOP)一次Apache服务然后再启动(START),使刚刚的修改生效。但要注意的是,如果你修改了默认端口号(假如将Listen 80改为Listen 8080),那么你将无法通过localhost或者是127.0.0.1来打开位于Apache服务器上的网页,必须在地址后面加上冒号+端口号,如localhost:8080或者是127.0.0.1:8080,只有这样才能访问位于Apache服务器中的网页。