㈠ 如何更改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伺服器中的網頁。