首先是选择系统,之前一直是用 ubuntu 14.04 minimal 的,毕竟喜欢折腾。。而Ubuntu软件全,apt-get方便。然后!!!重点来了,我把搬瓦工提供的所有debian系的系统都试了一次,安装mysql总是会出现不知名bug。。然后google了半天依然无法解决。。遂最终选择了Centos-6-x86-minimal。
再谈谈为什么我选择了Lighttpd和MySQL。选择Lighttpd的原因很简单,比Apache和Nginx都轻量化,虽然功能简单但完全够用了,在内存64M的机器上回节省宝贵的资源。然后为什么我不选SQLite,虽然我也知道SQLite就一个单文件,超级省内存,可是!!!宝宝完全不会转移啊。。试了各种方法。。总有各种各样的bug。为了以后博客的可移植性,只能放弃了。
一、安装
安装过程倒也挺简单的。
1. 安装EPEL源。参考EPEL官网EPEL Wiki
yum install epel-release
2. 安装MySQL
yum install mysql mysql-server
3. 安装phpMyAdmin
这里面安装依赖包的时候自动安装上了lighttpd和php,可以偷个小懒,嘿嘿~
yum install phpmyadmin
4. 安装lighttpd的fastcgi包
在安装phpmyadmin时没有安装;更新下php,以防有php-cli漏装导致后期错误
yum install lighttpd-fastcgi php
至此,安装部分完成,后面为配置部分,其实我还推荐安装一个nano,和vi/vim一样是个文本编辑器,可以Ctrl+W进行搜索,比较方便(好吧。。其实是我不会用强大的vi/vim。。捂脸)
二、配置
1. 配置MySQL
service mysqld start #首先启动一次mysql
chkconfig mysqld on #设置mysql开机启动
mysqladmin -u root password 'root' #设置mysql的root的账户的密码为root(自己改单引号里面的密码)
mysql -u root -p #以root账户登录mysql,回车后输入密码后再回车进入mysql
mysql> create database typecho; #在mysql里面建立一个数据库名为typecho,为后面安装typecho做准备
mysql> q #退出mysql
2. 配置Lighttpd
(1) 启用fastcgi
编辑/etc/lighttpd/modules.conf
文件,删掉 include "conf.d/fastcgi.conf"
这一行前面的注释,启用fastcgi
(2) 配置fastcgi
编辑/etc/lighttpd/conf.d/fastcgi.conf
文件,添加如下代码
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/var/run/lighttpd/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi"
)
)
)
若出现启动lighttpd时出现unlink /var/run/lighttpd/php-fastcgi.socket-0 after connect failed: Connection refused
错误,则运行如下代码并添加在开机自启脚本:
mkdir /var/run/lighttpd
touch /var/run/lighttpd/php-fastcgi.socket
chown -R lighttpd:lighttpd /var/run/lighttpd
(3) 调整lighttpd主配置
编辑/etc/lighttpd/lighttpd.conf
文件,删掉server.max-fds = 2048
这一行前面的注释,否则后期启动lighttpd时会出现报错。
(4) 设置lighttpd开机启动
chkconfig lighttpd on #开机启动lighttpd
#或使用
systemctl enable lighttpd #适用于CentOS7
3. 配置PHP/phpMyAdmin
(1) 添加phpMyAdmin软链接
ln -s /usr/share/phpMyAdmin /var/www/lighttpd
注意大小写,错了不行。lighttpd的默认路径是/var/www/lighttpd,把phpMyAdmin的位置软连接到网站空间地址下。
(2) 调整php主配置
编辑/etc/php.ini
文件,先把session.save_path = "/var/lib/php/session"
这一句注释掉。。虽然我也不知道为什么,但不注释掉会出现phpMyAdmin输入正确的用户名密码登陆,却只能原网页刷新的情况。再将session.auto_start
的值改为1(启动),默认是0(禁用),不然会出现phpMyAdmin打开报错的情况。
至此,全部安装配置完成。打开http://your ip/phpMyAdmin 即为phpMyAdmin的登陆界面。网站空间的位置就是默认的/var/www/Lighttpd下。在该路径下wget到typecho的安装包,解压出来是一个build的文件夹,把里面的所有文件mv到/var/www/lighttpd下,打开http://your ip/ 就可以进行安装了。。安装过程请参考tpyecho的wiki,很简单,几步就好了。
本文参考
Linux学习之CentOS(十三)–CentOS6.4下Mysql数据库的安装与配置 – xiaoluo501395377 – 博客园
CentOS7手动安装配置Lighttpd+PHP+MYSQL网站环境记录 | 老左博客
PHP fastcgi returns 403 on Lighttpd server – Stack Overflow
CentOS下Lighttpd Web服务器安装与配置方法
Linux中phpmyadmin的安装和配置 – 博客频道 – CSDN.NET
解决phpMyAdmin Cannot start session without errors错误-常见问题-Php教程-壹聚教程网
Lighttpd cannot create php-fastcgi.socket – Server Fault
I am in fact grateful to the owner of this website who has
shared this enormous piece of writing at at this place.
Just want to say your article is as astounding.
The clearness in your post is simply great and i could assume you’re an expert on this subject.
Well with your permission let me to grab your feed to keep up to date with forthcoming post.
Thanks a million and please keep up the enjoyable
work.