在 vagrant box 上编辑 php.ini
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22998431/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Editing php.ini on vagrant box
提问by the_unforgiven_II
Does anyone know how to edit the mail setting in the php.ini file by using Vagrant.
有谁知道如何使用 Vagrant 编辑 php.ini 文件中的邮件设置。
so I would ssh in terminal like so:
所以我会像这样在终端中 ssh:
cd myapp
cd myapp
vagrant ssh
无业游民ssh
then what>?
然后什么>?
回答by sinini
Depending on your box, it might be
根据您的盒子,它可能是
sudo nano /etc/php5/apache2/php.ini
then adopt you changes and restart with
然后采用您的更改并重新启动
sudo service apache2 restart
回答by mounty
Without knowing what specific setting you want and what you want it changed to, you could try adding a shell script to the end of your Vagrantfile (in the "Local Scripts" area) to do a search and replace on the ini file.
在不知道您想要什么特定设置以及您希望它更改为什么的情况下,您可以尝试在 Vagrantfile 的末尾(在“本地脚本”区域中)添加一个 shell 脚本来搜索并替换 ini 文件。
#!/usr/bin/env bash
sed -i.bak s/STRING_TO_REPLACE/STRING_TO_REPLACE_IT_WITH/g /etc/php5/apache2/php.ini
Failing that, you can use ini_setin your project (preferably in a bootstrap) to change mail settings on a per-project basis.
否则,您可以在项目中(最好在引导程序中)使用ini_set来更改每个项目的邮件设置。
回答by Devtype
In my case where I'm using scotchbox on vagrant, changing the php.ini
file won't reflect changes in phpinfo()
function output so I changed /etc/php5/apache2/conf.d/user.ini
file which could be a bare file or a file with few lines declaring php error display, I add my configurations here e.g. upload_max_filesize = 64M
Save the change and issue sudo service apache2 restart
. Viewed the phpinfo page and I can see the updated filesize.
在我在 vagrant 上使用 scotchbox 的情况下,更改php.ini
文件不会反映phpinfo()
函数输出的更改,因此我更改了/etc/php5/apache2/conf.d/user.ini
文件,该文件可能是裸文件或带有几行声明 php 错误显示的文件,我在此处添加我的配置,例如upload_max_filesize = 64M
保存更改并发出sudo service apache2 restart
. 查看 phpinfo 页面,我可以看到更新的文件大小。