使用VPS安装Lighttpd + PHP + SQLite搭建typecho个人博客
目录
在网上搜了多篇博文参考,搭建了这个博客,特写此文记录
- 系统为 Debian 7 32 位系统,经测试64位也是可以安装成功,ubuntn上安装失败,其它系统未测试
一、搭建博客运行环境
更新源的索引和软件
apt-get update -y apt-get upgrade -y安装Lighttpd,SQLite和PHP
apt-get install sqlite lighttpd php5-cgi php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
配置 PHP.INI 文件
vi /etc/php5/cgi/php.ini
- 找到 cgi.fix_pathinfo=1,把前面的;去掉。在更换系统后,把Lighttpd,SQLite和PHP环境搭建好之后,上传整个博客,登
陆即可使用,如果为0,登陆显示找不到制定文件

打开lighttpd.conf
cd /etc/lighttpd
vi lighttpd.conf
替换以下内容,其实就多了后面两段内容.注意请将
$HTTP["host"] =~ "(^|.)ss.com$"中的ss.com替换为你的域名
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_rewrite",
)
server.document-root = "/var/www/html"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
$HTTP["host"] =~ "(^|\.)ss.com$" {
server.document-root = "/var/www/html"
accesslog.filename = "/var/www/access.log"
server.error-handler-404 = "/404.html"
}
url.rewrite = (
"^/(admin|usr)/(.*)" => "/$1/$2",
"^/(.*).html$" => "/index.php/$1.html",
"^/archives/(.*)" => "/index.php/archives/$1",
"^/category/(.*)" => "/index.php/category/$1",
"^/([0-9]+)/([0-9]+)/$" => "/index.php/$1/$2/",
"^/tag/(.*)/$" => "/index.php/tag/$1",
"^/search/(.*)/$" => "/index.php/search/$1",
"^/(.*)page/(.*)" => "/index.php/$1page/$2",
"^/(feed.*)" => "/index.php/$1",
"^/action/(.*)" => "/index.php/action/$1",
"^/(.*)comment" => "/index.php/$1/comment"
)
在当前路径下,复制 fastcgi 相关文件
cd conf-enabled
cp ../conf-available/*fastcgi* .
- 至此运行环境就搭建完成了
二、安装typecho
将 typecho 的文件放到自己设定的网站根目录 (/var/www/ss), 设置目录
cd /var mkdir www cd www mkdir ss cd html apt-get install wget wget https://github.com/typecho/typecho/archive/v1.1-15.5.12-beta.zip apt-get install zip unzip unzip v1.1-15.5.12-beta.zip mv typecho-1.1-15.5.12-beta/* . rm -rf v1.1-15.5.12-beta.zip rm -rf typecho-1.1-15.5.12-beta chown -R www-data.www-data /var/www/ss重启 Lighttpd
/etc/init.d/lighttpd restart
- 在浏览器输入刚才设置的域名(解析好的域名),就跳出出安装的界面,安指示安装即可
三、在此环境下的博客搬家
比如上面我们的博客的根目录是/var/www/ss,那么只要备份ss这个文件夹(打包下载到电脑),我们到新的VPS上部署好Lighttpd + PHP + SQLite环境后,创建www文件夹,把备份的typecho程序ss上传解压,输入所填的域名,就会出现typecho后台登陆界面,输入原来的用户名和密码登陆,一切都恢复了
四、安装时出现无法链接数据库解决办法
新建数据库与表,并将数据库所在目录指向这个文件来解决的,不过这个问题的本质并不是数据库文件不存在,事实上typecho是可以自己新建数据库文件的,这个问题之所以出现是因为typecho没有对该目录的写权限而导致的问题.
可以通过
chmod -R 777 /var/www
来解决.不过这里的777过于极端,单纯是是为了确认typecho可以正常工作才设定的,这里的777意味着给予所有人(包括others)R W E的全部权限,这实际上是不合理的,按照官方文档,755就够用了
最后更新于 2017-12-11 13:19:04 并被添加「」标签,已有 112 位童鞋阅读过。
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处