1. 程式人生 > >How to Enable the GD Image Library for WordPress?

How to Enable the GD Image Library for WordPress?

很久以前還在用 php5 + wordpress 時,文章的縮圖都有自動被產生,某一次升級之後,縮圖功能就不見了。花了2小時Google 終於找到原因。

解法如下:

apt-get install php7.0-gd
phpenmod gd
/etc/init.d/php7.0-fpm restart

php restart 不同平臺的下法:

  • Using SysV Init scripts directly:
    /etc/init.d/php-fpm restart    # typical
    /etc/init.d/php5-fpm restart   # debian-style
    /etc/init.d/php7.0-fpm restart # debian-style PHP 7
    
  • Using service wrapper script
    service php-fpm restart    # typical
    service php5-fpm restart   # debian-style
    service php7.0-fpm restart # debian-style PHP 7
    
  • Using Upstart (e.g. ubuntu):
    restart php7.0-fpm         # typical (ubuntu is debian-based) PHP 7
    restart php5-fpm           # typical (ubuntu is debian-based)
    restart php-fpm            # uncommon
    
  • Using systemd (newer servers):
    systemctl restart php-fpm.service    # typical
    systemctl restart php5-fpm.service   # uncommon
    systemctl restart php7.0-fpm.service # uncommon PHP 7

我試了上面,重啟 apache2 + php7-fpm 之後,還是無效,刪掉放在我 wordpress 根目錄裡的 composer.json + composer.lock ,再重啟一次之後,重新產生縮圖,就看到縮圖跑出來了!