PHP-FPM is slow only for the sub domain - php

We have a project running in nginx/php-fpm which is basically a multi-site setup build on Symfony 2.7 and we're working on the next version of the site which is basically adding an another site to the project with some additional features. Just before going live, we needs to make sure everything works fine. So the site was hosted on subdomain.site.com with only internal access.
Basically there are 2 file servers and 2 load balancers with nginx. Load balancers receive the request and direct it to the web servers (where the php-fpm is installed) based on the load.
Now, the problem is the site is very slow, but the same website hosted on the test server is much faster which is having less configuration with multiple projects than the live server. This is what I see from the logs.
Web Server (PHP-FPM):
x.x.x.x - [08/Jan/2019:14:40:33 +0000] GET /app_dev.php/a-sample-url/ 200 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 took:14.856s
Load Balancer:
x.x.x.x - [08/Jan/2019:14:40:48 +0000] "GET /app_dev.php/a-sample-url/ HTTP/1.1" 200 38386 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36"
Here you can see that the php-fpm alone is taking 14.856s to execute also I'm unsure about how the logging is happening on the load balancer which is having the later time (not sure if it's the time when it returned response).
The live website is also located on the same server. So I'm doubting if the php-fpm is having a separate configuration for the sub domains.
Hereby I've attached the copy of my php-fpm configuration (excluded default values due to the size).
[www]
user = apache
group = apache
listen = 192.168.x.x:3456
listen.allowed_clients = 127.0.0.1,192.168.102.101,192.168.102.23
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
access.log = /var/log/php-fpm/$pool.access.log
access.format = "%{REMOTE_ADDR}e - [%t] %m %{REQUEST_URI}e %s %{HTTP_USER_AGENT}e took:%ds"
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = redis
php_value[session.save_path] = "tcp://192.168.x.x:1234/1"
Any help on this would be highly appreciated.

Related

Error proxying PHP APACHE with Nginx Proxy Manager in Docker

I am new to posting here, so sorry if I don't make it how it should be, and I could not decide what to make the title.
So, I am new to Nginx and Docker, I am wanting to use Nginx Proxy Manager to proxy all my websites that are hosted on 'php:8.1-apache' images for now.
I am proxying a website from a docker container (Named 'ApacheDefault') running a custom image of 'php:8.1-apache' through Nginx Proxy Manager (Assets Caching disabled, Block Common Exploits disabled), and I am having issues when going through the proxy that does not appear when reaching straight to the website.
When reaching through the proxy, it randomly works and then stops working.
On the root of my website, I got /test.php which is just the phpinfo function, /index.php which handle the routing, some assets in the /assets/ folder, and a /.htaccess with
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
Using 'my.domain' as an example, my domain is using Cloudflare DNS.
When reaching my.domain/test.php, I either get the regular phpinfo page or a page with this:
Warning: require_once(assets/php/config.php): Failed to open stream: No such file or directory in /var/www/html/assets/php/content.php on line 2
Fatal error: Uncaught Error: Failed opening required 'assets/php/config.php' (include_path='.:/usr/local/lib/php') in /var/www/html/assets/php/content.php:2 Stack trace: #0 /var/www/html/index.php(19): include() #1 /var/www/html/assets/php/classes/Route.php(37): {closure}('test.php') #2 /var/www/html/assets/php/classes/Router.php(40): Route->call() #3 /var/www/html/index.php(23): Router->run() #4 {main} thrown in /var/www/html/assets/php/content.php on line 2
^ "/var/www/html/assets/php/content.php" is not a file that does not exists and "assets/php/config.php" is never called in my code
The Nginx Proxy Manager log shows this (The first line landed on the error page, the second showed the regular phpinfo page):
[07/Oct/2022:16:20:22 +0000] - 200 200 - GET https my.domain "/test.php" [Client X.X.X.X] [Length 339] [Gzip -] [Sent-to ApacheDefault] "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" "-"
[07/Oct/2022:16:20:23 +0000] - 200 200 - GET https my.domain "/test.php" [Client X.X.X.X] [Length 23591] [Gzip -] [Sent-to ApacheDefault] "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" "-"
For some reason, the Length changes, and I can't get to understand why.
I tried:
Disabling Nginx caching from "Custom Nginx Configuration".
Disabling Nginx GZip (from "Custom Nginx Configuration") but could not manage to do it.
Enabling Cloudflare's Development Mode.
Thank you to anyone that can bring me the slightest help!
EDIT:
After testing a bit more I noticed something. When defining NPM (Nginx Proxy Manager)'s "Forward Hostname / IP" to my server raw IP or the website docker container's IP, the error does not appear anymore. The error only appears when using the docker container name as hostname instead of its IP. But I would like to rely on the hostname and not the IP because the IP can change, and seeing hostname is easier.
RE EDIT:
After removing my initial network connecting NPM & The Website Container and re creating it, it seems like it fixed the issue.
No idea why but i dont care, its fixed !

httpd / roundcube is throwing 500's with zero errors printed to the client or produced in the logs

