Ubuntu Server 从20.04升级到22.04

先更新一下包再重启一下

apt update
apt upgrade
reboot

然后升级系统

do-release-upgrade -d

升级过程中有要确认的选项直接默认回车就行了,大概十分钟就升级完成了

Ubuntu 22.04 升级到PHP8了,所以要改一下nginx的配置文件,把原来的7.4改成8.1,这样网站才能正常运行

fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;

打开网站后,WordPress会显示很多已弃用的警告,关闭debug就不会显示了,这些警告不会影响到网站

Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in .../wp-content/plugins/wordpress-seo/src/integrations/admin/helpscout-beacon.php on line 108
Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in .../wp-content/plugins/wordpress-seo/src/conditionals/third-party/elementor-edit-conditional.php on line 22
Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in .../wp-content/plugins/wordpress-seo/src/conditionals/third-party/elementor-edit-conditional.php on line 28
Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in .../wp-includes/functions.php on line 7035
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in .../wp-includes/functions.php on line 2164
Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in .../wp-includes/functions.php on line 7035
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in .../wp-includes/functions.php on line 2164
null to parameter #1 ($string) of type string is deprecated in .../wp-includes/formatting.php on line 2772

wp-config.php文件里关掉debug就不会显示了

define( 'WP_DEBUG', false ); 

我在Piwigo里,也会显示出相同的警告,编辑local/config/config.inc.php文件,加入下面的代码也可以关掉已弃用警告

$conf['show_php_errors'] = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING;

Piwigo 添加百度统计

复制代码到 /themes/主题名/template/footer.tpl 文件里,</body> 前面就好了

Piwigo 设置新建的相册默认为私有相册

编辑文件 /local/config/config.inc.php 文件

添加一行

$conf['newcat_default_status'] = 'private';

就OK了,新建的相册就不是公开的了,而且会自动将你的用户添加好权限

Piwigo 下载一个相册所有图片的方法

安装插件 Batch Downloader

然后在相册页的工具栏中找到一个“图标”,我的是最右边那个小小的长方形条条,不注意可能看不到。。。

然后就可以下载各个尺寸图像的zip文件了

piwigo把图片页的图片换成原图

piwigo的图片页默认输出的是压缩过的图,尺寸会小点,想换成原图的,找到主题目录下的 template 目录下的 picture_content.tpl 文件,换成下面的内容就行了

<script type="text/javascript">

	let url = '{$current.selected_derivative->get_url()}'

	if (url.substr(0,5) === '_data' || url.substr(0,5) === 'i.php') {

	let size = url.substring(url.lastIndexOf('.')-3, url.lastIndexOf('.'))

	let originLink

	if (size === '-me' || size === '-la' || size === '-xs'){

		// get original address

		originLink = url.replace('_data\/i\/','').replace('i.php?\/', '').replace(size, '')

	}

	document.write("<img src='" + originLink + "' alt='{$ALT_IMG}' />")

	} else {

		document.write("<img src='" + url + "' alt='{$ALT_IMG}' />")
	}

</script>

piwigo 手动升级

直接下载最新版覆盖即可,以下几个文件夹保留不要覆盖

  • galleries
  • upload
  • plugins
  • themes
  • template-extension
  • local
  • _data