centos7服务器结合lamp(linux+apach+mariadb+php)配置多站点
标签:Apache多站点
前言:其实要实现多站点很简单,就是利用Apache的虚拟主机文件来实现。
1、图省事直接 yum install httpd php -y
2、安装完成后的httpd、php默认配置文件在/etc下
3、修改/etc/php.ini文件,没有的可以加上
1 2 3 4 5 6 7 8 9 10 |
1). Ctrl+f 查找opcache.enable=1 设置为opcache.enable=0 2).Ctrl+f 查找 display_errors = Off 设置为 display_errors = On 3).Ctrl+f 查找 error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 设置为 error_reporting = E_ALL & ~E_DEPRECATED |
4、查看一下httpd配置文件结构
进入conf文件,开始配置虚拟主机。
5、修改httpd.conf文件
6、在配置文件尾部加入
1 2 |
# Virtual hosts Include conf/extra/httpd-vhosts.conf |
7、然后根据路径创建虚拟主机配置文件
8、 虚拟主机配置文件内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# Virtual Hosts # # Required modules: mod_log_config # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. Most configurations # use only name-based virtual hosts so the server doesn't need to worry about # IP addresses. This is indicated by the asterisks in the directives below. # # Please see the documentation at # <URL:http://httpd.apache.org/docs/2.4/vhosts/> # for further details before you try to setup virtual hosts. # # You may use the command line option '-S' to verify your virtual host # configuration. # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any <VirtualHost> block. # <VirtualHost *:80> ServerAdmin phpcms.youshop.top DocumentRoot "/var/www/html/phpcms" ServerName phpcms.youshop.top ServerAlias phpcms.youshop.top ErrorLog "logs/phpcms.youshop.top-error.log" CustomLog "logs/phpcms.youshop.top-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin tp.youshop.top DocumentRoot "/var/www/html/tp5/public" ServerName tp.youshop.top ServerAlias tp.youshop.top ErrorLog "logs/tp.youshop.top-error.log" CustomLog "logs/tp.youshop.top-access.log" common </VirtualHost> |
9、将域名做A记录解析到主机IP地址
最后要记得重启Apache服务器。