I'm using Apache/2.4.29 with PHP 7.4.5 as module.
Apache and PHP are configured with lito as user.
Virtualhost configuration with PHP settings:
php_admin_value opcache.enabled 1
php_admin_value opcache.preload /home/lito/www/preload.php
php_admin_value opcache.preload_user lito
phpinfo show opcache configuration:
opcache.enable On
opcache.preload /home/lito/www/preload.php
opcache.preload_user lito
No errors on apache log.
After apache restart opcache_get_status haven't any key related with preload status (preload_statistics) and there are only one script preloaded (current phpinfo.php):
Array
(
[opcache_enabled] => 1
[cache_full] =>
[restart_pending] =>
[restart_in_progress] =>
[memory_usage] => Array
(
[used_memory] => 9168872
[free_memory] => 125047784
[wasted_memory] => 1072
[current_wasted_percentage] => 0.00079870223999023
)
[interned_strings_usage] => Array
(
[buffer_size] => 6291008
[used_memory] => 522888
[free_memory] => 5768120
[number_of_strings] => 10969
)
[opcache_statistics] => Array
(
[num_cached_scripts] => 1
[num_cached_keys] => 1
[max_cached_keys] => 16229
[hits] => 1
[start_time] => 1587378881
[last_restart_time] => 0
[oom_restarts] => 0
[hash_restarts] => 0
[manual_restarts] => 0
[misses] => 3
[blacklist_misses] => 0
[blacklist_miss_ratio] => 0
[opcache_hit_rate] => 25
)
[scripts] => Array
(
[/home/lito/www/phpinfo.php] => Array
(
[full_path] => /home/lito/www/phpinfo.php
[hits] => 0
[memory_consumption] => 1040
[last_used] => Mon Apr 20 12:39:15 2020
[last_used_timestamp] => 1587379155
[timestamp] => 1587378955
)
)
)
Is not available opcache preload on Apache with PHP as module (without a custom php.ini)?
Thanks!
UPDATE: Tested adding preload file on /etc/php/7.4/apache2/php.ini and it works fine.
Similar (for nginx with php-fpm): https://bugs.php.net/bug.php?id=79043#1578412872
As far as I can tell, it looks like preloading is not in effect when configured this way.
Answer from PHP core dev:
yes, as preloading happens during early server startup, enabling it through php_admin_value does not work.
Related
I'm using AlmaLinux 8.4, and I'm trying to install Zend Opcache and verify that it's running.
In Easy Apache, php8 and php80-php-opcache are installed. php -1 shows Zend is not enabled, while php -a does, and 10-opcache.ini is loaded. (I see that CLI is not enabled, but I don't need it.)
Apache and PHP-FPM have been restarted several times.
Is this configuration correct?
How do I determine if Zend Opcode is actually running?
[root}# php -i shows:
Zend OPcache
Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Enabled
File Cache => Disabled
JIT => On
Startup Failed => Opcode Caching is disabled for CLI
Loaded Configuration File => /opt/cpanel/ea-php80/root/etc/php.ini
Additional .ini files parsed => /opt/cpanel/ea-php80/root/etc/php.d/10-opcache.ini
Core
PHP Version => 8.0.9
zend.assertions => -1 => -1
zend.detect_unicode => On => On
zend.enable_gc => On => On
zend.exception_ignore_args => Off => Off
zend.exception_string_param_max_len => 15 => 15
zend.multibyte => Off => Off
zend.script_encoding => no value => no value
zend.signal_check => Off => Off
The file /opt/cpanel/ea-php80/root/etc/php.d/10-opcache.ini shows
Enable Zend OPcache extension module
zend_extension=opcache.so
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0
; The OPcache shared memory storage size.
opcache.memory_consumption=128
; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8
; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 100000 are allowed.
opcache.max_accelerated_files=4000
php -a shows
php > print_r(opcache_get_configuration());
Array
(
[directives] => Array
(
[opcache.enable] => 1
[opcache.enable_cli] =>
[opcache.use_cwd] => 1
[opcache.validate_timestamps] => 1
[opcache.validate_permission] => 1
[opcache.validate_root] =>
[opcache.dups_fix] =>
[opcache.revalidate_path] =>
[opcache.log_verbosity_level] => 1
[opcache.memory_consumption] => 134217728
[opcache.interned_strings_buffer] => 8
[opcache.max_accelerated_files] => 4000
[opcache.max_wasted_percentage] => 0.05
[opcache.consistency_checks] => 0
[opcache.force_restart_timeout] => 180
[opcache.revalidate_freq] => 2
[opcache.preferred_memory_model] =>
[opcache.blacklist_filename] => /opt/cpanel/ea-php80/root/etc/php.d/opcache*.blacklist
[opcache.max_file_size] => 0
[opcache.error_log] =>
[opcache.protect_memory] =>
[opcache.save_comments] => 1
[opcache.record_warnings] =>
[opcache.enable_file_override] =>
[opcache.optimization_level] => 2147401727
[opcache.lockfile_path] => /tmp
[opcache.file_cache] =>
[opcache.file_cache_only] =>
[opcache.file_cache_consistency_checks] => 1
[opcache.file_update_protection] => 2
[opcache.opt_debug_level] => 0
[opcache.restrict_api] =>
[opcache.huge_code_pages] =>
[opcache.preload] =>
[opcache.preload_user] =>
[opcache.jit] => tracing
[opcache.jit_buffer_size] => 0
[opcache.jit_debug] => 0
[opcache.jit_bisect_limit] => 0
[opcache.jit_blacklist_root_trace] => 16
[opcache.jit_blacklist_side_trace] => 8
[opcache.jit_hot_func] => 127
[opcache.jit_hot_loop] => 64
[opcache.jit_hot_return] => 8
[opcache.jit_hot_side_exit] => 8
[opcache.jit_max_exit_counters] => 8192
[opcache.jit_max_loop_unrolls] => 8
[opcache.jit_max_polymorphic_calls] => 2
[opcache.jit_max_recursive_calls] => 2
[opcache.jit_max_recursive_returns] => 2
[opcache.jit_max_root_traces] => 1024
[opcache.jit_max_side_traces] => 128
[opcache.jit_prof_threshold] => 0
)
[version] => Array
(
[version] => 8.0.9
[opcache_product_name] => Zend OPcache
)
[blacklist] => Array
(
)
)
To determine if the opcache is enabled and working and ensure that the JIT actually works, create a PHP script that's accessible via the browser and look at the output of opcache_get_status().
Example PHP file can be:
var_dump(opcache_get_status());
Example output when it is enabled is:
array(9) {
["opcache_enabled"]=>
bool(true)
...
if the opcache extension is not installed or not enabled it will throw this error:
Fatal error: Uncaught Error: Call to undefined function opcache_get_status()
Another option is that you print out your phpinfo and check for opcache in the output:
<?php phpinfo(); ?>
Hi I need to parse the ini file shown below using php, which is basically created using Qt QSettings, I have tried the code here, but seems the INI file are different format there.
Is it possible to parse INI file in below format using PHP ?
[General]
Address=
Email=test#gmail.com
Password=123$
Sync=0
Loggedin=1
[Drives]
1\drive=/
1\free=281
1\size=908
2\drive=/media/New_Volume
2\free=6
2\size=7
3\drive=/media/sdb2
3\free=906
3\size=916
size=2
[Cam]
1\detection=0
1\Area.height=2.4
1\Area.width=9.5
2\detection=0
2\Area.height=2.4
2\Area.width=9.5
3\detection=0
3\Area.height=2.4
3\Area.width=9.5
size=2
Update:
Actually the above ini was working as said in below answer, and my actyual ini contains the $ symbol, that was creating the problem.
[General]
Address=
Email=test#gmail.com
Password=123$
Sync=0
Loggedin=1
[Drives]
1\drive=/
1\free=281
1\size=908
2\drive=/media/New_Volume
2\free=6
2\size=7
3\drive=/media/sdb2
3\free=906
3\size=916
size=2
[Cam]
1\detection=0
1\Area.height=2.4
1\Area.width=9.5
2\detection=0
2\Area.height=2.4
2\Area.width=9.5
3\detection=0
3\Area.height=2.4
3\Area.width=9.5
size=2
And seems I have to escape the $ symbol.
It works just fine, take a look at the php code while the .ini file stays exactly as you have it.
$ini_array = parse_ini_file("settings.ini",true);
print_r($ini_array);
//will output
Array
(
[General] => Array
(
[Address] =>
[Email] => test#gmail.com
[Password] => 123$ // note the $ sign in value here
[Sync] => 0
[Loggedin] => 1
)
[Drives] => Array
(
[1\drive] => /
[1\free] => 281
[1\size] => 908
[2\drive] => /media/New_Volume
[2\free] => 6
[2\size] => 7
[3\drive] => /media/sdb2
[3\free] => 906
[3\size] => 916
[size] => 2
)
[Cam] => Array
(
[1\detection] => 0
[1\Area.height] => 2.4
[1\Area.width] => 9.5
[2\detection] => 0
[2\Area.height] => 2.4
[2\Area.width] => 9.5
[3\detection] => 0
[3\Area.height] => 2.4
[3\Area.width] => 9.5
[size] => 2
)
)
I have two cpanel websites running the same php script that parses a csv file, one on godaddy servers (site A), one on hostgator (site B). on site B, the html portion of the page renders and then it parses the csv, while on site A it parses the csv and then renders the html portion.
Any ideas why there is such different behavior? I would like to have Site A perform this script like Site B
They are both running php 5.4 and have the same execution time limits.
Below are the result of array_diff_assoc of php.ini arrays of name => local_value. The first is array_diff_assoc(Site B, Site A) the second is array_diff_assoc(Site A, Site B)
Array
(
[allow_url_include] => 1
[date.timezone] => America/Chicago
[disable_functions] => dl
[enable_dl] =>
[error_reporting] => 22519
[expose_php] =>
[extension_dir] => /opt/php54/lib/php/extensions/no-debug-non-zts-20100525
[include_path] => .:/opt/php54/lib/php
[intl.default_locale] =>
[intl.error_level] => 0
[max_execution_time] => 30
[memory_limit] => 256M
[mssql.allow_persistent] => 1
[mssql.batchsize] => 0
[mssql.charset] =>
[mssql.compatability_mode] =>
[mssql.connect_timeout] => 5
[mssql.datetimeconvert] => 1
[mssql.max_links] => -1
[mssql.max_persistent] => -1
[mssql.max_procs] => -1
[mssql.min_error_severity] => 10
[mssql.min_message_severity] => 10
[mssql.secure_connection] =>
[mssql.textlimit] => -1
[mssql.textsize] => -1
[mssql.timeout] => 60
[mysql.allow_persistent] =>
[odbc.allow_persistent] =>
[odbc.check_persistent] =>
[odbc.default_cursortype] => 3
[odbc.default_db] =>
[odbc.default_pw] =>
[odbc.default_user] =>
[odbc.defaultbinmode] => 1
[odbc.defaultlrl] => 4096
[odbc.max_links] => -1
[odbc.max_persistent] => -1
[pcre.backtrack_limit] => 1000000
[pcre.recursion_limit] => 100000
[post_max_size] => 64M
[sourceguardian.restrict_unencoded] => 0
[upload_max_filesize] => 64M
[xsl.security_prefs] => 44
)
Array
(
[allow_url_include] => 0
[apc.cache_by_default] => 1
[apc.canonicalize] => 1
[apc.coredump_unmap] => 0
[apc.enable_cli] => 0
[apc.enabled] => 1
[apc.file_md5] => 0
[apc.file_update_protection] => 2
[apc.filters] =>
[apc.gc_ttl] => 3600
[apc.include_once_override] => 0
[apc.lazy_classes] => 0
[apc.lazy_functions] => 0
[apc.max_file_size] => 1M
[apc.mmap_file_mask] =>
[apc.num_files_hint] => 1000
[apc.preload_path] =>
[apc.report_autofilter] => 0
[apc.rfc1867] => 0
[apc.rfc1867_freq] => 0
[apc.rfc1867_name] => APC_UPLOAD_PROGRESS
[apc.rfc1867_prefix] => upload_
[apc.rfc1867_ttl] => 3600
[apc.serializer] => default
[apc.shm_segments] => 1
[apc.shm_size] => 32M
[apc.shm_strings_buffer] => 4M
[apc.slam_defense] => 1
[apc.stat] => 1
[apc.stat_ctime] => 0
[apc.ttl] => 0
[apc.use_request_time] => 1
[apc.user_entries_hint] => 4096
[apc.user_ttl] => 0
[apc.write_lock] => 1
[date.timezone] => UTC
[disable_functions] =>
[enable_dl] => 1
[error_reporting] => 1
[expose_php] => 1
[extension_dir] => /usr/local/lib/php/extensions/no-debug-non-zts-20100525
[include_path] => .:/usr/lib/php:/usr/local/lib/php
[max_execution_time] => 120
[memory_limit] => 64M
[mysql.allow_persistent] => 1
[mysqlnd.collect_memory_statistics] => 0
[mysqlnd.collect_statistics] => 1
[mysqlnd.debug] =>
[mysqlnd.log_mask] => 0
[mysqlnd.mempool_default_size] => 16000
[mysqlnd.net_cmd_buffer_size] => 4096
[mysqlnd.net_read_buffer_size] => 32768
[mysqlnd.net_read_timeout] => 31536000
[pcre.backtrack_limit] => 10000000
[pcre.recursion_limit] => 10000000
[post_max_size] => 48M
[upload_max_filesize] => 32M
)
Update 1
In comparing ini_get_all, I have found that Site A has APC enabled where Site B does not... could this be the issue? Is there any harm in this implementation in disabling APC?
Update 2
I believe we can rule out implicit_flush, as both are set to false and setting Site A's to true does not change the behavior
Update 3
Included the differences in ini files
Update 4
I have set Site A's php.ini file to be the same as site B's, with no change in behavior, so maybe we can rule this out?
Update 5
Although it does not mimic the async nature of site B, using
ob_flush();
flush();
to flush the buffer seems to get it very close, but it is not a very clean solution...
Anyone know anything about troubleshooting a PHP Curl problem? I have been using RollingCurl with great success on my OSX laptop, however when I upload to my Ubuntu server the same code fails to yield a result.
So there is clearly something wrong server side, the error logs are clean. I have no idea what to check... any help? Anyone!?
Thank you so much in advance, Stu
![http://rolling-curl.googlecode.com/svn/trunk/
Ubuntu 12.04 result
Array ( \[url\] => \[content_type\] => \[http_code\] => 0 \[header_size\] => 0 \[request_size\] => 0 \[filetime\] => 0 \[ssl_verify_result\] => 0 \[redirect_count\] => 0 \[total_time\] => 0 \[namelookup_time\] => 0 \[connect_time\] => 0 \[pretransfer_time\] => 0 \[size_upload\] => 0 \[size_download\] => 0 \[speed_download\] => 0 \[speed_upload\] => 0 \[download_content_length\] => -1 \[upload_content_length\] => -1 \[starttransfer_time\] => 0 \[redirect_time\] => 0 \[certinfo\] => Array ( ) \[redirect_url\] => )
Local OSX Leoard result
Array ( \[url\] => http://www.google.co.uk/ \[content_type\] => text/html; charset=ISO-8859-1 \[http_code\] => 200 \[header_size\] => 1535 \[request_size\] => 108 \[filetime\] => -1 \[ssl_verify_result\] => 0 \[redirect_count\] => 1 \[total_time\] => 0.597785 \[namelookup_time\] => 0.033881 \[connect_time\] => 0.070866 \[pretransfer_time\] => 0.070939 \[size_upload\] => 0 \[size_download\] => 43439 \[speed_download\] => 72666 \[speed_upload\] => 0 \[download_content_length\] => 221 \[upload_content_length\] => 0 \[starttransfer_time\] => 0.171418 \[redirect_time\] => 0.147887 )][1]
if (ini_get('safe_mode') == 'Off' || !ini_get('safe_mode')) {
$options[CURLOPT_FOLLOWLOCATION] = 1;
$options[CURLOPT_MAXREDIRS] = 5;
}
Here is the problem... I commented it out to test and BANG.... flys into action. Thank you all for your help.
Check your php.ini configuration file in your ubuntu server. In this article you can see many of the good practices that many people (and now, some packages do) to protect their servers from attacks: http://blog.up-link.ro/php-security-tips-securing-php-by-hardening-php-configuration/
UPDATE.
To make it more clear:
Log in to your ubuntu server as an admin user.
Change to the configuration file's directory
cd /etc/PHP5
Search in the file for allow_url_fopen = Off value by using the following command:
sudo nano php.ini
Change the value to On and press CTRL+X answer "yes" to save the changes and quit nano editor
I have just tried enabling php_browscap.ini so that I can use the get_browser function.
However, it seems to display an empty array?
$user_agent = get_browser(null, true);
print_r($user_agent);
In my php.ini file, I have the following:
[browscap]
; http://php.net/browscap
browscap = C:/wamp/bin/php/php5.3.0/extra/php_browscap.ini
I am probably missing something simple?
Update
Output I get:
Array ( [browser_name_regex] => §^.*$§ [browser_name_pattern] => * [browser] => Default Browser [version] => 0 [majorver] => 0 [minorver] => 0 [platform] => unknown [alpha] => [beta] => [win16] => [win32] => [win64] => [frames] => 1 [iframes] => [tables] => 1 [cookies] => [backgroundsounds] => [cdf] => [vbscript] => [javaapplets] => [javascript] => [activexcontrols] => [isbanned] => [ismobiledevice] => [issyndicationreader] => [crawler] => [cssversion] => 0 [supportscss] => [aol] => [aolversion] => 0 )
You could find if there's something else failing using tools like ProcMon. This tool will tell you which files had been accessed, and what was the result. So, you have to open it, highlight the browsercap ini's path, restart the webserver and see if any of this scenarios fits:
File doesn't exist
Permission denied
Finding wrong path
Doesn't appear at all
ProcMon is a Wonderful tool if you're in Windows.
If you find any of those scenarios, and don't know what to do, just edit your question :-)
Good luck!
There are several php.ini files for WAMP. To get to the right one, access it using the WAMP tray icon. That's how I got it to work. As it turns out, in my case it used the one in C:\Apps\wamp\bin\apache\apache2.2.22\bin.