在CentOS上配置LAMP(Linux, Apache, MySQL, PHP)虚拟主机涉及多个步骤,以下是详细的步骤说明:
环境准备:
关闭防火墙和SELinux:
systemctl stop firewalld systemctl disable firewalld vi /etc/selinux/config SELINUX=disabled reboot 安装必要的软件包:
yum install gcc gcc-c++ make yum install httpd mariadb-server php php-mysqlnd 配置Apache:
vi /usr/local/apache/conf/httpd.conf Listen 80 ServerName your_domain_or_ip DocumentRoot /var/www/html <Directory /var/www/html> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> systemctl start httpd systemctl enable httpd 配置MySQL:
systemctl start mariadb systemctl enable mariadb mysql_secure_installation 配置虚拟主机(可选):
vi /usr/local/apache/conf/extra/httpd-vhosts.conf your_domain为实际域名):<VirtualHost *:80> ServerName your_domain DocumentRoot /var/www/your_domain <Directory /var/www/your_domain> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost> systemctl restart httpd 通过以上步骤,您可以在CentOS上成功配置LAMP虚拟主机。