最近由于需求国外的WEB服务器,所以学习了CentOS7服务器的相关资料,使用Vultr的VPS服务器成功搭建Apache(httpd)以及多域名的配置。
至于Vultr的购买方式请看:https://www.svlik.com/136.html
实战CentOS7安装PHP多个版本
实战CentOS7安装Mysql多个版本
准备工具:
1.XShell (连接CentOS) 下载地址:https://www.svlik.com/262.html
2.Xftp (上传web页面) 下载地址:https://www.svlik.com/263.html
安装Apache
1.安装Apache:yum install httpd (提示“Is this ok [y/d/N]”的时候输入Y按回车即可。)
2.启动Apache:service start httpd.service
2.1重启Apache:service restart httpd.service
2.2停止Apache:service stop httpd.service
3.设置自启动:service enable httpd.service
4.检测安装状态:ps -e |grep httpd
此时Apache已经安装完毕。
关闭防火墙
很多人问搭建好了Apache却不能访问,那是因为被防火墙阻止了。你可以输入以下命令停止并禁止防火墙。
1.停止防火墙服务:
service stop firewalld.service
2.禁用防火墙开机启动服务:
service disable firewalld.service
配置Apache
1.使用Xftp进入/etc/httpd/conf/目录并下载httpd.conf文件。
2.使用Notepad+打开你下载的httpd.conf文件并进行以下修改。
3.搜索Directory /修改为以下内容。
<VirtualHost *:80>
DocumentRoot /home/www/www
ServerName www.pcpc.top
ServerAlias pcpc.top
<VirtualHost *:80>
DocumentRoot /home/www/test1
ServerName test1.pcpc.top
<VirtualHost *:80>
DocumentRoot /home/www/test2
ServerName test2.pcpc.top