Make a confession website

Apache basic configuration

vim etc / httpd / conf / httpd.conf
ServerRoot "etc / httpd" // Installation directory
Listen 80 // Listening port
User apache //
User group running apache // User group running Apache
DirectoryIndex love.html love.php // Set the default homepage
DocumentRoot // The site's default home directory
IncludeOpetional conf.d / *. Conf // Include the * .conf file under conf.d

Start to make a confession website

It's easy! ! !

Install packages

[root@bogon ~]# yum -y install httpd php gd php-gd

After starting the httpd service, set the firewall and close seLinux

[root@bogon ~]# firewall-cmd --add-port=8080/tcp permanent
[root@bogon ~]# firewall-cmd --add-service=httpd --permanent
[root@bogon ~]# firewall-cmd --reload

If you do n’t have your own domain name and server, you can only limit it to local, configure hosts resolution

192.168.140.150 www.cgp240.top
192.168.140.150 cgp240.top


Configure Apache Virtual Host

(Flexible configuration as required)

[root@bogon ~]# vi /etc/httpd/conf.d/love.conf
<VirtualHost *:8080>  #所有端口的80端口
        ServerName www.cgp240.top  #网站域名
        ServerAlias chp240.top  #网站别名
        DocumentRoot /web/love.html # apache默认的站点目录,路径结尾不要添加斜线
        ServerAdmin amyliyanice@163.com    # 服务管理员邮箱地址,出问题时发送邮件到这个邮箱
        ErrorLog "logs/wx.dev.log"         # 错误日志
</VirtualHost>

<Directory "/web/love.html"> #站点目录(以下为默认站点目录的限制,如果读者私自配置了站点目录而没有配置这里就会出现 403错误)
        Require all granted #对目录授权
        AllowOverride None #表示禁止用户对目录配置文件(.htaccess进行修改)重载,尽量不开启.htaccess 安全隐患大,规则多了网站访问性能低
        Deny from all #拒绝所有访问
</Directory>

Put the source code in the specified directory and rename it

[root@bogon web]# mv love/ love.html/

Port 80 can be used for the record, you need to modify the httpd.conf file

[root@bogon web]# vi /etc/httpd/conf/httpd.conf 

ServerName localhost:8080
Listen 8080

check for errors

[root@bogon ~]# httpd -t
Syntax OK

ok, restart httpd, the
following is the first website I set up. It is dedicated for confession.

www.cgp240.top

Released eight original articles · won praise 5 · Views 2395

Guess you like

Origin blog.csdn.net/qq_46341303/article/details/105340281