在CentOS上部署Web服务器的步骤如下:
sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo yum install php php-mysql -y
sudo yum install mariadb-server mariadb -y
sudo systemctl start mysqld
sudo systemctl enable mysqld
/etc/httpd/conf.d/example.com.conf
:sudo vi /etc/httpd/conf.d/example.com.conf
VirtualHost *:80
ServerAdmin webmaster@example.com
DocumentRoot "/var/www/html/example.com"
ServerName example.com
ServerAlias www.example.com
ErrorLog "/var/log/httpd/example.com-error.log"
CustomLog "/var/log/httpd/example.com-access.log" combined
sudo mkdir -p /var/www/html/example.com
sudo chown -R apache:apache /var/www/html/example.com
sudo chmod -R 755 /var/www/html/example.com
sudo systemctl restart httpd