當前位置:首頁 » 操作系統 » linux修改apache

linux修改apache

發布時間: 2023-05-25 07:24:21

『壹』 如何修改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 這個文件中。

打開這租轎個文件,找到port=80這一行,把80改為你想要使遲型稿用的埠即可(不可與其他正在使用的埠重復)

『叄』 如何更改linux下的Apache http埠號

---
httpd.conf配置請參照下面
#vi /etc/httpd/conf/httpd.conf
以下展示的是學新公園對默認值的修改。
#禁止顯示apache版本號
ServerTokens ProctOnly
ServerSignature Off
#埠監聽,我們將*改成了我們的獨立ip
Listen *:80
#我們開啟了兩個模塊,其他模塊默認設置
mod_rewrite.so #開啟.htaccess需要
mod_vhost_alias.so #設置仿舉虛擬機需要
#我們將ServerAdmin改成我們自己的郵箱。
ServerAdmin [email protected]
#我們將ServerName導向固定ip,即將*改成我們的ip
ServerName *:80
#我譽蔽們修改了DocumentRoot目錄
DocumentRoot /***
#將Options屬性改成FollowSymLinks
Options FollowSymLinks
#將AllowOverride屬性改成ALL以支持.htaccess
AllowOverride ALL
#我們配置了虛擬機,我們把*更改成我們的ip
NameVirtualHost *:80
#虛擬機上拒絕了備虛碧直接通過ip訪問我們的站點,我們把*更改成我們的ip
<VirtualHost *:80

『肆』 如何更改linux下的Apache http埠號

你可以根喊者弊據Apache的安裝路徑找其配置文件,比如說我的配置文件路鄭族徑就在/usr/local/apache2/conf/httpd.conf,你可以修改listen 80這一行,改成嫌告你想要的埠號

『伍』 在linux環境下,修改apache的許可權問題,使得php能夠對文件和文件目錄進行讀寫刪改的操作

是的,是apache的許可權問題,慎純一般把網站所在目錄設置成apache,權禪孝絕限自己設定,
chown -R apache:apache /網站賀姿所在目錄
chmod -R 775 /網站所在目錄

『陸』 linux怎樣修改apache默認網站的目錄

工具/原料

Apache

方法/步驟如下:

1、創建更改的新目錄,並更改宿主許可權為稿乎apache用戶 chown -R apache:apache /mnt/www

『柒』 如何更改linux下的Apache http埠號

使用vim編輯Apache http的配置文件:

[root@Linuxprobe~]#vim/etc/httpd/conf/httpd.conf
前文省略………………型棗………嫌跡……………
ServerRoot"/etc/httpd"
32
33#
34#Listen:/or
35#ports,insteadofthedefault.Seealsothe<VirtualHost>
36#directive.
37#
38#
39#.
40#
41#Listen12.34.56.78:80
42Listen80#這是Apache的默認監聽埠,修改你想要修改的埠就可以了
43
44#
45#DynamicSharedObject(DSO)Support
46#
47#
:wq#退出並保存

2.使用重新啟動httpd服務:芹租並systemctl restart httpd (PS:這里使用的是RHEL 7.0系統)如果是7以下的系統,這里有詳細介紹Apache的配置服務http://www.linuxprobe.com/chapter-09/。或者可以使用service httpd restart重啟即可。

[root@Linuxprobe~]#systemctlrestarthttpd
[root@Linuxprobe~]#

希望能夠幫助到你,謝謝!

『捌』 如何更改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

『玖』 linux怎樣修改apache默認網站的目錄

修改apache2的默認文檔目錄(默認是在/var/www)
修改命令:sudo gedit /etc/apache2/sites-enabled/000-default
在文檔中找到 DocumentRoot 在後段檔好面修改你要放置網頁文件的目錄
修改蠢世完後重啟apache2伺服器即可,重啟命令: sudo /etc/握鉛init.d/apache2 restart

『拾』 linux環境,apache2.4版本,怎麼開啟SSI,如何修改httpd.conf的配置文件

發行版不同,修改方法不同:

Ubuntu:/etc/apache2 目錄下應該有個mods-available 和mods-enabled目錄,在mods-enabled 目錄下創建一個 mods-avaibale/ssl.load 的軟連接:

sudoln-svmods-available/ssl.loadmods-enabled/ssl.load

CentOS:

sudovim/etc/httpd.conf
去掉#LoadMolessl_moleapachePath/moles/mod_ssl.so的注釋
熱點內容
scratch少兒編程課程 發布:2025-04-16 17:11:44 瀏覽:642
榮耀x10從哪裡設置密碼 發布:2025-04-16 17:11:43 瀏覽:368
java從入門到精通視頻 發布:2025-04-16 17:11:43 瀏覽:89
php微信介面教程 發布:2025-04-16 17:07:30 瀏覽:312
android實現陰影 發布:2025-04-16 16:50:08 瀏覽:794
粉筆直播課緩存 發布:2025-04-16 16:31:21 瀏覽:347
機頂盒都有什麼配置 發布:2025-04-16 16:24:37 瀏覽:213
編寫手游反編譯都需要學習什麼 發布:2025-04-16 16:19:36 瀏覽:818
proteus編譯文件位置 發布:2025-04-16 16:18:44 瀏覽:369
土壓縮的本質 發布:2025-04-16 16:13:21 瀏覽:596