Apache:读音类似阿帕奇武装直升机.....
Posted Linux学习的那些事儿
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Apache:读音类似阿帕奇武装直升机.....相关的知识,希望对你有一定的参考价值。
yum –y install httpd #做的yum安装服务,如果没配置yum源的请先配置,这里就不多说了
systemctl start httpd #启动服务
systemctl enable httpd #做开机启动
getenforce
setenforce 0
selinux开机不自启的配置如下:
执行:vi /etc/selinux/config
将SELINUX=xxxx 修改为SELINUX=disabled
systemctl status firewalld
systemctl enable firewalld
netstat -anp |grep httpd
firewall-cmd --add-port=80/tcp
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-service=http
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
rm –rf /etc/httpd/conf.d/welcome.conf
systemctl restart httpd
cd /var/www/html #进入默认发布目录
mkdir 1 2 #创建对应的工作目录1和2
echo “hello,a.com” > 1/index.html
echo “hello,b.com” > 2/index.html #在1和2两个目录下放置两个静态网页,.html后缀
netstat -anp|grep 81
netstat -anp|grep 82 #这里选用的是81和82,都没有在使用
vim /httpd/conf.d/8182.conf #创建并编辑一个8182.conf,必须要以.conf后缀
##########
#里面的具体参数也可以参考主配置文件/etc/httpd/conf/httpd.conf写,下面的都是必要参数
listen 81
listen 82
<virtualHost *:81>
servername a.com #指定网页名称,可以不写,名字随意
documentroot /var/www/html/1 #指定服务路径,网站根目录
<directory"/var/www/html/1"> #服务路径内的配置
options Indexes followsymlinks #主页显示,优先index
allowoverride none
require all granted
</directory> #对应开头directory
</virtualHost> #本段结尾,对应virtualHost *:81
<virtualhost *:82>
servername b.com
documentroot /var/www/html/2
<directory"/var/www/html/2">
options Indexes followsymLinks
allowoverride None
require all granted
</directory>
</VirtualHost>
#同上,参数释义一致
##########
firewall-cmd --add-port=81/tcp
firewall-cmd --add-port=82/tcp
firewall-cmd --add-port=81/tcp --permanent
firewall-cmd --add-port=82/tcp --permanent
firewall-cmd --reload
httpd –t #必要检查命令步骤
systemctl restart httpd #若无报错,重启服务
curl 192.168.20.20:81 #回显a.com;
curl 192.168.20.20:81 #回显HTTP状态码和a.com
mkdir -p /work/html1
mkdir -p /work/html2
cd /etc/httpd/conf.d/
vim yuming.conf
##########
<VirtualHost *:80>
ServerName www.AA.com
DocumentRoot /work/html1
<Directory "/work/html1">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.BB.com
DocumentRoot /work/html2
<Directory"/work/html2">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
##########
echo "我是AA,你知道不" > /work/html1/index.html
echo "我是BB,你知道不" > /work/html2/index.html
vim /etc/hosts
##########
192.168.20.20 www.AA.com
192.168.20.20 www.BB.com
##########
httpd –t #必要检查命令步骤
systemctl restart httpd #若无报错,重启服务
firewall-cmd --add-port=80/tcp
firewall-cmd --add-port=80/tcp –permanent
firewall-cmd --reload
curl www.AA.com
curl www.BB.com
yum -y install php #PHP依赖于httpd
systemctl start httpd
systemctl enable httpd
firewall-cmd --add-port=80/tcp
firewall-cmd --add-port=80/tcp --permanent
echo "" > /var/www/html/index.php
或者:
rm -rf /etc/httpd/conf.d/welcome.conf
echo "" > /var/www/html/rrr.php
[root@test-CG ~]
Server MPM: prefork
以上是关于Apache:读音类似阿帕奇武装直升机.....的主要内容,如果未能解决你的问题,请参考以下文章