Linux: Apache server build

Download and install and start the apache service

安装apache服务
yum  install  -y  httpd
启动apache服务
systemctl  start  httpd.service
The directory and the files will be stored apache server

/ etc / httpd / conf: This directory contains the Apache server configuration file
/ var / www / html: This is the default directory site root directory of the Apache server
/ etc / httpd / logs: Apache server's log file directory

Apache server is installed successfully test

Test localhost: in the address bar of your browser

Publish a single Web site

The site directory into / var / www / heml / directory

Modify the configuration file
Vim/etc/httpd/conf/httpd.conf
修改:DocumentRoot "/var/www/html/"
DocumentRoot "/var/www/html/站点目录名称"
修改完配置文件后必须要重启服务:systemctl restart httpd
Site personalization
例如:我放入的网站名称为:exam
网站部署完成后,考虑到站点是内部网站,为了保证安全,将首页改为exam.html,并使用8080端口访问。
改首页名字:#mv /var/www/html/exam/index.html /var/www/html/exam/exam.html
修改配置文件:Vim/etc/httpd/conf/httpd.conf
Listen 8080
DirectoryIndex exam.html index.html
重启服务:systemctl restart httpd
访问测试:ip地址:8080

Posted by Web Hosting Site

Based virtual hosting

domain registration

域名注册,在/etc/hosts中追加一行:
192.168.75.128 exam.excesoft.com 
域名测试:ping exam.excesoft.com

Page in your site

将两个网站放到/var/www/html/目录下

Modify the configuration file

修改主配置文件:vim /etc/httpd/conf/httpd.conf
Listen 80
DirectoryIndex  index.html
在末尾增加:Include conf/vhost/*.conf
vhost目录具体位置: /etc/httpd/conf
vhost 需自己创建

Create a domain configuration file

在/etc/httpd/conf    目录下新建vhost目录,并在下面新建exam.conf与attendance.conf两个
域名配置文件,并作如下编辑。
#vim exam.conf
<VirtualHost 192.168.75.128>
//配置访问的ip地址
ServerName exam.excesoft.com
//设置域名
DocumentRoot /var/www/exam/
//设置路径
<Directory “/var/www/exam/”>
//设置路径
Options Indexes FollowSymLinks   //显示网页文件列表
AllowOverride NOne               //忽略.htaccess 文件
Require all granted              //允许所有
</Directory>
</VirtualHost>

Check the configuration is correct

使用httpd -t检查虚拟主机的配置是否正确

Restart Apache and testing services

IP address-based virtual hosts
域名注册参考基于域名的虚拟主机设置
(1)设置多个IP地址
(2)域名注册
(3)修改主配置文件:vim /etc/httpd/conf/httpd.conf
Listen 80
DirectoryIndex  index.html
在末尾增加:Include conf/vhost/*.conf
(4)为每个主机新建配置文件并定义一个<VirtualHost>容器
(5)重启Apache服务器并进行测试

Guess you like

Origin www.cnblogs.com/yanlzy/p/11914774.html