咸的蛋蛋疼,看到炫Q 大佬在香蕉派上搭建了一个蜜汁鞋盒博客,心里痒痒,就在OrangePi PC上搭建了一个Nginx+PHP7.2+Sqlite3的Typecho blog,虽然自己已经有了个博客周海棠啦。
- demo For OpiPC
换源[OS:Armbian]
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main multiverse
安装PHP7、Sqlite
sudo apt update && sudo apt-cache search php
# 可以看出官方源里面最新的php版本是7.2
sudo apt-get install php7.2-cgi php7.2-fpm php7.2-curl php7.2-gd php7.2-mbstring php7.2-xml php7.2-sqlite3 sqlite3 -y
安装Nginx
sudo apt install nginx
sudo systemctl restart nginx
Nginx配置
# 默认存放html的位置 /var/www/html
sudo nano /etc/nginx/sites-available/default
# 害怕修改错,可以备份到 /home/xx/default
cp /etc/nginx/sites-available/default /home/xx/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html index.php;
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;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
client_max_body_size 256m;
}
# 修改完一定要重启
sudo systemctl restart nginx
修改上传文件大小限制
sudo nano /etc/php/7.2/fpm/php.ini
# 每个脚本运行的最长时间,单位秒,0为无限
max_execution_time = 0
# 每个脚本可以消耗的时间,单位也是秒
max_input_time = 300
# 脚本运行最大消耗的内存
memory_limit = 256M
# 表单提交最大数据为 8M,针对整个表单的提交数据进行限制的
post_max_size = 20M
# 上载文件的最大许可大小
upload_max_filesize = 10M
下载Typecho
wget http://typecho.org/downloads/1.1-17.10.30-release.tar.gz
tar -zxvf 1.1-17.10.30-release.tar.gz
cp build/* /var/www/html
# 可能html目录下没有权限,简单粗暴点
sudo chmod 777 html/
配置Tyoecho
直接输入ip 192.168.1.154,会自动跳转到设置页面,如果提示数据库错误数据库,没有权限。请自己用 chmod 777 xxx解决
后台出现404
sudo nano /etc/nginx/sites-available/default
# 修改 location ~ \.php$ {
# 为
location ~ .*\.php(\/.*)*$ {
# 修改完一定要重启
sudo systemctl restart nginx
开启伪静态
sudo nano /etc/nginx/sites-available/default
# 添加如下代码,然后在后台设置里永久链接中开启伪静态
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
# 修改完一定要重启
sudo systemctl restart nginx