找到之前新建的data目录,在里面新建一些目录和文件
找到httpd.conf文件
打开文件
添加一行代码,为阿里云ECS中内网地址:80
内网地址在阿里云控制台中
修改DirectoryIndex index.html为DirectoryIndex index.html index.php index.htm
修改/var/www/html为/data/www/web
将Options Indexes FollowSymLinks修改为Options FollowSymLinks 为了禁止访问目录列表
并将AllowOverride None改为AllowOverride All 为了支持.htaccess
修改/var/www/cgi-bin为/data/www/cgi-bin
修改ErrorLog "logs/error_log"为ErrorLog "/data/log/httpd/error_log"
修改CustomLog "logs/httpd/access_log"为CustomLog "/data/log/httpd/access_log"
输入systemctl restart httpd.service重启apache
删除/var/www目录,和/var/log/httpd目录
然后在浏览器里输入域名或者ip地址
在/data/www/web中新建index.php项目,输入代码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>my aliyun</title>
</head>
<body>
<?php
phpinfo()
?>
</body>
</html>
刷新浏览器
apache配置完成。