本文介绍使用Debian(stretch)+nginx(1.10)+typecho+sqlite3搭建轻量级博客系统。
环境:Debian(stretch)+nginx(1.10)+sqlite3
安装Debian stretch
我的debian系统是之前安装,一直在用。Debian系统的安装教程可参考官网或者直接百度一下。
安装nginx
命令行直接安装
sudo aptitude install nginx
配置nginx
修改/etc/nginx/sites-available下的default文件,修改后的文件内容如下:
server {listen 80 default_server;listen [::]:80 default_server;root /var/www;# Add index.php to the list if you are using PHPindex index.php index.html index.htm index.nginx-debian.html;server_name _;location / {# First attempt to serve request as file, then# as directory, then fall back to displaying a 404.try_files $uri $uri/ =404;}# pass PHP scripts to FastCGI server## location ~ \.php$ {location ~ .*\.php(\/.*)*$ {include snippets/fastcgi-php.conf;fastcgi_pass unix:/run/php/php7.0-fpm.sock;include fastcgi_params;}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one#location ~ /\.ht {deny all;}}
完成以上设置后,使用以下命令重启nginx。重启后可通过浏览器访问地址 http://server_domain_or_IP 测试nginx是否安装成功。
sudo service nginx restart
安装php-fpm
sudo aptitude install php7.0-fpm php7.0-cli php7.0-curl php7.0-sqlite3 php7.0-gd php7.0-xml php7.0-mcrypt php7.0-mbstring php7.0-iconv
在/var/www目录下新建info.php文件,访问地址 http://server_domain_or_IP/info.php 测试php是否安装成功。info.php文件内容如下。
<?phpphpinfo();?>
安装sqlite
使用以下命令安装sqlite并创建数据库文件。将数据库文件所在文件夹权限设置为777,否则后续安装typecho时会出现数据库无法连接的错误。
sudo aptitude install sqlite3 php-sqlite3sqlite3 typecho.db
安装typecho
进入/var/www目录,下载typecho最新版本,将解压后文件移动到/var/www目录下。将/var/www目录权限设置为777.
cd /var/wwwsudo wget -c /downloads/1.1-17.10.30-release.tar.gzsudo tar xvzf 1.1-17.10.30-release.tar.gzsudo mv build/* .chmod -R 777 /var/www
访问地址 http://server_domain_or_IP/install.php 安装并配置typecho。
如果php-fpm版本小于5.3.9,需要将/etc/php5/fpm/php.ini中的cgi.fix_pathinfo=0。
How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04
利用raspberry pi搭建typecho笔记(一) nginx PHP server quick start