PHP.ini在Laravel Homestead中向phpinfo()显示不同的值

时间:2018-03-06 15:03:16

标签: php laravel homestead

我试图修改Laravel homestead的PHP.ini文件以启用short_open_tags

根据joepferguson的建议,我在after.sh文件中添加了以下行:

sudo sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/5.6/fpm/php.ini
sudo sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.0/fpm/php.ini
sudo sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.1/fpm/php.ini
sudo sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.2/fpm/php.ini

现在,当我通过SSH连接到家庭服务器并执行以下操作时:

vagrant@homestead:/etc/php/7.1/fpm$ cat php.ini | grep short_
; short_open_tag
short_open_tag = On

它清楚地表明它已经开启。但是,当我运行以下代码时,它们仍无法正常工作:

它表明它确实加载了相同的php.ini文件:/etc/php/7.1/fpm/php.ini

但是那个短暂打开的标签仍然设置为Off,进一步向下文件phpinfo():

enter image description here

如果我运行命令php --ini,我会得到以下内容:

vagrant@homestead:/etc/php/7.1/fpm$ php --ini
Configuration File (php.ini) Path: /etc/php/7.2/cli
Loaded Configuration File:         /etc/php/7.2/cli/php.ini
Scan for additional .ini files in: /etc/php/7.2/cli/conf.d
Additional .ini files parsed:      /etc/php/7.2/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.2/cli/conf.d/10-opcache.ini,
/etc/php/7.2/cli/conf.d/10-pdo.ini,
/etc/php/7.2/cli/conf.d/15-xml.ini,
/etc/php/7.2/cli/conf.d/20-bcmath.ini,
/etc/php/7.2/cli/conf.d/20-calendar.ini,
/etc/php/7.2/cli/conf.d/20-ctype.ini,
/etc/php/7.2/cli/conf.d/20-curl.ini,
/etc/php/7.2/cli/conf.d/20-dom.ini,
/etc/php/7.2/cli/conf.d/20-exif.ini,
/etc/php/7.2/cli/conf.d/20-fileinfo.ini,
/etc/php/7.2/cli/conf.d/20-ftp.ini,
/etc/php/7.2/cli/conf.d/20-gd.ini,
/etc/php/7.2/cli/conf.d/20-gettext.ini,
/etc/php/7.2/cli/conf.d/20-iconv.ini,
/etc/php/7.2/cli/conf.d/20-igbinary.ini,
/etc/php/7.2/cli/conf.d/20-imap.ini,
/etc/php/7.2/cli/conf.d/20-intl.ini,
/etc/php/7.2/cli/conf.d/20-json.ini,
/etc/php/7.2/cli/conf.d/20-mbstring.ini,
/etc/php/7.2/cli/conf.d/20-msgpack.ini,
/etc/php/7.2/cli/conf.d/20-mysqli.ini,
/etc/php/7.2/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.2/cli/conf.d/20-pdo_pgsql.ini,
/etc/php/7.2/cli/conf.d/20-pdo_sqlite.ini,
/etc/php/7.2/cli/conf.d/20-pgsql.ini,
/etc/php/7.2/cli/conf.d/20-phar.ini,
/etc/php/7.2/cli/conf.d/20-posix.ini,
/etc/php/7.2/cli/conf.d/20-readline.ini,
/etc/php/7.2/cli/conf.d/20-shmop.ini,
/etc/php/7.2/cli/conf.d/20-simplexml.ini,
/etc/php/7.2/cli/conf.d/20-soap.ini,
/etc/php/7.2/cli/conf.d/20-sockets.ini,
/etc/php/7.2/cli/conf.d/20-sqlite3.ini,
/etc/php/7.2/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.2/cli/conf.d/20-sysvsem.ini,
/etc/php/7.2/cli/conf.d/20-sysvshm.ini,
/etc/php/7.2/cli/conf.d/20-tokenizer.ini,
/etc/php/7.2/cli/conf.d/20-wddx.ini,
/etc/php/7.2/cli/conf.d/20-xmlreader.ini,
/etc/php/7.2/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.2/cli/conf.d/20-xsl.ini,
/etc/php/7.2/cli/conf.d/20-zip.ini,
/etc/php/7.2/cli/conf.d/25-memcached.ini,
/etc/php/7.2/cli/conf.d/90-blackfire.ini,
/etc/php/7.2/cli/conf.d/zray.ini

所以Homestead在php.ini上加载了很多ini文件,对吗?除了网站使用FPM,所以我去了那个目录并运行了以下内容:

vagrant@homestead:/etc/php/7.1/fpm/conf.d$ grep -R "short_open"

但它没有任何回报。所以没有其他INI文件覆盖第一个,所以为什么short_open_tags仍然不能在网页上工作?

1 个答案:

答案 0 :(得分:3)

确保您正在运行

sudo service php5.6-fpm restart sudo service php7.0-fpm restart sudo service php7.1-fpm restart sudo service php7.2-fpm restart sudo service nginx restart

或者只是重新启动您正在编辑设置的版本。