安装Apache
yum -y install httpd
systemctl start httpd
添加防火墙
firewall-cmd --permanent --add-port=80/tcp systemctl restart firewalld
安装PHP7.2
yum install epel-release -y rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum -y install PHP72w PHP72w-cli PHP72w-fpm PHP72w-common PHP72w-devel PHP72w-gd PHP72w-mbstring PHP72w-MysqLnd PHP72w-opcache PHP72w-pdo PHP72w-xml systemctl restart httpd systemctl enable PHP-fpm.service systemctl start PHP-fpm.service
安装MysqL
yum -y install wget wget https:dev.MysqL.com/get/MysqL57-community-release-el7-9.noarch.rpm rpm -ivh MysqL57-community-release-el7-9.noarch.rpm cd yum.repos.d yum install -y MysqL-server service MysqLd start
MysqL密码配置
新版本的MysqL会为root用户创建一个初始密码,需要更改
查看默认密码
sudo grep 'temporary password' /var/log/MysqLd.log 2020-01-16T01:47:12.600702Z 1 [Note] A temporary password is generated for root@localhost: nym>Co+s7oK2
更改MysqL密码
cd /etc vi my.cnf 新增 skip-grant-tables 不用密码直接登录MysqL : MysqL 修改密码(5.7版本已经不再使用password来作为密码的字段了 而改成了authentication_string) UPDATE MysqL.user SET authentication_string=PASSWORD("123456") WHERE user=root" AND Host=localhost"; 刷新表格 flush privileges; 退出MysqL: exit; systemctl restart MysqLd
在本机浏览器访问 http://192.168.23.130/
配置虚拟域名
查看apache主配置文件,确保存在以下配置
vim /etc/httpd/conf/httpd.conf IncludeOptional conf.d/*.conf
新增虚拟主机配置文件
cd /etc/httpd/conf.d/
vim cyy.conf
添加虚拟机
<VirtualHost *:80> ServerName lamp.cyy.com ServerAlias lamp.cyy.com ServerAdmin lamp@cyy.com DocumentRoot /var/www/html/lamp.cyy.com/ <Directory /var/www/html/lamp.cyy.com> Options -Indexes +FollowSymLinks AllowOverride All </Directory> ErrorLog /var/log/httpd/lamp.cyy.com-error.log CustomLog /access.log combined </VirtualHost>
创建虚机主机目录及测试页面
/var/www/html/lamp.cyy.com/
创建info.PHP
在/etc/hosts文件中新增
192.168.23.130 lamp.cyy.com #虚拟机ip
检查配置文件是否正常
httpd -t AH00558: httpd: Could not reliably determine the servers fully qualified domain name,using localhost.localdomain. Set the 'ServerName directive globally to suppress this message Syntax OK
重启httpd服务
systemctl restart httpd
在本机我是win10,路径:C:\Windows\System32\drivers\etc
hosts文件中新增
23.130 lamp.cyy.com
浏览器访问:http://lamp.cyy.com/info.PHP