I am migrating mail servers from OVH/Centos7 to AWS/Amazon Linux; part of my setup uses roundcube webmail.
I have copied all of my config and supporting files from one instance to the other, however can not seem to make the webmail app load as expected. Anything and everything produces a 500 with no useful errors displayed anywhere.
All apps and subdirectories are owned by apache:apache
With the following error config in php.ini
display_errors = On
error_reporting = E_ALL
log_errors = On
This is the ONLY log entry created when navigating to my URL:
w.x.y.z - - [27/Dec/2018:03:56:03 +0000] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
The log entry clearly shows the 500, but produces no errors. In addition, the error log file within the roundcube directory is also empty.
The response to the client is empty, just a 500.
$curl https://mail.example.com/
Header is 500:
$curl https://mail.example.com/ --head
HTTP/1.1 500 Internal Server Error
....
If I cd to the roundcube directory and try to evaluate the index, it returns nothing:
$cd /path/to/roundcube
$php index.php
$
I have tried to disable every single roundcube plugin, in config/config.inc.php
$config['plugins'] = array();
Every single other app and web page works, after the transplant; roundcube is the only thing which is throwing 500's and not producing any error messages...
syslog is empty of relevant messages.
What can I possibly do to further investigate why this might be failing?

PHP ldap_connect returns negative

I stumbled across an issue while setting up LDAP for Dokuwiki using the authldap plugin. I run dokuwiki with php7.2 on Ubuntu 18.4 and have windows server 2016 as an active directory controller.
I have several services running that sucessfully use LDAP and i can use the tool "ldapsearch" to contact the Active directory host from the command line of the same machine that runs dokuwiki. Thus I assume that at least the connection should be alright.
So far I narrowed it down to the ldap_connect(server,port) method in the file /lib/plugins/authldap/auth.php
$this->con = #ldap_connect($server, $port);
This call returns -1 . An echo of $server and $port show the correct ip address and port.
I've run out of ideas how to debug this issue and would be very thankful for suggestions.
Thanks & greetings
[Update]
Upon suggestion I removed the silence flag. I could not find changes in any log giving further hints.
I have another log I havent properly looked at:
192.168.4.103 - - [06/Jan/2019:15:51:15 +0000] "POST /dokuwiki/doku.php?id=start&do=login&sectok= HTTP/1.0" 403 11344 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
192.168.4.103 - - [06/Jan/2019:15:51:15 +0000] "GET /dokuwiki/lib/exe/indexer.php?id=start&1546789875 HTTP/1.0" 200 42 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
For me this looks like there was a sucessful request (http code 200), followed by a 403, suggesting that this action was forbidden.
I assume this is a default answer due to the failed ldap_connect

can't open web page on my virtual lamp server ubuntu 12.04

i can't open one php script on my virtual ubuntu 12.04 lamp server, i tried at an online host and it works fine but at home didn't work.
what i already did:
i intall php 5.4 like the online host
change permisions on folder
change user folder
install php 7 (but the scripts tell php 5.4-5.5)
and i get this error page when i try to open: The requested URL /loja/login was not found on this server.
and the log apache tell :
[client 192.168.0.10] File does not exist: /var/www/script/login
"GET /loja/ HTTP/1.1" 307 769 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
192.168.0.10 - - [02/Apr/2017:00:12:23 -0300] "GET /loja/login HTTP/1.1" 404 502 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36""
what is wrong on my lamp server? onlines hosts works very well.
the script: https://mega.nz/#!dpskSCDS!vmlxWXVjByV67wv41DO8MqDMPgfjBpxxj_p7uoxmfjQ
Hi please add your php files on your htdocs folder it's /opt/lampp/htdocs
also do this
This will change the ownership of the /opt/lampp/htdocs/ to you:
sudo chown username:groupname /opt/lampp/htdocs
Example : (My username is test and my group name is also test)
sudo chown test:test /opt/lampp htdocs
This will change the folder's permissions to be read, write and executed by you:
sudo chmod 777 /opt/lampp/htdocs

PHP Page execution

I have created a PHP application where an image file is downloaded from a link and is stored in the local folder. From there it is uploaded back again to FTP folder.
The image size is 27 MB. Well the file is downloading and uploading back again with no problem as the script is initiated but my page stops loading after some time. Because of that whatever output it has to display it is not displaying. Now it is displaying as a blank page.
I tired setting ini_set('max_execution_time', 0); in my php page.
I have increased my timeout value in httpd-default.conf.
I also have changed the following values in php.ini
1) max_execution_time = 30000 // though i have set '0' in my php file.
2) max_input_time = 60
3) memory_limit = 512M
4) Have set file_uploads = On
5) upload_max_filesize = 2000M
6) max_file_uploads = 200
6) allow_url_include = On
Well the important point here is I'm running this application in Bluemix. Is there anything else that I should look into ?.
Edited:
I don't have any problem with small files sizes. It only happens with big images files.
I have pasted my log below:
2016-03-26T15:33:59.715+0530 [RTR/0] OUT dmrst.au-syd.mybluemix.net - [26/03/2016:10:03:59 +0000]
"GET / HTTP/1.1" 200 0 867 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" 168.1.55.103:60047 x_forwarded_for:"61.16.162.202" x_forwarded_proto:"http" vcap_request_id:f1e5381f-5e43-426c-57b8-e948889726ad response_time:0.003732228 app_id:be513862-de63-4b71-bef3-1c78d56d8414 x_global_transaction_id:"13332023"
2016-03-26T15:33:59.740+0530 [App/0] OUT 10:03:59 httpd | 168.1.44.156 - - [26/Mar/2016:10:03:59 +0000]
"GET / HTTP/1.1" 200 867 vcap_request_id=f1e5381f-5e43-426c-57b8-e948889726ad peer_addr=168.1.44.156

Categories