操作系统版本:Ubuntu 18.04
问题1:安装apache2和php后无法解析php,即php直接以文本文件显示出来。
需要修改apache2配置文件:
1 2 3 4 5 6 7 8 9 10 |
root@chen:~# tail -8 /etc/apache2/apache2.conf <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> LoadModule php7_module modules/libphp7.so AddType application/x-httpd-php .php DirectoryIndex index.php index.htm index.html root@chen:~# |
但重启apache2显示找不到libphp7.so。原来是这个库要单独装:
1 |
root@chen:~# apt install php libapache2-mod-php php-mysql |
问题2:无法发布任何东西:“Publishing failed. Error message: The response is not a valid JSON response.”
bug,最新的Gutenberg编辑器竟然是默认的。另外简单禁用Gutenberg也不好使,需要安装classic editor并启用才是真正禁用掉Gutenberg
问题3:永久链接无效。
打开rewrite选项:
1 2 3 4 5 |
root@chen:~# a2enmod rewrite Enabling module rewrite. To activate the new configuration, you need to run: systemctl restart apache2 root@chen:~# |
修改apache2配置:
1 2 3 4 5 6 7 8 9 |
root@chen:~# cat /etc/apache2/apache2.conf | grep "AllowOverride all" -a3 <Directory /var/www/> Options FollowSymLinks Multiviews MultiviewsMatch Any AllowOverride all Require all granted </Directory> root@chen:~# |
问题4:上传限制为2M。
有人说是修改php.ini,实测无效。另外系统里进行了php的升级以后会有很多个php.ini,这个命令可以确定当前的配置文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
root@chen:~# php --ini Configuration File (php.ini) Path: /etc/php/7.4/cli Loaded Configuration File: /etc/php/7.4/cli/php.ini Scan for additional .ini files in: /etc/php/7.4/cli/conf.d Additional .ini files parsed: /etc/php/7.4/cli/conf.d/10-mysqlnd.ini, /etc/php/7.4/cli/conf.d/10-opcache.ini, /etc/php/7.4/cli/conf.d/10-pdo.ini, /etc/php/7.4/cli/conf.d/20-calendar.ini, /etc/php/7.4/cli/conf.d/20-ctype.ini, /etc/php/7.4/cli/conf.d/20-exif.ini, /etc/php/7.4/cli/conf.d/20-ffi.ini, /etc/php/7.4/cli/conf.d/20-fileinfo.ini, /etc/php/7.4/cli/conf.d/20-ftp.ini, /etc/php/7.4/cli/conf.d/20-gd.ini, /etc/php/7.4/cli/conf.d/20-gettext.ini, /etc/php/7.4/cli/conf.d/20-iconv.ini, /etc/php/7.4/cli/conf.d/20-json.ini, /etc/php/7.4/cli/conf.d/20-mysqli.ini, /etc/php/7.4/cli/conf.d/20-pdo_mysql.ini, /etc/php/7.4/cli/conf.d/20-phar.ini, /etc/php/7.4/cli/conf.d/20-posix.ini, /etc/php/7.4/cli/conf.d/20-readline.ini, /etc/php/7.4/cli/conf.d/20-shmop.ini, /etc/php/7.4/cli/conf.d/20-sockets.ini, /etc/php/7.4/cli/conf.d/20-sysvmsg.ini, /etc/php/7.4/cli/conf.d/20-sysvsem.ini, /etc/php/7.4/cli/conf.d/20-sysvshm.ini, /etc/php/7.4/cli/conf.d/20-tokenizer.ini |
最终解决是在apache根目录的.htaccess进行配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
root@chen:/var/www/html# cat .htaccess # BEGIN WordPress # The directives (lines) between `BEGIN WordPress` and `END WordPress` are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> php_value upload_max_filesize 10M php_value post_max_size 20M php_value memory_limit 32M # END WordPress root@chen:/var/www/html# |
其中php_value相关的即为php设置一些会引用到的数值。
问题5:无法裁剪图片,提示“There has been an error cropping your image.”
1 |
root@chen:~# apt-get install php-gd |
全文完。