暗中观察

CentOS typecho 安装 (theme handsome)
nginx+php+mysql+typecho+handsome1.安装nginx(tengine)2.安装mys...
扫描右侧二维码阅读全文
26
2018/08

CentOS typecho 安装 (theme handsome)

nginx+php+mysql+typecho+handsome

1.安装nginx(tengine)

2.安装mysql

$ mysql -uroot -p
$ CREATE DATABASE handsome DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
$ create user 'handsome'@'localhost' identified by 'handsomedbpasswd';
$ grant ALL PRIVILEGES on handsome.* to 'handsome'@'localhost' identified by 'handsomedbpasswd';
$ flush PRIVILEGES;

ps:mysql5.7以上设置sql_mode,否则handsome主题留言板功能打不开!

# 编辑配置文件加入sql_model后重启mysqld
$ vi /etc/my.cnf
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

3.安装php环境

yum install -y epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y php72w-fpm php72w-opcache php72w-bcmath php72w-cli php72w-common php72w-gd php72w-mbstring php72w-mysqlnd php72w-pdo php72w-xml php72w-mbstring
# 重启
systemctl restart php-fpm

4.关联nginx和php


#ps: 证书路径 /usr/local/nginx/conf/cert/cn/
#    项目路径 /data/www/web
#编辑
$ /usr/local/nginx/conf/nginx.conf加入:
include vhosts/*.conf;

$ mkdir -p /usr/local/nginx/conf/vhosts/www.sunjianhua.cn.conf
#加入以下内容
server {
         listen 80;
         server_name www.sunjianhua.cn sunjianhua.cn;
         rewrite ^(.*) https://www.sunjianhua.cn$1 permanent;
}


server {
    listen 443;
    server_name sunjianhua.cn www.sunjianhua.cn;
    ssl on;
    root /data/www/web;
    charset utf-8;
    index index.php index.html index.htm;
    ssl_certificate   "/usr/local/nginx/conf/cert/cn/sunjianhua.cn.pem";
    ssl_certificate_key  "/usr/local/nginx/conf/cert/cn/sunjianhua.cn.key";
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #Э
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#
    
    ssl_prefer_server_ciphers on;
    
    location / {
        index  index.php index.html index.htm;
        if (!-e $request_filename) {
            rewrite ^(.*)$ /index.php$1 last;
        }
    }
    location ~ \.php {
        include fastcgi_params;
        set $path_info "";
        set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                set $real_script_name $1;
                set $path_info $2;
        }
        fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_intercept_errors on;
        fastcgi_read_timeout 240;
        fastcgi_connect_timeout 300s;
        fastcgi_pass   127.0.0.1:9000;
    }
    
    location ~ /\.ht {
        deny  all;
    }
}    

5.安装typecho

$ mkdir -p /data/www/web
$ wget http://typecho.org/downloads/1.1-17.10.30-release.tar.gz
$ tar -zxvf 1.1-17.10.30-release.tar.gz -C /data/www/web
$ mv /data/www/web/build/* /data/www/web/ && rm -rf /data/www/web/build/

#确保上述正确安装后,重启下所有服务:
systemctl restart nginx
systemctl restart mysqld
systemctl restart php-fpm
#地址栏访问一下网址,填入数据库信息,安装即可完成!
https://www.sunjianhua.cn/install.php

6.设置handsome主题

#上传handsome主题包到以下路径
/data/www/web/usr/themes/

#登录后台,启用即可,如下图:

enable_theme_handsome.png

7.常见问题

sina防盗链: 临时解决办法,nginx设置:add_header Referrer-Policy "no-referrer";

最后修改:2019 年 06 月 22 日 03 : 37 PM
如果觉得我的文章对你有用,请随意赞赏

发表评论