Typecho个人博客搭建

PHP7.4的安装

借鉴此篇

在CentOS 7系统上安装PHP 7.4版本的方法

为yum添加EPEL和REMI存储库

sudo yum install epel-release
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

安装PHP7.4

启用存储库

sudo yum -y install yum-utils
yum repolist all | grep php
sudo yum-config-manager --enable remi-php74

安装PHP7.4及其扩展

sudo yum install php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis

检查安装是否成功

php -v

VeryNginx配置

似乎是因为VeryNginx的面板并不支持FastCGI这样的设置,无论在静态后端还是反向代理中进行设置,均会在访问PHP页面时直接触发浏览器下载功能。因此放弃在面板中进行设置,删去或禁用所有与blog页面有关的过滤及代理,转向nginx.conf的设置。

# /opt/verynginx/openresty/nginx/conf/nginx.conf
server {
	server_name blog.chen-kai.fun;
		listen	443 ssl;
		listen	[::]:443 ssl;
		#this line shoud be include in every server block
		include /opt/verynginx/verynginx/nginx_conf/in_server_block.conf;

		ssl_certificate	/www/cert/*.chen-kai.fun/fullchain.cer;
		ssl_certificate_key /www/cert/*.chen-kai.fun/*.chen-kai.fun.key;
	location / {
		root /www/data;
		index index.php;
	}
	location ~ .*\.php(/|$) {
		root /www/data;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
	}
	error_page 404 /404.html;
	location /404.html {
		root /www/data;
	}
}

重启Nginx:

/opt/verynginx/openresty/nginx/sbin/nginx -s reload

安装Typecho

直接访问your.domain.com,首次将直接跳转至install.php,进入安装向导。

按照向导顺序安装即可完成安装。

如果选择SQLite时提示对不起,无法连接数据库,请先检查数据库配置再继续进行安装,则说明\www\data目录权限设置错误,需将该目录拥有者设置为Apache用户组中的Apache用户。


最后修改于 2021-04-05