在终端中运行
yum install httpd
//配置ServerName//将#ServerName www.example.com:80修正为ServerName localhost:80
vi /etc/httpd/conf/httpd.conf
//启动apache:
systemctl start httpd
///查看安装版本: (我的是apache/2.4.37)
httpd -v
//设置开机启动:
systemctl enable httpd
2、 安装php:
yum install php php-devel
//查看php版本 (我的是php 7.2.11)
php -v//安装php扩展
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
//我这里在安装php-mysql的时候会提示缺点:没有匹配的参数:php-mysql
//办理如下:
yum search php-mysql
//找到两个匹配版本:php-mysqlnd.x86_64 ;实行安装
yum install php-mysqlnd.x86_64
//启动php
systemctl start php-fpm
//设置开机启动
systemctl enable php-fpm
apache默认解析目录是在 /var/www/html 目录下,变动成 /var/www 目录
vim /etc/httpd/conf/httpd.conf
从 DocumentRoot “var/www/html/" 开始 改成 ”var/www/"
systemctl restart httpd
cd /etc/httpd/conf.d/
touch test.conf
//test.conf 插入代码
<VirtualHost :80>
DocumentRoot /var/www/test
ServerName www.test.com
<Directory "/var/www/test">
Require all granted
Options FollowSymLinks
AllowOverride all
#Require all denied
</Directory>
</VirtualHost>
如需修正默认目录 需变动以上代码 并授权
例:chmod 755 /home/usr/www