简体   繁体   English

如何配置php.ini文件

[英]How to configure php.ini file

I am having a bit of trouble understanding how to set up the php.ini file on my website. 我在理解如何在我的网站上设置php.ini文件时遇到了一些麻烦。 I have included the line session.cookie_lifetime = 1800 as well as some others, but nothing has changed. 我已经包含了session.cookie_lifetime = 1800和其他一些内容,但是没有任何变化。 When I go to my phpinfo.php pgae, none of the settings I have configured in the .ini file are not taken into effect. 当我转到phpinfo.php pgae时,.ini文件中配置的所有设置均不会生效。 Can anyone help me with this? 谁能帮我这个? Thanks. 谢谢。

Add below lines in .htaccess file, it will increase the timeout to 30 minutes. .htaccess文件中添加以下行,它将使超时增加到30分钟。

php_value session.cookie_lifetime 1800
php_value session.gc_maxlifetime 1800

When you make changes in the php.ini file you have to restart the webserver or reloading the configuration files in most cases. php.ini文件中进行更改时,在大多数情况下,您必须重新启动Web服务器或重新加载配置文件。

Because I have not enough reputation yet to write comments I assume you are using a LAMP environment. 由于我尚无足够的声誉来撰写评论,因此我假设您使用的是LAMP环境。 You can restart the webserver by typing in console: 您可以通过在控制台中键入来重新启动Web服务器:

service apache2 restart

or 要么

/etc/init.d/apache2 restart

reload or force-reload instead of restart should also work for just reloading the configuration files, but with restart you're one the safe side. reloadforce-reload而不是restart也应该只用于重新加载配置文件,但是restart是安全的一面。

Also make sure you're editing the correct php.ini file. 还要确保您正在编辑正确的php.ini文件。 You can find the right file by looking at the 'Loaded Configuration File' directive of phpinfo() output. 您可以通过查看phpinfo()输出的“ Loaded Configuration File”指令来找到正确的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM