CentOS 7.6 上 Typecho 的安装(VirtualHost+git+SSL)

先试试 HTTP 的

[root@pluvet ~]# cd /etc/httpd/conf.d

[root@pluvet conf.d]# vi pluvet-vhost.conf

<VirtualHost *:80>

        DirectoryIndex index.html index.php

        ServerName pluvet.com
        ServerAlias www.pluvet.com
        DocumentRoot /var/www/pluvet.com

        ErrorLog "/var/log/httpd/pluvet.com/error.log"
        CustomLog "/var/log/httpd/pluvet.com/common.log" combined
</VirtualHost>

[root@pluvet ~]# mkdir /var/www/pluvet.com && chown apache $_
[root@pluvet ~]# mkdir /var/log/httpd/pluvet.com/ && chown apache $_

[root@pluvet conf.d]# apachectl restart

[root@pluvet conf.d]# cd /var/www/pluvet.com/
[root@pluvet pluvet.com]# sudo -u apache vi index.php

<?php echo "ok"; ?>

访问:http://www.pluvet.com/
结果:ok

现在可以上 SSL 了

[root@pluvet ~]# cd /etc/httpd/conf.d
[root@pluvet ~]# ls
autoindex.conf  php.conf  phpMyAdmin.conf  pluvet-vhost.conf  README  ssl.conf  userdir.conf  welcome.conf

[root@pluvet conf.d]# vi pluvet-vhost.conf

<VirtualHost *:80>
        ServerName pluvet.com
        ServerAlias www.pluvet.com
        Redirect / https://www.pluvet.com/
</VirtualHost>
<VirtualHost *:443>

        DirectoryIndex index.html index.php

        ServerName pluvet.com
        ServerAlias www.pluvet.com
        DocumentRoot /var/www/pluvet.com

        SSLEngine On
        SSLCertificateKeyFile /etc/httpd/conf/ssl/pluvet.com.key
        SSLCertificateFile /etc/httpd/conf/ssl/pluvet.com.crt

        ErrorLog "/var/log/httpd/pluvet.com/error.log"
        CustomLog "/var/log/httpd/pluvet.com/common.log" combined
</VirtualHost>

[root@pluvet conf.d]# vi /etc/httpd/conf/ssl/pluvet.com.key
[root@pluvet conf.d]# vi /etc/httpd/conf/ssl/pluvet.com.crt

[root@pluvet conf.d]# apachectl restart

[root@pluvet conf.d]# yum install git -y
[root@pluvet conf.d]# cd /var/www/pluvet.com
[root@pluvet conf.d]# rm index.php -f
[root@pluvet pluvet.com]# git clone https://github.com/typecho/typecho.git
[root@pluvet pluvet.com]# mv typecho/* .
[root@pluvet pluvet.com]# rm typecho -rf
[root@pluvet pluvet.com]# vi .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

[root@pluvet pluvet.com]# chown -R apache .
[root@pluvet pluvet.com]# chcon -R -t httpd_sys_rw_content_t .
[root@pluvet pluvet.com]# vi /etc/httpd/conf/httpd.conf

找到:

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

改为

<Directory "/var/www">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
[root@pluvet pluvet.com]# apachectl restart

访问:
https://www.pluvet.com/install.php
正常安装即可。

发表留言

本站启用了垃圾评论检测插件,如果误删请联系我~