官网Apache:www.apache.org
软件包:httpd
服务端口:80/tcp(http) 443/tcp(https,http+ssl)
配置文件:
/etc/httpd/conf/httpd.conf----主配置文件
/etc/httpd/conf.d/*.conf-------子配置文件
/etc/httpd/conf.d/welcome.conf-----默认测试页面
yum -y install httpd
systemctl start httpd
systemctl enable httpd
作用:在一台物理服务器上运行多个网站
基于IP地址
基于端口号
实现如下网站:
www.a.org /var/www/html/a.org
www.b.org /b.org
注意关闭firewalld和selinux(setenforce 0)
#mkdir /var/www/html/a.org
#vim /var/www/html/a.org/index.html
在index.html中编写网页内容
创建a.org的配置文件
#vim /etc/httpd/conf.d/a.org.conf
ServerName www.a.org
DocumentRoot /var/www/html/a.org
检测配置文件语法,重启服务
#httpd -t
#systemctl restart httpd
web客户机自建DNS,或者用修改hosts文件解析
#yum -y install elinks
#elinks www.a.org
#mkdir /b.org
#vim /b.org/index.html
创建b.org的配置文件
#vim /etc/httpd/conf.d/b.org.conf
ServerName www.b.org
DocumentRoot /b.org
Require all granted
检测配置文件语法,重启服务
#httpd -t
#systemctl restart httpd
web客户机自建DNS,或者用修改hosts文件解析
#yum -y install elinks
#elinks www.b.org
图示:
Apache : www.apache.org
软件包:httpd
服务端口:80/tcp (http) 443/tcp(https,http+ssl)
配置文件:
/etc/httpd/conf/httpd.conf-----主配置文件
/etc/httpd/conf.d/*.conf-------子配置文件
/etc/httpd/conf.d/welcome.conf //默认测试页面
#yum -y install httpd
#systemctl start httpd
#systemctl enable httpd
# sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
# setenforce 0
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https
# firewall-cmd --reload
#vim /var/www/html/index.html
1802test
输入ip地址测试是否成功
#vim /var/www/html/test.php
phpinfo();
>
输入10.18.41.22/test.php观察测试是否成功 答案:NO
上一步之所以测试不成功,是因为没有人解析动态语言
#yum -y install php //php作为Apache的模块
重启网站程序,调动PHP模块
#systemctl restart httpd
刷新查看10.18.41.22/test.php 会出现下图,证明成功
#yum -y install mariadb-server mariadb
#systemctl start mariadb.server
#systemctl enable mariadb.server
增强mysql-----为数据库设置密码
#mysql_secure_installation
Set root password [Y/n]
New password: 123
Re-enter new password: 123
手动测试账号密码。
[root@apache ~]# mysql -uroot -p123 //登录mariadb测试
MariaDB [(none)]> \q
[root@apache ~]# rm -rf /var/www/html/*
[root@apache ~]# vim /var/www/html/index.php
$link=mysql_connect('localhost','root','123');
if ($link)
echo "Successfuly";
else
echo "Faile";
mysql_close();
>
测试结果: php无法连接mysql 。因为缺少php连接mysql的工具
#yum -y install php-mysql
#systemctl restart httpd
[root@tianyun ~]# vim /etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd" //安装目录
Listen 80 //监听端口
IncludeOptional conf.d/*.conf //包含conf.d下的*.conf文件
User apache //运行Apache的用户
Group apache //运行Apache的用户组
DirectoryIndex index.html 或index.php //设置默认主页,用一个。
DocumentRoot //站点默认主目录
# sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
#setenforce 0
#systemctl stop firewalld.server
#systemctl disable firewalld.server
#yum -y install httpd mariadb-server mariadb php php-mysql gd php-gd
#systemctl start httpd mariadb
#systemctl enable httpd mariadb
#mysqladmin -u root password "123"
#vim /etc/httpd/conf.d/bijz.conf
ServerName www.bijz.com
ServerAlias bijz.com
DocumentRoot /var/www/html/bijz
Require all granted
#httpd -t ---配置文件语法检测
#systemctl restart httpd
#mkdir -p /var/www/html/bijz
#unzip ECShop_V3.0.0_UTF8_release0518.zip //官网下载
# cp -rf ECShop_V3.0.0_UTF8_release0518/* /var/www/html/bijz
#vim /etc/hosts
添加
10.18.41.22 www.bijz.com
#mysqladmin -u root password "123" -----创建数据库root的密码
#mysql_secure_installation ------修改数据库的密码
#mysql -uroot -p"123" ------登录数据库
>show databases ;
>create database bijz ;