解决wordpress标点符号无法正确显示的问题

不知道从哪一版WordPress开始,有些标点符号在编辑文章页面内输入是正确的,

但是发表文章后却是一团乱,会莫名其妙转成其他标点符号,影响实际使用。

尤其最近写了很多linux的文章,复制粘贴linux命令的时候,经常出错。

 

事实上这是因为「wptexturize()」这个PHP函数在作怪,

wordpress使用wptexturize()函数将纯文本字符转换成格式化的 HTML 实体。例如将‘–’转义为‘-’破折号。数据在数据库里保存的内容是‘–’,只是在显示的时候被自动转义成了-。对于一般写纯文字博客的人来说,这个自动将英文半角符号转换成全角符号,确实很方便、智能。但如果你经常要粘贴一些代码,而且没有使用专门的代码高亮插件,你会发现,你代码中的半角符号都会被转换成全角了。别人复制后,根本没办法直接使用。

我们可以通过WordPress的「Quotmarks Replacer」插件,

即可解决双引号或是其它符号乱掉的问题。

直接在安装插件页面,找到Quotmarks Replacer安装启用即可。

官方网站:https://wordpress.org/plugins/quotmarks-replacer/

 

ps,虽然可以通过「Raw HTML」或代码高亮插件来解决问题,但是用raw HTML,若你以前文章也有使用引号的话,那变成要慢慢查询看看哪边文章有使用引号,然后进入文章编辑,把可以使用引号的选项打勾,这样除了麻烦外,也是一件很没效率的事情,而且要求你熟悉html。代码高亮插件停用后会很多问题。所以我们可以直接透过「Quotmarks Replacer」来处理就可以了。

make编译phpredis扩展几个错误的解决办法

 

给php编译phpredis扩展,有几个乱七八糟的错误,终于解决。

记录下来,以后备用。(lnmp1.4环境)

1、将下载的包解压后,按照官方说明,要求

phpize
./configure [--enable-redis-igbinary]
make && make install

但是会出错,要把第二行替换为:

./configure -with-php-config=/usr/local/php/bin/php-config

2、make的时候会出现错误:

Makefile:193: recipe for target ‘redis.lo’ failed

google了半天,搜到个解决方案:

git clone https://github.com/phpredis/phpredis.git
cd phpredis/
git checkout php7
rm -f aclocal.m4

然后按第一步make即可。

3、修改php.ini文件,添加redis.so扩展

extension=//usr/local/php/redis.so

记得把redis.so文件具体路径写清楚。

开启Debian/Ubuntu root账户远程ssh登录

Debian 8.0(Jessie)安装完成后,默认root账户无法通过SSH远程登录到主机。

需要修改配置文件 /etc/ssh/sshd_config 搜索 /PermitRootLogin

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

PermitRootLogin without-password

修改为

PermitRootLogin yes

保存退出

重启sshd服务

/etc/init.d/ssh restart

然后就可以远程root登录Debian/Ubuntu了。

这是系统默认的一个安全的设置,为了防止他人通过暴力破解主机的root密码。

Accelerate WordPress with Redis

Do you have a website or blog powered by WordPress? Discover how to speed up loading, thanks to Redis! In this tutorial we set up a NoSQL Redis database, and use it to cache WordPress objects. The payload gains will be visible on your site for your visitors, but also in the administration of WordPress.
All actions performed in this tutorial are the responsibility of the Customer. OVH will not be held responsible for any failure. Remember to back up your files before making any changes.

This tutorial requires  :

  • A Web hosting compatible and with the module PHP -redis installed or installable ( an OVH shared Web hosting is currently not compatible ): VPS , Dedicated Server, Public Cloud .. at OVH or another  provider.
  • An administrator account on your WordPress, in order to install a  plugin.
  • WordPress version 4.x or  higher
  • And of course a database Redis, activable on our lab  !

WordPress + Redis =  ??

Redis is an open source tool to keep NoSQL databases in RAM and cache objects. The goal is speed. It is today constantly growing, adopted by Twitter, Github, Flickr, Pinterest and many others. We are not going to talk about Redis anymore, but do not hesitate to read the official documentation that is very well  provided.

WordPress, for its part, can be resource consuming. User sessions, database queries, … Their developers allow us to put these “objects” in cache, ie to store them non-  persistently.

You will understand, the gains will be more or less significant depending on your use of “objects”. A site with static content, such as a blog, will be much less optimizable than a merchant site, an information portal, and  so on.

There are a multitude of plugins to manage this cache, the best known being W3 Total Cache ( W3TC ). However, it does offer a cache of objects locally (on your VPS , or server), which sometimes does not suit us. Maintaining a redis or memcached database can be tedious and  memory consuming .

We will see in this tutorial how to configure the Redis Lab proposed by OVH , and link it to your WordPress. The goal is to increase performance when loading WordPress for visitors, but also for its  administrators.

Let’s go !

Join the Lab and test its base  Redis

