沃梦达 / 编程技术 / 服务器 / 正文

apache常用工能

【修改首页内容】[root@chaogelinux ~]# vim /var/www/html/index.html[root@chaogelinux ~]# curl 127.0.0.1meta charset=utf8超哥带你学apache【修改网页资源目录路径】1.修改配置文件如下,两处修改[root@chaog...

【修改首页内容】
[root@chaogelinux ~]# vim /var/www/html/index.html
[root@chaogelinux ~]# curl 127.0.0.1
<meta charset=utf8>
超哥带你学apache

【修改网页资源目录路径】
1.修改配置文件如下,两处修改
[root@chaogelinux ~]# cat /etc/httpd/conf/httpd.conf
DocumentRoot "/www/html"
<Directory "/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

2.创建资源目录,创建html文件
mkdir -p /www/html/
[root@chaogelinux conf]# cat /www/html/index.html
<meta charset=utf8>
我是新的首页,你好兄弟们

3.修改了配置文件,还得重启http服务才能生效
systemctl restart httpd
4.注意关闭防火墙和selinux,影响实验
[root@chaogelinux conf]# systemctl stop firewalld
[root@chaogelinux conf]# systemctl disable firewalld
[root@chaogelinux conf]# iptables -F
[root@chaogelinux conf]# setenforce 0  #临时关闭selinux
[root@chaogelinux conf]# grep -i ‘^selinux‘ /etc/selinux/config    
SELINUX=disabled    #永久关闭selinux,重启机器生效
SELINUXTYPE=targeted
5.此时可以访问新的页面了
[root@chaogelinux conf]# curl 127.0.0.1
<meta charset=utf8>
我是新的首页,你好兄弟们


【修改监听端口】
[root@chaogelinux ~]# grep -i "^listen"  /etc/httpd/conf/httpd.conf
Listen 85
访问效果
[root@chaogelinux ~]# curl 127.0.0.1:85
<meta charset=utf8>
我是新的首页,你好兄弟们

原文:https://www.cnblogs.com/wzj0015/p/13170338.html

本文标题为:apache常用工能

基础教程推荐