I lost my php-fpm.sock file from / var / run / php-fpm / - php

I installed PHP 7 on Red Hat Linux server, but apparently due to running a few commands on the server to configure PHP I have the lost the php-fpm.sock file.
Could anyone please assist me with contents of the file?

Yes that file should be auto generated, do not create the file manually! Ensure that the service is running service php-fpm start If it still fails, check the permissions. Check here for help: /etc/php-fpm.d/www.conf This is your main php-fpm config file. Make sure user, group, listen.owner, listen.group are set to your either nginx or apache user, depending on what web server you use. Also note that listen point to the actual socket file.

Related

set php-fpm umask in systemd

I have looked at several other answers and none of them are working. for example: How to set umask for php5-fpm on Debian?
here's the setup.
I have a cakePHP 2 app running with apache as a reverse proxy for php-fpm on RHEL 7.
I've created a site specific user, which we'll call siteuser.
The virtual host for this site will do a 'SuexecUserGroup for the siteuser user/group.
I've added the php-fpm user to the siteuser group.
There are specific directories in cakePHP 2 which must be writable. I've made these directories group writable and set the S bit so new files are created with the group intact.
In addition, I set the systemd UMask for php-fpm as follows:
/etc/systemd/system/php-fpm.service.d/override.conf
[Service]
UMask=113
After saving this file I do a systemctl daemon-reload && systemctl restart php-fpm.
however, the files are getting written as 777 rather than the 664 I would expect.
What am I missing?
Please add a 0 to your umask for the special permissions bit (i.e. sticky, setuid, setgid, etc.)
[Service]
UMask=0113
Update:
It seems like your changes are not being recognized at all...
I just noticed you are setting this in your override.conf file. In this case you need to make sure that override.conf is being included from the main config (IIRC: php5-fpm.service.conf in the same folder).
Also, have a look at this serverfault question that may contain further information for you.

503 service unavailable after installing php-fpm with apache and nginx reverse proxy

I have installed apache on centos 7 and setup nginx as a reverse proxy for apache. Apache listens into 8080 and nginx into 80. I have two virtual hosts and also two server blocks.
Everything is OK and I can see my two server addresses: www1.mysite.com and www2.mysite.com
Now I install php-fpm to run php script. Near to one of my tested index.html files in my websites' root directory, I create an info.php file to see something printed by php. But I encounter a 503 error (unavailable service). What is wrong with my simple configuration do you think?
Any idea or similar experience would help me. Thank you in advance
My problem was almost funny. I had named my sock file php-fpm.sock but it was another name in the php-fpm config file.
I made them equal and the problem was resolved. Hope nobody encounter this rediculous mistake.

How link N php containers with 1 nginx container

i´m moving my wordpress farm (10 installs) to docker architecture,
I want had one nginx container and run 10 php-fpm containers (mysql is on external server)
the php containers are named php_domainname, and also contain persistent storage
i want know how do this:
a)How pass domainname and containername to vhost conf file¿
b)when i start a php-fpm container
1) add a vhost.conf file into nginx confs folder
2) add volume (persistent storage) to nginx instance
3) restart nginx instance
All nginx-php dockers that i founded, has both process per instance, but i think that had 10+1 nginx is overloading the machine, and break the docker advantages
Thanks
No need to reinvent the wheel, this one has already been solved by docker-proxy which is also available on docker hub.
You can also use consul or like with service-autodiscovery. This means:
you add a consul server to your stack
you register all FPM servers as nodes
you register every FPM-daemon as a service "fpm" in consul
For your nginx vhost conf, lets say located /etc/nginx/conf.d/mywpfarm.conf you use consul-template https://github.com/hashicorp/consul-template to generate the config in a go-template were you use
upstream fpm {
{{range service "fpm"}}
server {{.Name}} {{.Address}}:{{.Port}};
{{end}}
}
In your location when you forward .php based request to the FPM upstream, you now use the upstream above. This way nginx will load-balance through all available servers. If you shutdown one FPM host, the config changes automatically and the FPM upstream gets adjusted ( thats what consul-template is for, it watches for changes ) - so you can add new FPM services at any time and scale horizontally very easy

php my admin default Timestamp is wrong even if I use correct timezone

I am experiencing problem in default timestamps I have this column name dateCreated type is TIMESTAMP and default as CURRENT_TIME whenever I insert a new row in my add member page the time generated is late for 2 hrs.
I currently live in ASIA/MANILA which is GMT +8.
I tried changing the php.ini (in my server) timezone to ASIA/MANILA.
but still the generated timestamp is late for 2hrs.
whenever I run the code echo date_default_timezone_get(); I get a result of ASIA/MANILA can somebody tell me what is the problem? and how can I FIX it? thanks in advance
You should restart httpd once. The the httpd RPM installs the /etc/rc.d/init.d/httpd Bourne script, which is accessed using the /sbin/service command.
To start your server, as root type:
/sbin/service httpd start
NOTE: If you are running the Apache HTTP Server as a secure server, you will be prompted to type your password.
To stop your server, type the command:
/sbin/service httpd stop
The command restart is a shorthand way of stopping and then starting your server. The restart command explicitly stops and then starts your server. You will be prompted for your password if you are running the Apache HTTP Server as a secure server. The restart command looks like the following:
/sbin/service httpd restart
If you just finished editing something in your httpd.conf file, you do not need to explicitly stop and start your server. Instead, you can use the reload command.
Note: If you are running the Apache HTTP Server as a secure server, you will not need to type your password when using the reload option as the password will remain cached across reloads.
The reload command looks like the following example:
/sbin/service httpd reload
By default, the httpd process will not start automatically when your machine boots. You will need to configure the httpd service to start up at boot time using an initscript utility, such as /sbin/chkconfig, /sbin/ntsysv, or the Services Configuration Tool program.
For more details about how to restart apache you can check the link Here

Where can I find error log files for PHP?

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

Categories