The first step is to get a Redis database and check its  operation.

Direction Runabove OVH labs then subscribe to Lab Redis. Once done, via the Sunrise OVH Manager , create a Redis database, change the password, and keep the page open, we will  use it.

Redis Sunrise manager

Test the connection to Redis from a  terminal

Open your favorite terminal, and log in to your Redis database command line  :

1
Redis-cli -h my-instance-url -p my-port

For my part it looks like  :

1
Redis-cli -h 950c9520-ed3c-492c-8e0a-c1xxxxxxxxxx.pdb.ovh.net -p 21244

Then authenticate with the password set in your OVH Sunrise Manager . Redis works with a unique password, no User  required ..

1
Auth MyPassWord

And finally, let’s monitor what happens on your Redis base  :

1
Monitor

We will see here what happens on your live  base.

At this point, the only thing we know is that the Redis base is running! Let’s see if we can connect to it in PHP . 

Test the connection to Redis from its  WordPress site

On your instance hosting your WordPress, we will test the connection to Redis with a very  fast script .

Via the medium of your choice ( FTP , SSH , ..) create a phpinfo.php file at the root of your wordpress site and add in it  :

1
2
3
<? Php 
    phpinfo (); 
?>

Then go to http://www.mywebsite.com/wordpress/phpinfo.php (to change according to your configuration) and look for  :

PHPinfo and RedisThis module allows PHP to interact with the Redis database. If you can not find any paragraph about Redis, you are missing the component. Install it (Debian / Ubuntu compatible command)  :

1
Sudo apt-get install php-redis

You should see the Redis box (if necessary, update PHP and restart your  instance).

Let’s now test the connection to Redis in PHP , from your hosting. Via the medium of your choice ( FTP , SSH , …), create a file redis.php at the root of your wordpress site and add in  :

1
2
3
4
5
6
7
8
9
 <? Php 
     // Connecting to Redis server on OVH 
     $ redis  =  new  Redis (); 
     $ Redis -> connect ( 'xxxxxxxxx-xxxxxx-xxxxx-xxxxxxxxx.pdb.ovh.net' ,  12345 ); 
     $ Redis -> auth ( 'MyPassword' ); 
     Echo  "Connection to server ongoing" ; 
     // check whether server is running or not 
     echo  "Server is running" . $ Redis -> ping (); 
?>

Do not forget to fill in the access URL , port and password of your database, entered in your OVH Sunrise Manager . Then go to http://www.mywebsite.com/wordpress/redis.php .

If the connection is successful, you should see “Server is running:  + PONG

And in your terminal open on your Redis base, a  PING

Congratulations! Everything works based. We now move on to configuring  WordPress.

Configuring WordPress with  Redis

The database works, remains to configure WordPress to use it. If you already have a cache plugin, you may want to disable the Object Cache ( for example, W3TC  ).

Changing WPCONFIG . PHP

Via a text editor, open the wp-config.php file at the root of your WordPress. We’re going to add those 3 lines right after the Key  Salts.

1
2
3
Define ('WP_REDIS_HOST', '950c9520-ed3c-492c-xxxxx-xxxxxxxxxx.pdb.ovh.net'); 
Define ('WP_REDIS_PORT', '12345'); 
Define ('WP_REDIS_PASSWORD', 'MyPassword')

Optional: add a Key Salt. When you have a single application that uses Redis this is not necessary, but if for example you have multiple WordPress sites, this will be required to differentiate who-push-what .

1
Define ('WP_CACHE_KEY_SALT', 'myvps_');

Installing the Redis Object  Cache plugin

Redis Object Cache infoThen, in order to facilitate our task, we will install the Redis Object Cache plugin . For the curious, it is a fork of the code of Eric Mann and Erick Hitter: Github Redis Object  Cache .

If you are allergic to plugins, feel free to do a manual installation (note the names of params that are substantially different in WPCONFIG . PHP ) 

This plugin will add a file (or modify) the file object-cache.php in the wp-content / folder of your WordPress. If the plugin fails to do so, add it manually (see the plugin page for  details).

Plugin settings

If everything is installed, go to your WordPress Admin for  Redis.

You should see something like this  :

Note the “Connected” status and your Host, Port, Database and Password well  informed.

Redis Object Cache infoEverything is clean  !

Checking earnings  performance

If you have not closed the monitoring of your Redis database, you should see activity on your  base.

Open a second terminal or stop this monitoring, and on your Redis base enter  :

1
Keys *

This will allow you to parse all key-value sets stored in Redis. In my case  :

1
2
3
4
5
6
7
8
...
48 )  "myvpswp_ how: get_comments: 9503889e74633f729bf0ed7217c233a4: 0.53134300 1486125318" 
49 )  "myvpswp_ how: 1" 
50 )  "myvpswp_: term_meta: 1" 
51 )  "myvps_wp_: userlogins: bastien" 
52 )  "myvpswp_: transient: feed_b9388c83948825c1edaef0d856b7b109" 
53 )  "myvpswp_: posts: 1"
...

