I'm running php7.2-fpm with apache 2.4.29 on Ubuntu Server 18.04 LTS.
I'm unable to set a specific php error log file per host (as I normally do with php with apache pre-fork).
On apache host conf file I set my custom error log path:
ErrorLog /var/www/server_logs/myhost_error.log
LogLevel warn
But that file is empty
Looking at /etc/php/7.2/fpm/php-fpm.conf I saw that error log file is set to /var/log/php7.2-fpm.log and error level is enable and set to notice.
On my php project base path I put .user.ini containing
display_errors=on
display_startup_errors=on
error_reporting=E_ALL
html_errors=on
On my php project I generate a WARNING: I see it on screen but never get logged in my apache custom log error file nor in /var/log/php7.2-fpm.log
In /var/log/php7.2-fpm.log I only see
[17-Oct-2019 16:01:44] NOTICE: fpm is running, pid 25328
[17-Oct-2019 16:01:44] NOTICE: ready to handle connections
[17-Oct-2019 16:01:44] NOTICE: systemd monitor interval set to 10000ms
but no errors logged!
I cannot understand what I missed!
Anyone could help me please?
Related
I have this PHP configuration:
ini_get('max_execution_time') = 3000
ini_get('memory_limit') = 256
ini_get('post_max_size') = 200M
ini_get('upload_max_filesize') = 200M
On this environment:
CentOS 7 server
CentOS Web Panel
Apache web server 2.4
PHP 7.2
Laravel framework 7.0
And when I try to upload files more than 1MB I get a 500 internal server error!
This is the error in network tab:
Other info about request:
I tried everything that I had in mind like setting ini in controller changing the sending file method from ajax to simple form, etc... but no luck!
I also restarted the httpd service even restarted the server so maybe the changes make affect but nothing changes
Edit:
I also see this error in apache logs:
Handler for (null) returned invalid result code 70007
After a lot of researches and tries I found the problem and in doesn't make sense at all!
As in this link said:
7007 apache error
I had to just disable this line:
LoadModule reqtimeout_module modules / mod_reqtimeout.so
From Apache httpd.conf file
I tried to install php5-fpm, but currently got stuck when trying to install libapache2-mod-fastcgi installation.
I get the following message:
After this operation, 250 kB of additional disk space will be used.
Selecting previously unselected package libapache2-mod-fastcgi.
(Reading database ... 63345 files and directories currently installed.)
Preparing to unpack .../libapache2-mod-fastcgi_2.4.7~0910052141-1.1_amd64.deb ...
Unpacking libapache2-mod-fastcgi (2.4.7~0910052141-1.1) ...
Setting up libapache2-mod-fastcgi (2.4.7~0910052141-1.1) ...
apache2_invoke: Enable module fastcgi
Action 'configtest' failed.
The Apache error log may have more information.
apache2_reload: Your configuration is broken. Not restarting Apache 2
I will post my apache log shortly, since it is a big file and i need to parse it first.
by the way i did a quick:
grep -RIs "FastCgiExternalServer" /etc/apache2
and got the following response:
/etc/apache2/conf-available/php5-fpm.conf:FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
And this as well, when i try to restart Apache:
* Restarting web server apache2 [fail]
* The apache2 configtest failed.
Output of config test was:
AH00526: Syntax error on line 4 of /etc/apache2/mods-enabled/fastcgi.conf:
FastCgiIpcDir /var/lib/apache2/fastcgi: access for server (uid 33, gid 33) failed: write not allowed
Action 'configtest' failed.
The Apache error log may have more information.
This is the file that contains the offending line:
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
#FastCgiWrapper /usr/lib/apache2/suexec
FastCgiIpcDir /var/lib/apache2/fastcgi
</IfModule>
Can anyone help me ?
I had the same error. Originally /var/lib/apache2/fastcgi was already owned by www-data. I had to change permission of /var/lib/apache2/fastcgi (all files/recursive) to 0777. I tried 0744 and 0755 but the error persisted with those configs.
I am having errors setting up my webserver on my vps. At the moment I have followed this tutorial: https://www.howtoforge.com/apache_php_mysql_on_centos_6.5_lamp
I am stuck on the /etc/init.d/httpd start part. When I run this command, I get the following output:
[root#localhost conf]# service httpd restart
Stopping httpd: [FAILED]
Starting httpd: [Mon Feb 23 21:27:02 2015] [warn] NameVirtualHost *:80 has no VirtualHosts
[FAILED]
And there is no more output. Prior to this I was getting this error:
[root#localhost etc]# /etc/init.d/httpd start
Starting httpd: httpd: Could not reliably determine the server's fully
qualified domain name, using localhost.localdomain for ServerName [FAILED]
I googled and managed to get this error to disappear by editting /etc/httpd/conf/httpd.conf - I simply uncommented the ServerName variable and changed the value to localhost. So it looks like:
ServerName localhost - In my mind this makes sense since localhost is the external ip server anyways. [NOTE]: Even if I change it to ServerName <external-ip> I still get the same output when restarting httpd.
Can anyone help me get past this step? I've been googling for about 1-2 hours. Can't find anything. Anyone had the same error and mind pointing me in the right direction?
UPDATE 1:
cat /var/log/httpd/error_log
The output is basically normally operation until it reaches this point at which it just spams the rest of the log with it
(2)No such file or directory: httpd: could not open error log file
/srv/www/java-applet/logs/error.log - Unable to open logs
So I guess the error occurs since it cannot find the specified log file? Where can I change this? Why is this even occurring if I have a default installation of httpd?
Update 2:
Nevermind, I just solved it by making the directory that it said it was missing. Lame...
Where can I find error log files?
I need to check them for solving an internal server error shown after installing suPHP.
You can use lsof to find open logfiles on your system. lsof just gives you a list of all open files.
Use grep for "log" ... use grep again for "php" (if the filename contains the strings "log" and "php" like in "php_error_log" and you are the root user you will find the files without knowing the configuration).
lsof | grep log
... snip
gmain 12148 12274 user 13r REG 252,1 32768 661814 /home/user/.local/share/gvfs-metadata/home-11ab0393.log
gmain 12148 12274 user 21r REG 252,1 32768 662622 /home/user/.local/share/gvfs-metadata/root-56222fe2.log
gvfs-udis 12246 user mem REG 252,1 55384 790567 /lib/x86_64-linux-gnu/libsystemd-login.so.0.7.1
==> apache 12333 user mem REG 252,1 55384 790367 /var/log/http/php_error_log**
... snip
lsof | grep log | grep php
**apache 12333 user mem REG 252,1 55384 790367 /var/log/http/php_error_log**
... snip
Also see this article on finding open logfiles: Find open logfiles on a Linux system
It works for me. How can we log all PHP errors to a log file?
Just add the following line to file /etc/php.ini to log errors to specified file – file /var/log/php-scripts.log
vi /etc/php.ini
Modify the error_log directive:
error_log = /var/log/php-scripts.log
Make sure display_errors is set to Off (no errors to end users):
display_errors = Off
Save and close the file. Restart the web server:
/etc/init.d/httpd restart
How do I log errors to syslog or Windows Server Event Log?
Modify error_log as follows:
error_log = syslog
How can we see logs?
Login using ssh or download a log file /var/log/php-scripts.log using SFTP:
sudo tail -f /var/log/php-scripts.log
On CentOS with cPanel installed, my logs were in:
/usr/local/apache/logs/error_log
To watch: tail -f /usr/local/apache/logs/error_log
It depends on what OS you are using and which web server.
On Linux and Apache, you can find the Apache error_log in folder /var/log/apache2/.
This will definitely help you,
Enable PHP error logging
Or
In php.ini (vim /etc/php.ini or sudo vim /usr/local/etc/php/7.1/php.ini)
display_errors = Off
log_errors = On
error_log = /var/log/php-errors.log
Make the log file, and writable by user www-data:
sudo touch /var/log/php-errors.log
/var/log/php-errors.log
sudo chown <owner>:www
I am using CentOS 6.6 with Apache and for me error log files are in:
/usr/local/apache/log
This is a preferable answer in most use cases, because it allows you to decouple execution of the software from direct knowledge of the server platform, which keeps your code much more portable. If you are doing a lot of cron or CGI, this may not help directly, but it can be set into a configuration at web runtime that the cron and CGI scripts pull from to keep the log location consistent in that case.
You can get the current log file assigned natively to PHP on any platform at runtime by using:
ini_get('error_log');
This returns the value distributed directly to the PHP binary by the web server, which is what you want in 90% of use cases (with the glaring exception being CGI). CGI will often log to this same location as the HTTP web server client, but not always.
You will also want to check that it is writeable before committing anything to it to avoid errors. The configuration file that defines its location (typically either file apache.conf globally or vhosts.conf on a per-domain basis), but the configuration does not ensure that file permissions allow write access at runtime.
For Unix CLI users:
Most probably the error_log ini file entry isn't set. To verify:
php -i | grep error_log
// error_log => no value => no value
You can either set it in your php.ini CLI file, or just simply quickly pipe all standard error yourself to a file:
./myprog 2> myerror.log
Then quickly:
tail -f myerror.log
I have been busy setting up my own VPS after being used to cPanel, but I can't seem to find out how to let PHP create an error_log file in the same directory as the script that throws the errors.
I would like this to happen without me having to add a line of code to each .php file. In cPanel this works out of the box somehow.
Example:
Error in: /var/www/webapp1/index.php
Logfile location: /var/www/webapp1/error_log
Error in: /var/www/info/system/test.php
Logfile location: /var/www/info/system/error_log
Basically, I want PHP to store an error_log file in each directory for the scripts in that directory.
Additional information:
Single VPS account
Debian 6.0 (Squeeze) GNU/Linux
Apache 2.2.16
Set the error_log value to the name of the error log you want to appear in the directory, but do not put any slashes. The file will be saved in the directory from which the script is ran, so the same directory.
error_log = "php_error.log"
For this, there is the error_log directive in php.ini like:
error_log string
Where string represents the name of the file where script errors should be logged. The file should be writable by the web server's user. If the special value syslog is used, the errors are sent to the system logger instead. On Unix, this means syslog(3) and on Windows NT it means the event log. The system logger is not supported on Windows 95. See also: syslog(). If this directive is not set, errors are sent to the SAPI error logger. For example, it is an error log in Apache or stderr in CLI.
Edit your php.ini file and uncomment the line with error_log:
error_log = php_errors.log
Save the changes, restart Apache, and be happy.
If you're using Linux, open a terminal and type this to restart:
sudo services apache2 restart
If you have access to WebHost Manager (WHM) you can search for SERVICES and then restart HTTPD or Apache.
If you're using EasyPHP or Vertrigo, you can do that through the program it self.
basically I want php to store an error_log file in each directory for the scripts in that directory
Assuming you're using Apache, you can use Apache's error_log directive in the VirtualHost to accomplish this behaviour. If memory serves me right, PHP itself doesn't decide where it stores its errors.