环境:Vmware17虚拟机 CentOS 9 Stream
配置虚拟机
1.启用HTTP和HTTPS端口
sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --zone=public --add-service=https --permanent
sudo firewall-cmd --reload
2.关闭Selinux(Selinux是linux的安全子系统,可看作第二层防火墙)
setenforce 0 --临时关闭SeLinux
永久关闭Selinux:
vim /etc/selinux/config
找到:SELINUX=enforcing
将enforcing改为disable
3.重启系统(重启后才能生效哦)
reboot
安装Apache
1.更新系统资源
sudo yum update
2.安装Apache(Apache在系统库中可用,但名称为“httpd”,不是“apache”)
sudo yum install httpd httpd-tools
3.安装完成后,启用Apache
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd
4.验证Apache的安装
打开浏览器并输入URL(http://你的ip地址)
浏览器会显示Apache的欢迎界面
5.Apache的文件位置:
网站位置 /var/www/html
配置文件位置 /etc/httpd
日志文件位置 /var/log/httpd
安装Mysql
1.更新系统资源
sudo yum update
2.安装Mysql
sudo yum install mysql
sudo yum install mysql-server
3.启动Mysql并设置开机自启
sudo systemctl start mysqld
sudo systemctl enable mysqld
sudo systemctl status mysqld
安装PHP
1.更新系统资源
sudo yum update
2.安装PHP
sudo yum install php
3.验证PHP
php -v