Apache与PHP

httpd

提供http服务

配置文件路径/etc/httpd/conf
服务路径/var/www/html

快速搭建服务

#!/bin/bash
yum -y install httpd
systemctl enable httpd
systemctl restart httpd
firewall-cmd --add-service=http
firewall-cmd --add-service=http --permanent

http虚拟网站

根据需要,一台服务器可能会运行多个网站,这些网站使用同一个IP,因此我们需要对其进行区分。

根据端口区分

#!/bin/bash
mkdir -p /html/81
cat >/etc/httpd/conf.d/new.conf <<EOF
Listen 81
<VirtualHost *:81>
ServerName      1.com
DocumentRoot "/html/81"
<Directory "/html/81">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
</VirtualHost>
EOF
echo "hello world">/html/81/index.html
firewall-cmd --add-port=81/tcp
firewall-cmd --add-port=81/tcp --permanent

根据域名区分

#!/bin/bash
yum -y install httpd
mkdir -p /html/1
cat >/etc/httpd/conf.d/1.conf <<EOF
<VirtualHost *:80>
ServerName      1.com
DocumentRoot "/html/1"
<Directory "/html/1">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
</VirtualHost>
EOF
echo "192.168.10.101    1.com" >>/etc/hosts
echo "hi" >/html/1
systemctl restart httpd
firewall-cmd --add-port=80/tcp
firewall-cmd --add-port=80/tcp --permanent

PHP

Apache调用PHP是调用模块

PHP搭建

#!/bin/bash
yum -y install php
systemctl enable httpd
systemctl restart httpd
echo "<?php phpinfo(); ?>" >/var/www/html/index.php
firewall-cmd --add-service=http
firewall-cmd --add-service=http --permanent

计算机英语

virtualhost虚拟主机
document文件
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值