And to analyze a specific key as an example  :

1
Get myvpswp_: posts: 1

At the performance level, I opened the development tools and then “Network”. Being part of a WordPress totally clean and without content, I do not have a very significant gain but still appreciable  !

The site is displayed in 250ms on average instead of 500ms (hosted on a VPS SSD OVH located in  Strasbourg).

Chrome Network toolDo not hesitate to share your feedback on your tests  !

将新版shadowsocks编译deb安装

apt-get install git

Get the latest source code

To get the latest source code, you should also update the submodules as following:

git clone https://github.com/shadowsocks/shadowsocks-libev.git cd shadowsocks-libev git submodule update –init –recursive

sh -c printf “deb http://httpredir.debian.org/debian jessie-backports main” > /etc/apt/sources.list.d/jessie-backports.list
apt update
apt -t jessie-backports install libmbedtls-dev libsodium-dev

apt-get install –no-install-recommends gettext build-essential autoconf automake libtool \ gawk debhelper dh-systemd init-system-helpers pkg-config asciidoc xmlto apg libpcre3-dev \ libev-dev libudns-dev dh-autoreconf ./autogen.sh && dpkg-buildpackage -b -us -uc -i cd .. dpkg -i shadowsocks-libev*.deb

然后正常修改配置文件,开启服务即可。

nano /etc/shadowsocks-libev/config.json /etc/init.d/shadowsocks-libev start

给linux(linode)vps更换内核以支持bbr

注意,需要root权限,非root登陆请su。

linode需要edit profile,选择grub2启动。

下载内核:

wget O linuximage4.9.10amd64.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9.10/linux-image-4.9.10-040910-generic_4.9.10-040910.201702141931_amd64.deb

安装:dpkg -i linux-image-4.9.10-amd64.deb

查看当前已安装内核:dpkg -l|grep linux-image | awk ‘{print $2}’

删除旧的:apt-get purge 旧内核名称

如果提示你是否终止删除内核的行为,选择 NO

更新引导:update-grub
重启:reboot

开启bbr:

echo “net.core.default_qdisc=fq” >> /etc/sysctl.conf

echo “net.ipv4.tcp_congestion_control=bbr” >> /etc/sysctl.conf

sysctl p

执行下面命令,如果结果中有bbr,即证明你的内核已开启bbr。

sysctl net.ipv4.tcp_available_congestion_control

执行下面命令,看到有 tcp_bbr 模块,即说明bbr已启动

lsmod | grep bbr

安装Tokumx出现NO_PUBKEY 9334A25F8507EFA5的解决办法

昨天安装Tokumx 时出错。

提示:
W: GPG error: http://repo.percona.com jessie InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 9334A25F8507EFA5

后来查询发现是因为他们更新了key,却没有在网页说明上改过来。。。

使用如下命令更新:

apt-key adv –keyserver keys.gnupg.net –recv-keys 8507EFA5

apt-get update

然后正常apt-get install tokumx-enterprise即可。

debian下给shadowsocks 启用 chacha20 加密

apt-get install build-essential

wget https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz

tar xf libsodium-1.0.11.tar.gz && cd libsodium-1.0.11

./configure && make && make install

ldconfig

然后修改/etc/shadowsocks.json即可。

在debian中禁用ipv6

有些vps,比如linode,默认开启ipv6,但是其他的很多不支持,很不方便,关掉更方便。

使用 /proc

这是#关闭所有接口的 IPv6 功能

echo "1" > /proc/sys/net/ipv6/conf/all/disable_ipv6

关闭指定网卡的 IPv6 功能

echo "1" > /proc/sys/net/ipv6/conf/ethx/disable_ipv6

使用 modprobe ,禁用 IPv6

编辑

vim /etc/modprobe.d/aliases

输入

alias net-pf-10 off
alias ipv6 off

编辑

vim /etc/modprobe.d/blacklist

输入

blacklist net-pf-10
blacklist ipv6

利用 GRUB 添加启动参数, 禁用 IPv6

编辑

vim /etc/default/grub

找到

GRUB_CMDLINE_LINUX_DEFAULT="quiet"

替换为

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet"

使用sysctl

对于squeeze及其后的版本,ipv6已被内核支持,所以可以通过sysctl来关闭它。可以使用以下命令:

echo 'net.ipv6.conf.all.disable_ipv6=1' > /etc/sysctl.d/disableipv6.conf

让ipv4优先于ipv6

一些系统中是ipv4和ipv6并存,而且ipv6优先于ipv4。但机房可能并暂时没有实际分配ipv6,所以我们也可以不要关闭ipv6,记ipv4优先于ipv6即可。输入如下命令:

echo "precedence ::ffff:0:0/96 100">>/etc/gai.conf

当然也可以直接修改

/etc/gai.conf

找到

#precedence ::ffff:0:0/96  100

把前面的”#”去掉即可。