在CentOS上搭建网站的步骤如下:
安装必要的软件:
sudo yum install httpd
sudo yum install php
sudo yum install mariadb-server
启动和配置服务:
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start mariadb
sudo systemctl enable mariadb
配置防火墙:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
创建网站目录:
sudo mkdir /var/www/html/mywebsite
设置网站文件权限:
sudo chown -R apache:apache /var/www/html/mywebsite
sudo chmod -R 755 /var/www/html/mywebsite
创建并编辑网站文件:
sudo vi /etc/httpd/conf.d/mywebsite.conf
<VirtualHost *:80>
ServerName mywebsite.com
DocumentRoot /var/www/html/mywebsite
ErrorLog /var/log/httpd/mywebsite-error.log
CustomLog /var/log/httpd/mywebsite-access.log combined
</VirtualHost>
重启Apache服务器:
sudo systemctl restart httpd
现在,你的CentOS服务器上的网站已经搭建完成。你可以将你的网站文件上传到/var/www/html/mywebsite
目录中,并通过浏览器访问你的网站。