I have a virtual machine with openSUSE Leap 42.3 and a LAMP stack.
Now I want to set up a CMS called TYPO3. The install tool tells me, that I should change following settings:
Low PHP script execution time
PHP max_input_vars is very low
I opened my /etc/php7/cli/php.ini and changed the values. But after restarting the Apache web server, and executing phpinfo();, nothing changes.
This is what phpinfo() tells me:
Configuration File (php.ini) Path /etc/php7/apache2 Loaded
Configuration File /etc/php7/apache2/php.ini Scan this directory for
additional .ini files /etc/php7/conf.d
Are my changes overridden? A system restart did not help.
The php.ini file in the /cli directory is for the command line interface (CLI). Those changes will not affect if the PHP interpreter is "called by Apache" (or other web servers) in PHP's default configuration. You have to adjust the apache2/php.ini file. This is also what your phpinfo() states ;)
Restart PHP and/or Apache (depending on the system you are using) and it should be done.
Related
I needed to change few values in php.ini file and after running phpinfo() within my application, found my php.ini file in below location
Configuration File (php.ini) Path /opt/php-5.6.30/lib
Loaded Configuration File /opt/php-5.6.30/lib/php.ini
Changed the values in above php.ini file followed by apache2 restart but they didn't reflect.
I ran php --ini command to see any other php.ini files and got following folders:
/etc/php/7.0/cli
/etc/php/7.0/apache2
/etc/php/7/0/fpm
so changed values in all of those php.ini files followed by apache2 and php7.0-fpm restart but to no effect.
I'm puzzled as my application's "loaded configuration file" is using php 5.6.30 which is in /opt/php-5.6.30 folder without any apache2 folder within and php-fpm points at /etc/php/7.0 folder.
None of those ini files followed by apache & php-fpm service restarts is actually reflecting my changes.
Any suggestions/pointers would be much appreciated.
I think the problem is that you are using different php versions for php-fpm (web), and cli. You should create test.php file, and run there phpinfo(). And check where loaded php.ini of web version is located. You should access test.php from web, like https://example.com/test.php
If you've made changes to your php.ini file and the changes are not being reflected, even after restarting your server, there are a few things you can try:
Check that you are editing the correct php.ini file: Make sure you are editing the correct php.ini file that your server is using. You can check which file your server is using by creating a PHP file with the following content:
<?php
phpinfo();
?>
Save the file to your server and open it in your browser. Look for the "Loaded Configuration File" directive in the output to determine the location of the php.ini file.
Check that you have permission to edit the php.ini file: Make sure that you have permission to edit the php.ini file. If you are not the owner of the file, you may need to use sudo to edit it.
Check for syntax errors: Make sure that there are no syntax errors in your php.ini file. You can check for syntax errors by running the following command:
php -c /path/to/php.ini -l
Replace /path/to/php.ini with the actual path to your php.ini file. If there are syntax errors, you will need to correct them before the changes can take effect.
Clear any opcode caches: If you have an opcode cache, such as APC or OPcache, you may need to clear it before the changes to the php.ini file take effect. You can usually clear the opcode cache by restarting your web server or by using the cache's built-in function.
Check that your changes are in the correct section: Make sure that your changes are in the correct section of the php.ini file. For example, if you are trying to change the max_execution_time directive, make sure that it is in the [PHP] section of the file.
Restart your web server: Finally, make sure to restart your web server after making changes to the php.ini file. Depending on your server configuration, you may need to restart both the web server and the PHP FPM process.
I need to install ioncube loader on my local machine with easyphp 16.1 (apache 2.4.28 and php 5.6.17).
I've followed the instructions of the loader_wizard.php and modified the php.ini file:
my php.ini
But when I start the apache server, I notice that php.ini has been modified and the ioncube line has been replaced with a xdebug line:
modified php.ini after server start
I also tried to create a php.ini that call the ioncube loader in the same folder of the php files I need to open, without success.
Any suggestion?
Thank you very much!
If your php.ini gets altered when you restart the server software, it's likely that the startup process is creating the php.ini file from a template or partial php.ini file fragments somewhere. Check documentation for EasyPHP or post a support query with them to find out how to make a permanent change to the php.ini file.
My PHPUnit tests keep failing when trying to tests any .php files in my (legacy code) application that begin with the short open tag (<? instead of <?php).
But in my php.ini file, the short_open_tag is set to On.
The application runs fine. Why is PHPUnit getting upset over the short open tag? I've looked for other php.ini files, and could only find the one at /etc/php.ini. My .htaccess file doesn't affect this setting either. What else could be causing this?
General solution
1) Check which php.ini file is loaded (command line: php --ini)
2a) Set in that php ini file: short_open_tag = on
2b) Set in .htaccess file: php_value short_open_tag 1
3) Restart the server (command line: service httpd restart)
So, I got it to work and the solution is frustrating: My application is on a VM and the php.ini file within the VM had the correct setting. However, PHPUnit was using the php.ini file on my local machine, which had short_open_tag set to Off. Changing that setting fixed my problem.
(I'm still unsure of why PHPUnit uses the other php.ini, but I think that's outside the scope of this question.)
PHPUnit uses PHP-cli module of PHP. And PHP-cli has another .ini file for its configuration. I am using ubuntu 14.04, in my case
/etc/php5/apache2/php.ini //used for web compiler
/etc/php5/cli/php.ini // Used for PHP-cli, you need to set short_open_tag=On here
I installed MAMP for windows
I have this error since several hours...
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: date_default_timezone_get(): It is not safe to rely on the system'
s timezone settings. You are *required* to use the date.timezone setting or
the date_default_timezone_set() function. In case you used any of those me
thods and you are still getting this warning, you most likely misspelled th
e timezone identifier. We selected the timezone 'UTC' for now, but please s
et date.timezone to select your timezone.
In the php.ini concerned (C:/MAMP/conf/php5.5.19/php.ini), I changed the line DATE like this:
[Date]
; Defines the default timezone used by the date functions
date.timezone = "Europe/Paris"
And in my phpinfo(), the path loaded is :
Loaded Configuration File C:\MAMP\conf\php5.5.19\php.ini
When I do in the consol the command php --ini I have this :
C:\Users\Thomas>php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Why Configuration File (php.ini) Path: is "C:\Windows" and not C:\MAMP\conf\php5.5.19\. Can I change this Path ?
I don't know what to do now...
thanks !
I had the same error. I had no clue where it was coming from, but with some trial and error I figured out it had something to do with the special character in my htdocs folder:
htdocs/Exámple
By changing that character to a normal character (thus changing to htdocs/Example), I no longer got the error and the site would load normally.
The problem is that your xAMP server and cli access uses different php configuration.
One is C:\Windows\php.ini for CLI
Second is C:\MAMP\conf\php5.5.19\php.ini for web server
Make sure you have updated both files.
Secondly do not forget to restart xAMP server, as apache do not reload libapache2-mod-php5 configs automatically.
When you set configuration in MAMP it only affects PHP which is loaded in Apache module handler mode (mapped as module inside Apache process). If you want to set PHP CLI you need to set this separately from web server configuration.
Open command prompt from Windows (cmd.exe from Start button)
enter ECHO %PATH%
this command will list your current PATH variable with all paths. For example, something like this:
C:>echo %PATH%
C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\binaries\php\php_runningversion
;C:\ProgramData\Oracle\Java\javapath;C:\Perl\site\bin;C:\Perl\bin
...
now enter following command
SET PATH=%PATH%;c:\mamp\bin\php\php5.6.0\;
This will going to add path to php5.6.0 version from MAMP folder.
you can now test your PHP CLI by entering following command :
php -v
then try to initialize configuration from MAMP for version PHP5.6.0 file:
C:>php -c "c:\mamp\conf\php5.6.0\php.ini" --ini
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: C:\MAMP\conf\php5.6.0\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
You can use command -c from PHP CLI to set path to configuration file; and "c:\mamp\conf\php5.6.0\php.ini" is path to PHP ini file for version 5.6.0.
If you do not want to always add path to configuration file with -c command, just copy php.ini file from C:\MAMP\conf\php5.6.0\ to C:\MAMP\bin\php\php5.6.0\
Off course, this will going to set PHP CLI only in currently opened command prompt. To add this path permanently, you need to modify System Environment variable, or to use MAMP PRO as it already have this feature on PHP options page.
TL:DR - Make sure to edit both the ..\MAMPPRO\conf\php[version].ini and the ..\MAMP\bin\php\php[version]\php.ini with your correct/approved php timezone.
So while I was going through my setup, I had the same issue.
I was taking a look at my phpinfo() and it was giving me a path to my "Loaded Configuration File" that was located in my ..\MAMPPRO\conf\php[version].ini so I was editing that file with approved timezone from http://php.net/manual/en/timezones.php making sure to avoid any from http://php.net/manual/en/timezones.others.php.
After a few restarts and no success I started to dig a little further into where MAMP Pro was pulling that ini.
I found the solution in ..\MAMP\bin\php\php[version]\php.ini. If I edited this file IN ADDITION TO editing the MAMP Pro ini everything worked properly.
Hopefully this can help you out!
At the beggining of your web/app_dev.php and web/app.php you can add:
date_default_timezone_set('Europe/Paris');
I've see a few other similar questions on here, but most of the answers are Apache specific (dealing with their .htaccess file) and I'm using nginx.
I'm having trouble making my change to the upload_max_filesize in php.ini stick. I'm using nginx, php5 and wordpress on Debian.
When I run phpinfo() I see the following output:
Loaded Configuration File /etc/php5/cgi/php.ini
I then go to the relevant .ini file, change a few values, and then restart nginx. When I fire up a phpinfo() plugin I got for wordpress, it reports the values as unchanged.
I'm at a loss because phpinfo() reports that it is loading config values from the file that I've changed, but it doesn't report the changes.
You might be using FAST CGI:
[webserver] <----> [fcgi daemon]
`- [php]
If you restart the webserver, PHP is not restarted, so still has the old ini values because it didn't reload the ini file.
Restarting the fcgi daemon solves that issue, PHP will be restarted, re-reading the ini.
Some fcgi daemons have a command that reloads the child processes more gracefully. Depends on what you use.
For me the problem was a syntax error in the custom php.ini file, which I found after checking the error logs.
This might help the ones that are using php -i from the terminal to check php.ini settings.
In my case, I increased the upload_max_filesize from 2M to 20 MB by editing /etc/php/7.3/apache2/php.ini and restarted the apache by apachectl restart command.
I used php -i command from the Debian terminal to see the changes are in effect but upload_max_filesize was still 2M.
Then I realized settings readings came from /etc/php/7.3/cli/php.ini because I was using php -i from the terminal instead of phpinfo() function in a web page.
$ sudo service php7.4-fpm restart
Resolved my problem. change the php version to the one you using.