Typecho的搭建过程及问题解决
Typecho安装
LNMP环境+Typecho参考CentOS下Typecho的安装
配置
参考内容安装完成后,配置基本如下
nginx配置
默认配置目录
[root@10-23-159-191 conf.d]# cd /etc/nginx/conf.d^C
[root@10-23-159-191 conf.d]# ls
default.conf php.conf php-fpm.conf typecho.conf
default.conf
server {
listen 80;
server_name nginx.vkxx.com;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
php.conf
server {
listen 80;
server_name php.vkxx.com;
index index.php;
root /usr/share/nginx/php;
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
php-fpm.conf
# PHP-FPM FastCGI server
# network or unix domain socket configuration
upstream php-fpm {
server unix:/run/php-fpm/www.sock;
}
typecho.conf
需要注意如果fastcgi_pass不配置成和php-fpm.conf一样是unix:/run/php-fpm/www.sock
,可能会导致Typecho访问404
server {
listen 80;
server_name vkxx.com www.vkxx.com;
index index.php;
root /usr/share/nginx/typecho;
location ~ .*\.php(\/.*)*$ {
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?q=$1 last;
break;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Typecho配置
config.inc.php
注:其中注释掉的Logger.php
是后续自己扩展用于调试功能
<?php
/**
* Typecho Blog Platform
*
* @copyright Copyright (c) 2008 Typecho team (http://www.typecho.org)
* @license GNU General Public License 2.0
* @version $Id$
*/
/** 定义根目录 */
define('__TYPECHO_ROOT_DIR__', dirname(__FILE__));
/** 定义插件目录(相对路径) */
define('__TYPECHO_PLUGIN_DIR__', '/usr/plugins');
/** 定义模板目录(相对路径) */
define('__TYPECHO_THEME_DIR__', '/usr/themes');
/** 后台路径(相对路径) */
define('__TYPECHO_ADMIN_DIR__', '/admin/');
/* 日志功能
// 定义日志文件类型:txt文本,html网页,建议开发使用网页,便于查看
define('MINI_DEBUG_TYPE', 'html');
// 定义日志文件目录
define('MINI_DEBUG_PATH', __TYPECHO_ROOT_DIR__ . '/logs/');
*/
/** 开启HTTPS */
/** define('__TYPECHO_SECURE__',true);*/
/** 设置包含路径 */
@set_include_path(get_include_path() . PATH_SEPARATOR .
__TYPECHO_ROOT_DIR__ . '/var' . PATH_SEPARATOR .
__TYPECHO_ROOT_DIR__ . __TYPECHO_PLUGIN_DIR__);
/* 日志功能
require_once 'Logger.php';
*/
/** 载入API支持 */
require_once 'Typecho/Common.php';
/** 载入Response支持 */
require_once 'Typecho/Response.php';
/** 载入配置支持 */
require_once 'Typecho/Config.php';
/** 载入异常支持 */
require_once 'Typecho/Exception.php';
/** 载入插件支持 */
require_once 'Typecho/Plugin.php';
/** 载入国际化支持 */
require_once 'Typecho/I18n.php';
/** 载入数据库支持 */
require_once 'Typecho/Db.php';
/** 载入路由器支持 */
require_once 'Typecho/Router.php';
/** 程序初始化 */
Typecho_Common::init();
/** 定义数据库参数 */
$db = new Typecho_Db('Mysql', 'typecho_');
$db->addServer(array (
'host' => '127.0.0.1',
'user' => 'root',
'password' => '你的密码',
'charset' => 'utf8',
'port' => '3306',
'database' => 'typecho',
), Typecho_Db::READ | Typecho_Db::WRITE);
Typecho_Db::set($db);
安装问题
网页无样式问题
Typecho进入管理员,然后设置
->基本
里的站点地址
要填对就没问题了
无法提交评论(点击提交评论
界面刷新了却没反应)
<typecho目录>/var/Widget/Feedback.php
文件Widget_Feedback::comment
函数,注释以下两句
/**
* 评论处理函数
*
* @throws Typecho_Widget_Exception
* @throws Exception
* @throws Typecho_Exception
*/
private function comment()
{
// 使用安全模块保护
// 这个安全保护模块有问题,有空检查下 mark by jzl
//$this->security->enable($this->options->commentsAntiSpam);
//$this->security->protect();
无法上传附件
a.<typecho目录>/var/Typecho/Common.php
文件isAppEngine
函数更改为直接返回false
/**
* 检测是否在app engine上运行,屏蔽某些功能
*
* @static
* @access public
* @return boolean
*/
public static function isAppEngine()
{
return false;
/* 不能上传问题
return !empty($_SERVER['HTTP_APPNAME']) // SAE
|| !!getenv('HTTP_BAE_ENV_APPID') // BAE
|| !!getenv('HTTP_BAE_LOGID') // BAE 3.0
|| (ini_get('acl.app_id') && class_exists('Alibaba')) // ACE
|| (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) // GAE
;
*/
}
isAppEngine是判断是否为虚拟机什么的,虚拟机默认不支持上传附件
b.给附件文件夹权限
进入typecho目录
[root@10-23-159-191 typecho]# chmod -R 777 usr/uploads