记录一下linux yum安装Apache

说明
操作系统:linux centos7
Apache版本:2.4.6
安装方式:yum安装

1. 安装

yum -y install httpd
# 安装完成后启动httpd
# systemctl status httpd  查看状态
# systemctl start httpd   启动
# systemctl restart httpd 重启
# systemctl stop httpd    停止
# systemctl enable httpd  设置开机自启动
# systemctl disable httpd 设置开机不自启动

浏览器输入服务器ip地址,网页出现test123…说明安装成功。

提示:需要注意一下防火墙是否开放80端口

2. 配置Apache

vim /etc/httpd/conf/httpd.conf
# 编辑配置文件,找到
<Directory />
    AllowOverride none
    Require all denied
</Directory>
# 改为
<Directory />
    AllowOverride none
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options FollowSymLinks
    AllowOverride All
    Require all denied
</Directory>
# 改为
<Directory "/var/www/html">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

3. 项目部署
然后进入Apache项目根目录

cd /var/www/html

新建文件夹test1,创建index.html,并随机写一下内容

mkdir test1
# 编辑test1下的index.html
vim test1/index.html

浏览器输入服务器ip/test1,网页出现刚刚index.html的内容则成功

4. 多项目部署,并配置域名

和上面方法一下,在创建一个test2,然后

vim /etc/httpd/conf.d/vhost.conf

写入

<VirtualHost *:80>
	# 项目文件
    DocumentRoot "/var/www/html/test1"
    # 域名
    ServerName 你的域名1
    ServerAlias www.你的域名1
    <Directory "/var/www/html/test1">
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/var/www/html/test2"
    ServerName 你的域名2
    ServerAlias www.你的域名2
    <Directory "/var/www/html/test2">
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

浏览器输入你的域名1.com,你的域名2.com,能成功访问则成功。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值