时间:2023-07-15 17:48:01 | 来源:网站运营
时间:2023-07-15 17:48:01 来源:网站运营
Centos7 安装Apache:yum -y install httpd
systemctl enable httpdsystemctl start httpd
如果您正在运行防火墙(firewalld),则还需要打开HTTP和HTTPS端口80和443:firewall-cmd --permanent --zone=public --add-service=httpfirewall-cmd --permanent --zone=public --add-service=httpsfirewall-cmd --reload
我们可以通过以下方式检查Apache服务的状态和版本: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
要再次启动,请键入:systemctl start httpd
重新启动Apache服务:systemctl restart httpd
在进行一些配置更改后重新加载Apache服务:systemctl reload httpd
如果您想禁用Apache服务以在启动时启动: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
,我们找到 如下注释对应的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
注意改动的位置 因为该文件 有多处 AllowOverride None
,只有找到正确的位置才有效。systemctl restart httpd
var/www/html
,可通过httpd.conf配置文件里的DocumentRoot
参数进行修改。## 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"
关于虚拟主机项目配置文件,位于/etc/httpd/conf.d
目录,建议一个域名一个配置文件 虚拟主机配置文件规范:[域名].conf<VirtualHost *:80> ServerName [域名] ServerAlias [域名] DocumentRoot "/var/www/html/[项目目录]"</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服务器详细信息都暴出来了,如果没个版本的apache和php爆出严重漏洞,会给攻击者提供最有攻击价值的安全信息,这是非常危险的。# 禁止在http请求头暴露服务器信息ServerTokens ProductOnlyServerSignature Off
然后重启Apache服务,再次发出Apache头信息请求:Connection:Keep-AliveDate:Sun, 10 Mar 2019 17:18:52 GMTETag:"18-583bffda946f5"Keep-Alive:timeout=5, max=100Server:Apache
可以看到apache版本号于已经没有了。关键词:安装