時(shí)間:2023-07-15 17:48:01 | 來源:網(wǎng)站運(yùn)營(yíng)
時(shí)間:2023-07-15 17:48:01 來源:網(wǎng)站運(yùn)營(yíng)
Centos7 安裝Apache:yum -y install httpd
systemctl enable httpdsystemctl start httpd
如果您正在運(yùn)行防火墻(firewalld),則還需要打開HTTP和HTTPS端口80和443:firewall-cmd --permanent --zone=public --add-service=httpfirewall-cmd --permanent --zone=public --add-service=httpsfirewall-cmd --reload
我們可以通過以下方式檢查Apache服務(wù)的狀態(tài)和版本:systemctl status httpd
輸出:● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2019-03-10 14:14:53 CST; 4min 6s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 1062 (httpd) Status: "Total requests: 15; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─1062 /usr/sbin/httpd -DFOREGROUND ├─1170 /usr/sbin/httpd -DFOREGROUND ├─1171 /usr/sbin/httpd -DFOREGROUND ├─1172 /usr/sbin/httpd -DFOREGROUND ├─1173 /usr/sbin/httpd -DFOREGROUND ├─1174 /usr/sbin/httpd -DFOREGROUND ├─1221 /usr/sbin/httpd -DFOREGROUND ├─1222 /usr/sbin/httpd -DFOREGROUND └─1223 /usr/sbin/httpd -DFOREGROUND
再輸入如下命令:httpd -v
輸出:Server version: Apache/2.4.6 (CentOS)Server built: Nov 5 2018 01:47:09
systemctl stop httpd
要再次啟動(dòng),請(qǐng)鍵入:systemctl start httpd
重新啟動(dòng)Apache服務(wù):systemctl restart httpd
在進(jìn)行一些配置更改后重新加載Apache服務(wù):systemctl reload httpd
如果您想禁用Apache服務(wù)以在啟動(dòng)時(shí)啟動(dòng):systemctl disable httpd
并重新啟用它:systemctl enable httpd
/etc/httpd
/etc/httpd/conf/httpd.conf
<FilesMatch /.php$> SetHandler application/x-httpd-php</FilesMatch>
/etc/httpd/conf.modules.d/00-base.conf
使用vim命令打開文件:vim /etc/httpd/conf.modules.d/00-base.conf
在文件里搜索rewrite_module modules/mod_rewrite.so
,在所在行前面是否有#
,如果有的話,將#
刪除,然后保存文件。 查看httpd.conf文件是否已打開允許重寫功能vim /etc/httpd/conf/httpd.conf
在文件里搜索.htaccess
,我們找到 如下注釋對(duì)應(yīng)的AllowOverride None
# # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None
然后將AllowOverride None
改成AllowOverride All
注意改動(dòng)的位置 因?yàn)樵撐募?有多處 AllowOverride None
,只有找到正確的位置才有效。systemctl restart httpd
var/www/html
,可通過httpd.conf配置文件里的DocumentRoot
參數(shù)進(jìn)行修改。## DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but# symbolic links and aliases may be used to point to other locations.#DocumentRoot "/var/www/html"
關(guān)于虛擬主機(jī)項(xiàng)目配置文件,位于/etc/httpd/conf.d
目錄,建議一個(gè)域名一個(gè)配置文件 虛擬主機(jī)配置文件規(guī)范:[域名].conf<VirtualHost *:80> ServerName [域名] ServerAlias [域名] DocumentRoot "/var/www/html/[項(xiàng)目目錄]"</VirtualHost>
Connection:Keep-AliveDate:Sun, 10 Mar 2019 17:15:20 GMTETag:"18-583bffda946f5"Keep-Alive:timeout=5, max=100Server:Apache/2.4.6 (CentOS)
幾乎把web服務(wù)器詳細(xì)信息都暴出來了,如果沒個(gè)版本的apache和php爆出嚴(yán)重漏洞,會(huì)給攻擊者提供最有攻擊價(jià)值的安全信息,這是非常危險(xiǎn)的。# 禁止在http請(qǐng)求頭暴露服務(wù)器信息ServerTokens ProductOnlyServerSignature Off
然后重啟Apache服務(wù),再次發(fā)出Apache頭信息請(qǐng)求:Connection:Keep-AliveDate:Sun, 10 Mar 2019 17:18:52 GMTETag:"18-583bffda946f5"Keep-Alive:timeout=5, max=100Server:Apache
可以看到apache版本號(hào)于已經(jīng)沒有了。關(guān)鍵詞:安裝
客戶&案例
營(yíng)銷資訊
關(guān)于我們
客戶&案例
營(yíng)銷資訊
關(guān)于我們
微信公眾號(hào)
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。