Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
1
votes
1
answers
4842
views
how to make Nginx use home directory as root
I have set up a local server on my laptop for web development and to check the website I'm working on I should have my code base in */var/www/example.domain* which is not so convenient, I want Nginx to retrieve the files and parse PHP from my home directory, something like */home/projects/test-one/*...
I have set up a local server on my laptop for web development and to check the website I'm working on I should have my code base in */var/www/example.domain* which is not so convenient, I want Nginx to retrieve the files and parse PHP from my home directory, something like */home/projects/test-one/* but if I add this directory to
root
it'll throw me a **502 Bad Gateway** error
here's my configuration:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location / {
root /home/amirreza/Projects/escribir/;
index index.php index.html index.htm;
}
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
in */etc/nginx/sites-available/default*, I'm on Debian 11
Amirreza
(203 rep)
Dec 16, 2022, 08:55 AM
• Last activity: Jun 27, 2024, 07:48 PM
0
votes
1
answers
140
views
If "-f %{REQUEST_FILENAME}" what mean's - fcgi
I configures my apache + php-fpm + mod_proxy_fcgi server and I can't understand the line in the two tutorials that don't explain why. This is not found in any other tutorial. SetHandler "proxy:unix:/run/php-fpm/example.com.sock|fcgi://example.com/" -------- I don't understand line: I was able to det...
I configures my apache + php-fpm + mod_proxy_fcgi server and I can't understand the line in the two tutorials that don't explain why. This is not found in any other tutorial.
SetHandler "proxy:unix:/run/php-fpm/example.com.sock|fcgi://example.com/"
--------
I don't understand line:
I was able to determine that this line means:
'check if the file really exists' I understand correctly? If so, why check? maybe it's not needed?
varavell
(1 rep)
Dec 16, 2019, 09:47 PM
• Last activity: Jul 26, 2023, 01:40 PM
1
votes
1
answers
1895
views
Service httpd is failing to start - fcgid can't create shared memory
I'm not sure why, but when I try to start the httpd service, it will not start. Server config: OS: CentOS 5.10 PHP: 5.5.7 Apache: 2.2.3 1. I built mod_fcgid from source, put it into the /etc/httpd/modules directory. 2. I appended `LoadModule fcgid_module modules/mod_fcgid.so` to the list of modules...
I'm not sure why, but when I try to start the httpd service, it will not start.
Server config:
OS: CentOS 5.10
PHP: 5.5.7
Apache: 2.2.3
1. I built mod_fcgid from source, put it into the /etc/httpd/modules directory.
2. I appended
LoadModule fcgid_module modules/mod_fcgid.so
to the list of modules
3. I commented out LoadModule cgi_module modules/mod_cgi.so
since I will not need it.
4. I created a wrapper script for php and placed it into /var/www/cgi-bin:
5. I created a handler for PHP that points to the wrapper.
6. Then I try to start the httpd service
The following is the error that I get in /var/log/httpd/error_log:
[Mon Dec 16 12:18:26 2013] [notice] SELinux policy enabled; httpd running as context user_u:system_r:httpd_t:s0
[Mon Dec 16 12:18:26 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Dec 16 12:18:26 2013] [notice] SSL FIPS mode disabled
[Mon Dec 16 12:18:26 2013] [notice] Digest: generating secret for digest authentication ...
[Mon Dec 16 12:18:26 2013] [notice] Digest: done
[Mon Dec 16 12:18:26 2013] [emerg] (17)File exists: mod_fcgid: Can't create shared memory for size 1200712 bytes
I'm not sure if this is a permissions issue, or something with SELinux perhaps - or maybe suEXEC?
I would appreciate any guidance, since I'm not even sure where to start searching.
zaemz
(254 rep)
Dec 16, 2013, 08:21 PM
• Last activity: Nov 23, 2022, 03:50 PM
2
votes
2
answers
497
views
Asynchronous Child Process in FastCGI Script
Suppose that I want my server to sleep on any HTTP request to the path `/sleep` (i.e. `http://hostname/sleep`), but also send a complete response (`HTTP 200`) before sleeping. [Using **nginx** with **FastCGI**][1], I have configured the path in the **nginx** configuration: location /sleep { fastcgi_...
Suppose that I want my server to sleep on any HTTP request to the path
/sleep
(i.e. http://hostname/sleep
), but also send a complete response (HTTP 200
) before sleeping.
Using **nginx** with **FastCGI** , I have configured the path in the **nginx** configuration:
location /sleep {
fastcgi_pass unix:/path/to/fcgiwrap.socket;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to/script.sh;
}
This invokes the following script (/path/to/script.sh
):
#!/bin/sh
# -*- coding: utf-8 -*-
cat Sleep
Sleep: $(date)
EOF sleep 1 && sudo systemctl suspend /dev/null 2>&1 & Even though this will sleep the system, **FastCGI** will block until the child process completes, meaning that the web request will not complete before the system sleeps. So, how do I detach that final command from oversight by **FastCGI** so that the response completes, yet the command continues in the background, in this case ultimately to sleep the system?
palswim
(5597 rep)
Jun 5, 2021, 05:50 AM
• Last activity: Jun 10, 2021, 08:47 PM
4
votes
1
answers
3604
views
problem with default fcgiwrap socket access rights and nginx (Alpine Linux)
I want to run git-daemon (git-http-backend) in Alpine Linux using nginx and fcgiwrap. However, the default installation of nginx and fcgiwrap leads to a 502 Bad Gateway error. Apparently the group access rights seem to miss the write rights for the fcgiwrap socket. When I grant write access for grou...
I want to run git-daemon (git-http-backend) in Alpine Linux using nginx and fcgiwrap. However, the default installation of nginx and fcgiwrap leads to a 502 Bad Gateway error. Apparently the group access rights seem to miss the write rights for the fcgiwrap socket.
When I grant write access for group on the fcgiwrap socket, everything works beautifully. What would be the proper way to make that work? The socket file is created when fcgiwrap is started, so I cannot adjust the rights before it runs.
**Details:**
I'm using Alpine Linux 3.10. Among others I installed the packages nginx, fcgiwrap and git-daemon. For a simple fcgiwrap test I added perl and a test script
f.pl
.
These are the rights of the fcgiwrap socket after the service is started:
gitsrv-dev:~# ls -la /run/fcgi*
total 0
drwxrwsr-x 2 fcgiwrap www-data 60 Feb 21 08:52 .
drwxr-xr-x 7 root root 320 Feb 17 19:03 ..
srwxr-xr-x 1 fcgiwrap www-data 0 Feb 21 08:52 fcgiwrap.sock
The services run as these users:
gitsrv-dev:~# ps axu | grep -E '(nginx|fcgiwrap)'
3436 root 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
3443 nginx 0:00 nginx: worker process
3490 fcgiwrap 0:00 /usr/bin/fcgiwrap -f -c 1 -s unix:/run/fcgiwrap/fcgiwrap.sock
3554 root 0:00 grep -E (nginx|fcgiwrap)
My test perl script run by fcgiwrap:
gitsrv-dev:~# cat /repos/f/f.pl
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "f.pl is working
"; The configuration to run the f.pl script in nginx: gitsrv-dev:~# vi /etc/nginx/conf.d/f.conf server { listen *:82; location ~ /f(/.*) { gzip off; root /repos/f; client_max_body_size 0; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /repos/f/f.pl; fastcgi_param PATH_INFO $1; fastcgi_param REMOTE_USER $remote_user; fastcgi_pass unix:/run/fcgiwrap/fcgiwrap.sock; } } As mentioned, this default configuration leads to a 502 Bad Gateway error (URLhttp://192.168.1.221:82/f/
).
When I grant g+w
rights, it works:
gitsrv-dev:~# chmod g+w /run/fcgiwrap/fcgiwrap.sock
gitsrv-dev:~# ls -la /run/fcgi*
total 0
drwxrwsr-x 2 fcgiwrap www-data 60 Feb 21 08:52 .
drwxr-xr-x 7 root root 320 Feb 17 19:03 ..
srwxrwxr-x 1 fcgiwrap www-data 0 Feb 21 08:52 fcgiwrap.sock
Reloading the browser now leads to the output f.pl is working
.
I'm using Alpine Linux for a few internal servers - all running nicely in a VM. These are set up using vagrant / puppet and I would like to create a git server now. So I'd like to keep things simple and rather not modify the default script files. Did I miss some obvious configuration options to let fcgiwrap and nginx play nicely together?
Rainer Schwarze
(93 rep)
Feb 21, 2021, 05:26 PM
• Last activity: Feb 24, 2021, 11:11 PM
0
votes
0
answers
231
views
Can not access PHP-FPM site
Using OpenSUSE v15.2, Apache. Installed PHP-FPM with zypper. Followed instructions on this site: https://en.opensuse.org/SDB:Apache_FastCGI_and_PHP-FPM_configuration I restarted Apache and PHP-FPM. However the site is not loading in the browser. **I get HTTP ERROR 502.** `lynx http://10.20.30.40/inf...
Using OpenSUSE v15.2, Apache.
Installed PHP-FPM with zypper.
Followed instructions on this site:
https://en.opensuse.org/SDB:Apache_FastCGI_and_PHP-FPM_configuration
I restarted Apache and PHP-FPM.
However the site is not loading in the browser.
**I get HTTP ERROR 502.**
lynx http://10.20.30.40/info.php
results Alert!: HTTP/1.0 502 cannotconnect
Also get this error:
McAfee Web Gateway - Notification
Cannot Connect
The proxy could not connect to the destination in time.
URL:
_____________________________________________________________________________________________________
generated 2020-08-02 15:00:37 by McAfee Web Gateway
Lynx/2.8.9dev.16 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/1.1.1d
**Might be just a firewall issue?**
**Or error is in my Apache/PHP-FPM config?**
/etc/apache2/vhosts.d/mysite.conf
ServerAdmin webmaster@localhost
ServerName devsite.com
DocumentRoot /srv/www/mydir
# RewriteEngine On
# RewriteRule ^(.*)$ https://devsite.com$1 [L,R=301]
# ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/srv/www/mydir$1
SetHandler "proxy:fcgi://127.0.0.1:9000"
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride None
Options FollowSymLinks MultiViews
AllowOverride None
Require all granted
AccessFileName .htaccess
ErrorLog /var/log/apache2/myhost.err
CustomLog /var/log/apache2/myhost.acs combined
LogLevel warn
I tried to debug the problem with lynx browser locally and got this result:
lynx 127.0.0.1:9000
Looking up 127.0.0.1 first
Looking up 127.0.0.1:9000
Making HTTP connection to 127.0.0.1:9000
Sending HTTP request.
HTTP request sent; waiting for response.
Retrying as HTTP0 request.
Looking up 127.0.0.1:9000
Making HTTP connection to 127.0.0.1:9000
Sending HTTP request.
HTTP request sent; waiting for response.
Alert!: Unexpected network read error; connection aborted.
Can't Access `http://127.0.0.1:9000/ '
Alert!: Unable to access document.
lynx: Can't access startfile
Also tried
lynx http://127.0.0.1/info.php
Looking up 127.0.0.1 first
Looking up 127.0.0.1
Making HTTP connection to 127.0.0.1
Sending HTTP request.
HTTP request sent; waiting for response.
HTTP/1.1 200 OK
which executes phpinfo().
The php was not executed, just offered the info.php to download.
So php is not interpreted.
PHP-FPM log:
tail -f /var/log/php-fpm.log
[02-Aug-2020 01:37:29] NOTICE: Terminating ...
[02-Aug-2020 01:37:29] NOTICE: exiting, bye-bye!
[02-Aug-2020 01:37:29] NOTICE: fpm is running, pid 8099
[02-Aug-2020 01:37:29] NOTICE: ready to handle connections
[02-Aug-2020 01:37:29] NOTICE: systemd monitor interval set to 10000ms
[02-Aug-2020 01:39:47] NOTICE: Terminating ...
[02-Aug-2020 01:39:47] NOTICE: exiting, bye-bye!
[02-Aug-2020 01:39:47] NOTICE: fpm is running, pid 8202
[02-Aug-2020 01:39:47] NOTICE: ready to handle connections
[02-Aug-2020 01:39:47] NOTICE: systemd monitor interval set to 10000ms
Shows that it is running, and shows restarts, nothing more.
Apache error log:
tail -f /var/log/apache2/error_log
[Sun Aug 02 01:37:34.743959 2020] [mpm_prefork:notice] [pid 6160] AH00170: caught SIGWINCH, shutting down gracefully
AH00557: httpd-prefork: apr_sockaddr_info_get() failed for myhost
AH00558: httpd-prefork: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[Sun Aug 02 01:37:34.818193 2020] [mpm_prefork:notice] [pid 8113] AH00163: Apache/2.4.43 (Linux/SUSE) OpenSSL/1.1.1d configured -- resuming normal operations
[Sun Aug 02 01:37:34.818251 2020] [core:notice] [pid 8113] AH00094: Command line: '/usr/sbin/httpd-prefork -D SYSCONFIG -D SSL -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache2/sysconfig.d//include.conf -D SYSTEMD -D FOREGROUND'
[Sun Aug 02 01:39:45.771523 2020] [mpm_prefork:notice] [pid 8113] AH00170: caught SIGWINCH, shutting down gracefully
AH00557: httpd-prefork: apr_sockaddr_info_get() failed for myhost
AH00558: httpd-prefork: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[Sun Aug 02 01:39:45.852536 2020] [mpm_prefork:notice] [pid 8186] AH00163: Apache/2.4.43 (Linux/SUSE) OpenSSL/1.1.1d configured -- resuming normal operations
[Sun Aug 02 01:39:45.852586 2020] [core:notice] [pid 8186] AH00094: Command line: '/usr/sbin/httpd-prefork -D SYSCONFIG -D SSL -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Include /etc/apache2/sysconfig.d//global.conf -f /etc/apache2/httpd.conf -c Include /etc/apache2/sysconfig.d//include.conf -D SYSTEMD -D FOREGROUND'
In www.conf I enabled
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
But no /var/log/fpm-php.www.log was created.
Apache info:
apachectl -S
VirtualHost configuration:
10.20.30.40:80 mysite.com (/etc/apache2/vhosts.d/myhost.conf:1)
*:443 mysite.com (/etc/apache2/vhosts.d/myhost.ssl.conf:1)
ServerRoot: "/srv/www"
Main DocumentRoot: "/srv/www/htdocs"
Main ErrorLog: "/var/log/apache2/error_log"
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/run/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/var/run/httpd.pid"
Define: SYSCONFIG
Define: SSL
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="wwwrun" id=471
Group: name="www" id=471
/etc/apache2/conf.d/mod_fcgid.conf:
FcgidIPCDir /var/lib/apache2/fcgid/
FcgidProcessTableFile /var/lib/apache2/fcgid/shm
#
# SetHandler "proxy:fcgi://localhost/"
# SetHandler "proxy:fcgi://127.0.0.1:9000/"
#
/etc/php7/fpm/php-fpm.conf
[global]
include=/etc/php7/fpm/php-fpm.d/*.conf
/etc/php7/fpm/php-fpm.d/www.conf
[www]
user = wwwrun
group = www
listen = 127.0.0.1:9000
listen.owner = wwwrun
listen.group = www
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
Any idea, what can be the problem?
klor
(426 rep)
Aug 2, 2020, 12:10 AM
• Last activity: Aug 2, 2020, 01:13 PM
1
votes
1
answers
685
views
fastcgi php nginx errorlog messed up
I have a strange problem, the errorlog of my nginx server is somehow messed up: PHP errors seem to be all written in one line and repeating itself recursively. This way the llog grows a few GB within one day! This is **one line** in the error log: 2020/03/26 16:58:45 [error] 29816#29816: *32 FastCGI...
I have a strange problem, the errorlog of my nginx server is somehow messed up: PHP errors seem to be all written in one line and repeating itself recursively. This way the llog grows a few GB within one day!
This is **one line** in the error log:
2020/03/26 16:58:45 [error] 29816#29816: *32 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined variable: SCRIPT_FILENAME in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 58PHP message: PHP Notice: Undefined variable: pfad in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 60PHP message: PHP Notice: Undefined offset: 1 in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 65PHP message: PHP Notice: Undefined variable: benutzer in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 70PHP message: PHP Notice: Undefined index: PATH_TRANSLATED in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 84PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on li
The lines are cut after 2048 characters.
here i split the lines before each new error:
2020/03/26 16:58:45 [error] 29816#29816: *32 FastCGI sent in stderr: "
PHP message: PHP Notice: Undefined variable: SCRIPT_FILENAME in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 58
PHP message: PHP Notice: Undefined variable: pfad in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 60
PHP message: PHP Notice: Undefined offset: 1 in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 65
PHP message: PHP Notice: Undefined variable: benutzer in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 70
PHP message: PHP Notice: Undefined index: PATH_TRANSLATED in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 84
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on line 96
PHP message: PHP Notice: Undefined variable: localdir in /var/kunden/webs/my_web_app/www/pics/userpics/index.php on li
Where could this come from? how do I have to define a standard error reporting in nginx?
rubo77
(30435 rep)
Mar 26, 2020, 04:05 PM
• Last activity: Mar 26, 2020, 04:24 PM
2
votes
2
answers
3117
views
Can't get Perl FastCGI script to run on Apache Server: Error 500
I'm trying to run an Apache server that executes some scripts over fast CGI, but I can't figure out for the life of me how to actually get it to work. My problem in particular is the "Error 500: End of script output before headers". I've been reading a lot about this, following every suggestion I ca...
I'm trying to run an Apache server that executes some scripts over fast CGI, but I can't figure out for the life of me how to actually get it to work. My problem in particular is the "Error 500: End of script output before headers".
I've been reading a lot about this, following every suggestion I can find but still no luck. There were some about IOTimeout and BusyTimeout and every other kind of Fcgid timeout available, but those did nothing and I don't think my problem is related to it.
Starting from a fresh linux installation this is what I've done:
1. Installed
apache
and mod_fcgid
.
2. Created a new empty web at /var/www/test
with some empty files and a script. I've set the permissions accordingly and just to be sure changed the owner and group to http.
$ ls -l /var/www
drwxrwxr-x 1 http http 122 Nov 8 16:08 test/
$ ls -l /var/www/test
-rw-rw-r-- 1 http http 0 Nov 8 15:29 file01.txt
-rw-rw-r-- 1 http http 0 Nov 8 15:29 file02.txt
-rw-rw-r-- 1 http http 0 Nov 8 15:29 file03.txt
-rwxr-xr-x 1 http http 107 Nov 8 16:08 run.fcgi*
$ cat /var/www/test/run.fcgi
#!/usr/bin/perl
use strict;
use warnings;
print "Content-type: text/html\n\n";
print "Hello world.\n";
3. I've appended this to /etc/httpd/conf/httpd.conf
:
LoadModule fcgid_module modules/mod_fcgid.so
AddHandler fcgid-script .fcgi
DocumentRoot /var/www/test
Options +Indexes +ExecCGI
Require all granted
Now, I can run the script perfectly fine from the terminal. When I then head over to http://localhost
I get a list of the directory files as expected, but when I then open the script I get the error 500 mentioned above. The apache's error log shows this (snipped unnecessary parts):
Content-type: text/html
Hello world.
(...) Connection reset by peer (...) mod_fcgid: error reading data from FastCGI server, referer: (...)
(...) End of script output before headers: run.fcgi, referer: (...)
Why is it that the script's output got logged into the error log? I think this is related to permissions and ownership, but I can't figure out how, I think I've set all of them accordingly. Do you have any idea what I can do to get this to run?
I'm trying to run all this in a 64-bit Arch linux box.
Thank you all!
elpato
(145 rep)
Nov 8, 2015, 07:48 PM
• Last activity: Feb 19, 2020, 05:13 AM
1
votes
1
answers
2730
views
How to configure which user fcgiwrap runs as on FreeBSD?
I have Redmine/Git/nginx/fcgiwrap running in a jail on FreeBSD 9.3 for (potentially) authenticated Git commits over HTTP/S. Everything works until I restart the jail. In order for a commit to work I need to manually change `/var/run/fcgiwrap/fcgiwrap.sock` from `srwxr-xr-x root:wheel` to `srwxrwxr-x...
I have Redmine/Git/nginx/fcgiwrap running in a jail on FreeBSD 9.3 for (potentially) authenticated Git commits over HTTP/S. Everything works until I restart the jail.
In order for a commit to work I need to manually change
/var/run/fcgiwrap/fcgiwrap.sock
from srwxr-xr-x root:wheel
to srwxrwxr-x root:www
.
It seems like there should be a better way to do this so that its persistent over a reboot. My feeling is that there should be some way of telling fcgiwrap who to run as but I can't work out where this is specified on FreeBSD.
The man page says:
> Most probably you will want to launch fcgiwrap by spawn-fcgi using a configuration like this:
FCGI_SOCKET=/var/run/fcgiwrap.sock
FCGI_PROGRAM=/usr/sbin/fcgiwrap
FCGI_USER=nginx
FCGI_GROUP=www
FCGI_EXTRA_OPTIONS="-M 0700"
ALLOWED_ENV="PATH"
Based on this question I have looked in /usr/local/etc/rc.d
for spawn-fcgi
but its not there which I assume means its not installed. It also seems overkill to install spawn-fcgi just to manage who fcgiwrap runs as.
I've found in /usr/local/etc/rc.d/fcgiwrap
it says:
# fcgiwrap rc.d script supports multiple profiles (a-la rc.d/nginx)
# When profiles are specified, the non-profile specific parameters become defaults.
# You need to make sure that no two profiles have the same socket parameter.
What is a profile and how would I go about creating one for this rc.d script? Or am I going about this all the wrong way?
Samuel Harmer
(295 rep)
Sep 5, 2015, 12:09 PM
• Last activity: Jan 14, 2019, 03:01 AM
2
votes
1
answers
389
views
Nginx version agnostic php-fpm configuration
When I create a new webapp conf in Nginx I use the following template: server { root /var/www/html/${domain}; server_name ${domain} www.${domain}; location ~* \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ { expires 365d; } location / { index index.php index.html index.htm fastcgi_index; try_files $u...
When I create a new webapp conf in Nginx I use the following template:
server {
root /var/www/html/${domain};
server_name ${domain} www.${domain};
location ~* \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
expires 365d;
}
location / {
index index.php index.html index.htm fastcgi_index;
try_files $uri $uri =404 $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Note the following
location
block in that template:
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).
Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.
## Update
BTW, these 7.0 directives can **also** be a bit painful - you sometimes just want to run a script, without starting to measure versions:
sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service
Arcticooling
(1 rep)
Dec 31, 2017, 05:03 AM
• Last activity: Dec 31, 2017, 06:06 PM
1
votes
1
answers
211
views
Building dynamically driven web sites with Mason (Perl) with httpd on OpenBSD current
Is it possible to build dynamically driven web sites with Mason (Perl) with httpd on OpenBSD current? See [_The Mason Book_][1] and [the introduction to OpenBSD's httpd][2]. [1]: http://masonbook.houseabsolute.com/ [2]: https://www.openbsd.org/papers/httpd-slides-asiabsdcon2015.pdf
Is it possible to build dynamically driven web sites with Mason (Perl) with httpd on OpenBSD current?
See _The Mason Book_ and the introduction to OpenBSD's httpd .
Vim
(229 rep)
Nov 23, 2016, 09:31 AM
• Last activity: Dec 15, 2017, 03:47 PM
3
votes
2
answers
3223
views
Nginx on FreeBSD: fcgiwrap.sock permission denied
I'm trying to setup nginx and cgit on FreeBSD but nginx can't access `/var/run/fcgiwrap/fcgiwrap.sock`. In my `/etc/rc.conf` I already set `fcgiwrap_user="www"`, and `www` is also the user nginx runs as. When I make `fcgiwrap.sock` owned by `www` by performing `chown www /var/run/fcgiwrap/fcgiwrap.s...
I'm trying to setup nginx and cgit on FreeBSD but nginx can't access
/var/run/fcgiwrap/fcgiwrap.sock
.
In my /etc/rc.conf
I already set fcgiwrap_user="www"
, and www
is also the user nginx runs as.
When I make fcgiwrap.sock
owned by www
by performing chown www /var/run/fcgiwrap/fcgiwrap.sock
, everything works the way I want.
However this is of course not the proper way to do this, and it will only last until reboot.
I was under the assumption that setting fcgiwrap_user="www"
would also determine this.
Am I missing something?
**Update:**
I noticed that when I use service fcgiwrap start
or restart
, the message Starting fcgiwrap
is followed by chmod: /var/run/fcgiwrap/fcgiwrap.sock: No such file or directory
. However /var/run/fcgiwrap/fcgiwrap.sock
does exist afterwards.
Jessica Nowak
(57 rep)
Apr 13, 2017, 03:11 PM
• Last activity: Apr 21, 2017, 05:46 PM
2
votes
0
answers
872
views
Nginx & FastCGI Buffering
I want to ask few questions regarding nginx and fastcgi buffering that i can't find an answer for. 1) Is the fastcgi_buffering values / request or for entire nginx? 2) Assuming that i want to have exactly buffer size of 3MB, what should i do? 3) Assuming that we set the buffer size 3 MB, and we have...
I want to ask few questions regarding nginx and fastcgi buffering that i can't find an answer for.
1) Is the fastcgi_buffering values / request or for entire nginx?
2) Assuming that i want to have exactly buffer size of 3MB, what should i do?
3) Assuming that we set the buffer size 3 MB, and we have a file with 10MB in size to send with php what nginx will do? It will buffer the first 3MB, sends them to client, then re-buff the next 3MB etc? Or it will continuously buffer 3MB until we send our whole file? (nginx buffers 3MB, clients get for example 100kb, then nginx will fill the buffer to 3MB again?)
4) Assuming that i set the
> fastcgi_max_temp_file_size 0;
Nginx will only use Memory to buffer the response? Is a good technique to avoid too much I/O in case we have many requests?
5) Does it makes sense to use fastcgi buffering in endless requests? (eg. sending live stream data with php)
user3393046
(143 rep)
Oct 22, 2016, 01:29 PM
0
votes
4
answers
21581
views
permission error with php/nginx and not using www-data
-edit- whats even more curious is if I `chmod 777 /var/run/php-fastcgi/php-fastcgi.socket` this works. If it's not www-data, php-www (nor root) then what user is trying to access the socket :| -edit2- I added `chown www-data:$FASTCGI_GROUP $SOCKET` to the end of the script below (which is right afte...
-edit- whats even more curious is if I
chmod 777 /var/run/php-fastcgi/php-fastcgi.socket
this works. If it's not www-data, php-www (nor root) then what user is trying to access the socket :|
-edit2- I added chown www-data:$FASTCGI_GROUP $SOCKET
to the end of the script below (which is right after spawn-fcgi
) and that solves the problem, but I'm confused, www-data is in the php-www group. Why must it be owner. I didn't change FASTCGI_USER back to www-data bc it would defeat the purpose (it would allow the PHP files to access all my files as www-data which I don't want)
Essentially what I wanted to do is have the PHP process not be www-data so if it gets compromised its damage is limited to the very few PHP sites I have. What I did was create the user php-www and add its group to www-data. When I log in as www-data I can access everything ih php-www however php-www can't access anything but my PHP sites. perfect.
I got php+nginx running. But how changing it gives me a problem. I see www-data mention in a init.d script which changes the ownership of a folder. Its fine and I changed it to php-www. Thats not a problem.
What is the problem is the spawn script.
#!/bin/bash
FASTCGI_USER=php-www
FASTCGI_GROUP=php-www
SOCKET=/var/run/php-fastcgi/php-fastcgi.socket
PIDFILE=/var/run/php-fastcgi/php-fastcgi.pid
CHILDREN=6
PHP5=/usr/bin/php5-cgi
/usr/bin/spawn-fcgi -s $SOCKET -P $PIDFILE -C $CHILDREN -u $FASTCGI_USER -g $FASTCGI_GROUP -f $PHP5
the user/group lines use to say www-data but now I changed them to php-www.
I started php-fastcgi and nginx. When I visit my site I get a 502 bad gateway error. When I look in nginx logs I see this line
connect() to unix:/var/run/php-fastcgi/php-fastcgi.socket failed (13: Permission denied) while connecting to upstream
Permission denied!?! why!?! www-data does have the group php-www and stat
that folder and socket shows owner and group php-www. I can access the PHP file with bot php-www and www-data. Why am I get a permission error? and what am I doing wrong?
in case you want to see my process
# ps aux | egrep "php|www"
shows
www-data 548 0.0 0.1 1908 492 ? Ss 18:08 0:00 /usr/sbin/fcgiwrap
www-data 586 0.0 0.1 1908 488 ? Ss 18:08 0:00 /usr/sbin/fcgiwrap
php-www 1611 0.0 1.9 19312 5020 ? Ss 18:20 0:00 /usr/bin/php5-cgi
php-www 1612 0.0 0.7 19312 1856 ? S 18:20 0:00 /usr/bin/php5-cgi
php-www 1613 0.0 0.7 19312 1856 ? S 18:20 0:00 /usr/bin/php5-cgi
php-www 1614 0.0 0.7 19312 1856 ? S 18:20 0:00 /usr/bin/php5-cgi
php-www 1615 0.0 0.7 19312 1856 ? S 18:20 0:00 /usr/bin/php5-cgi
php-www 1616 0.0 0.7 19312 1856 ? S 18:20 0:00 /usr/bin/php5-cgi
php-www 1617 0.0 0.7 19312 1856 ? S 18:20 0:00 /usr/bin/php5-cgi
www-data 1776 0.0 0.6 5428 1684 ? S 18:27 0:00 nginx: worker process
php-www 1967 0.0 1.9 19312 5020 ? Ss 18:40 0:00 /usr/bin/php5-cgi
php-www 1968 0.0 0.7 19312 1856 ? S 18:40 0:00 /usr/bin/php5-cgi
php-www 1969 0.0 0.7 19312 1856 ? S 18:40 0:00 /usr/bin/php5-cgi
php-www 1970 0.0 0.7 19312 1856 ? S 18:40 0:00 /usr/bin/php5-cgi
php-www 1971 0.0 0.7 19312 1856 ? S 18:40 0:00 /usr/bin/php5-cgi
php-www 1972 0.0 0.7 19312 1856 ? S 18:40 0:00 /usr/bin/php5-cgi
php-www 1973 0.0 0.7 19312 1856 ? S 18:40 0:00 /usr/bin/php5-cgi
root 2110 0.0 0.2 3300 736 pts/1 S+ 18:55 0:00 egrep php|www
user4069
Sep 29, 2011, 01:57 AM
• Last activity: Sep 11, 2016, 01:24 PM
0
votes
1
answers
250
views
What Are The Advantages of Using A Dedicated Web Server?
To elaborate, what are the advantages of using a dedicated web server (i.e. lighttpd or nginx) and running programs (i.e. Swift / Python) as directed by the web server? Specifically, how does that compare to simply running a web framework (i.e. Perfect / Flask) and using its inbuilt routing?
To elaborate, what are the advantages of using a dedicated web server (i.e. lighttpd or nginx) and running programs (i.e. Swift / Python) as directed by the web server?
Specifically, how does that compare to simply running a web framework (i.e. Perfect / Flask) and using its inbuilt routing?
Brandon Bradley
(349 rep)
Aug 24, 2016, 11:56 PM
• Last activity: Aug 25, 2016, 12:28 AM
2
votes
0
answers
851
views
proper permissions under HTTP root with Apache2 + FastCGI + Suexec
I currently have a setup which runs Apache2 + FastCGI PHP + Suexec. As an example, I'm using `/mnt/data/www/vhosts/inflex.co.uk/htdocs` as a DocRoot for one of my virtual hosts. I have a script `/mnt/data/www/php5-cgi/inflex.co.uk/php5-cgi` which contains: #!/bin/sh exec /usr/bin/php5-cgi The accoun...
I currently have a setup which runs Apache2 + FastCGI PHP + Suexec.
As an example, I'm using
/mnt/data/www/vhosts/inflex.co.uk/htdocs
as a DocRoot for one of my virtual hosts.
I have a script /mnt/data/www/php5-cgi/inflex.co.uk/php5-cgi
which contains:
#!/bin/sh
exec /usr/bin/php5-cgi
The account the scripts should run under is duncan
, this file is owned by duncan and also in the group duncan. It has -rwxr-x---
permissions.
.../www/vhosts/inflex.co.uk
and ../inflex.co.uk/htdocs
is owned by duncan and in the group duncan.
If I remove all access for others, such as chmod 750
, I get an error regarding permissions when trying to access the website, if I allow read/write for others, 755 say, it works.
I'm assuming this is an issue with www-data
(apache2 user) accessing the directory, but I thought the point of Suexec was that all of this was ran under a seperate user, or does www-data
require read (maybe write?) on the folder and then executes PHP php file as the user?
dunks
(21 rep)
Apr 9, 2012, 12:14 PM
• Last activity: Jul 12, 2016, 12:00 PM
1
votes
1
answers
713
views
lighttpd2 and php under fast-cgi returns 403 "Permission denied"
lighttpd2 is under development but it's faar enough to where i want to start using it. I've overcome the hurdle of installing it and getting vhost etc working. * PHP 5.6.6 (cgi-fcgi) (built: Feb 20 2015 17:27:21) * lighttpd-angel/2.0.0 - a fast and lightweight webserver | Build date: Mar 17 2015 13:...
lighttpd2 is under development but it's faar enough to where i want to start using it.
I've overcome the hurdle of installing it and getting vhost etc working.
* PHP 5.6.6 (cgi-fcgi) (built: Feb 20 2015 17:27:21)
* lighttpd-angel/2.0.0 - a fast and lightweight webserver
| Build date: Mar 17 2015 13:42:32
* Arch Linux | linux 3.18.6-1
* VMWare Workstation 11.1.0 build-2496824
However php gives me the worst headache.
/etc/lighttpd2/php.conf
looks as follows:
if phys.path =$ ".php" {
log.write "Accessing php file";
fastcgi "unix:/srv/http/php.sock";
}
The sock used to reside under /var/run/lighttpd2/ but for access/debugging purposes I moved it to /srv/http where the entire doc-root is.
And this is what my /etc/lighttpd2/lighttpd.conf
looks like:
setup {
module_load [
"mod_accesslog",
"mod_dirlist",
"mod_vhost"
"mod_fastcgi"
];
listen "0.0.0.0:80";
listen "[::]:80";
log [
"info" => "/var/log/lighttpd2/info.log",
"error" => "/var/log/lighttpd2/error.log",
"abort" => "/var/log/lighttpd2/error.log",
"backend" => "/var/log/lighttpd2/backend.log",
"debug" => "/var/log/lighttpd2/debug.log",
default => "/var/log/lighttpd2/error.log"
];
accesslog "/var/log/lighttpd2/access.log";
accesslog.format "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"";
static.exclude_extensions [ ".php", ".pl", ".fcgi", "~", ".inc" ];
}
include "/etc/lighttpd2/mimetypes.conf";
include "/etc/lighttpd2/vhost.conf";
include "/etc/lighttpd2/php.conf";
#docroot "/srv/http";
index [ "index.php", "index.html", "index.htm", "default.htm", "index.lighttpd.html" ];
dirlist;
static;
Not sure if I should comment out static
at the end or not.
And finally, my "startup script" for php looks as follows:
#!/bin/sh
exec 2>&1
PHP_FCGI_CHILDREN=2 \
PHP_FCGI_MAX_REQUESTS=10000 \
LANG=C LC_ALL=C \
exec /usr/bin/spawn-fcgi -n -s /srv/http/php.sock -u www-data -U www-data -- /usr/bin/php-cgi
My logs are almost empty, but never the less here's what they say:
Startup log from systemd
---
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: info (angel_plugin.c:166): activate
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: info (angel_plugin.c:177): done
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:765: Reached state: suspended (dest: down)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:677: Try reaching state: stopping (dest: down)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:765: Reached state: stopping (dest: down)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:677: Try reaching state: down (dest: down)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:765: Reached state: down (dest: down)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (info) lighttpd_worker.c:141: going down
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: debug (angel_server.c:367): instance released
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: info (angel_main.c:94): going down
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: info (angel_plugin.c:166): activate
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: info (angel_plugin.c:171): activate: core
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: debug (angel_server.c:184): Instance (30976) spawned: /usr/lib/lighttpd-2.0.0/lighttpd2/lighttpd2-worker
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: info (angel_plugin.c:177): done
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: info (angel_main.c:90): parsed config file
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) lighttpd_worker.c:105: config path: /etc/lighttpd2/lighttpd.conf
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) plugin_core.c:1254: loaded module 'mod_accesslog'
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) plugin_core.c:1254: loaded module 'mod_dirlist'
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) plugin_core.c:1254: loaded module 'mod_vhost'
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) plugin_core.c:1254: loaded module 'mod_fastcgi'
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:765: Reached state: loading (dest: suspended)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:677: Try reaching state: suspended (dest: suspended)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:765: Reached state: suspended (dest: suspended)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: debug (angel_plugin_core.c:638): listen to ipv4: '0.0.0.0:80' (port: 80)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: debug (angel_plugin_core.c:679): listen to ipv6: '::' (port: 80)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:677: Try reaching state: warmup (dest: running)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:765: Reached state: warmup (dest: running)
Mar 17 17:14:21 ArchKB lighttpd2: 2015-03-17 17:14:21 CET: lighttpd2-worker: 17/Mar/2015 17:14:21 CET (debug) server.c:677: Try reaching state: running (dest: running)
Error-log is empty, but info.log
says:
17/Mar/2015 17:14:21 CET (info) server.c:58: Got signal, shutdown
debug.log
says:
17/Mar/2015 17:12:29 CET (debug) server.c:677: Try reaching state: suspending (dest: down)
17/Mar/2015 17:12:29 CET (debug) server.c:765: Reached state: suspending (dest: down)
17/Mar/2015 17:12:29 CET (debug) server.c:677: Try reaching state: suspended (dest: down)
17/Mar/2015 17:12:29 CET (debug) server.c:765: Reached state: running (dest: running)
And access.log
(after I've requested index.php) says:
192.168.253.1 192.168.253.130 - [17/Mar/2015:17:12:36 +0100] "GET / HTTP/1.1" 403 3744 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36"
Access on files
---
If I comment out everything to do with **php**, I get the file as a downloaded object with the proper content of:
The header()
mod is just to make sure that lighttp doesn't screw up the headers because it's CGI (it's happned before and this *should* not affect the end result in a bad way).
The permissions looks as follows:
-rwxrwxrwx 1 www-data www-data 84 Mar 17 16:40 index.php
srw-r----- 1 www-data www-data 0 Mar 17 16:47 php.sock
-rw-r--r-- 1 root root 5 Mar 17 17:06 wham.html
"Funny" thing is that I can request wham.html
without a problem and it's owned by root, but according to the documentation only working should be run as non-root, which I am:
root 30975 0.0 0.6 5104 3140 ? Ss 17:14 0:00 /usr/sbin/lighttpd2 -c /etc/lighttpd2/angel.conf
www-data 30976 0.0 0.7 52048 3760 ? Ssl 17:14 0:00 /usr/lib/lighttpd-2.0.0/lighttpd2/lighttpd2-worker --angel -c /etc/lighttpd2/lighttpd.conf
Where the hell am I going wrong about this?
---
My conclusion is that it's something to do with php.conf
, because log.write
never executes, or at least I can't see anything in any of the logs.
So I need help, badly!
Torxed
(3727 rep)
Mar 17, 2015, 03:33 PM
• Last activity: Mar 18, 2015, 08:25 AM
30
votes
9
answers
52645
views
Ensure a process is always running
I started hosting sites a while back using Cherokee. For external sources (FastCGI, etc) it has an option to launch the process if it can't find one running on the designated socket or port. This is great because it means if PHP or a Django site falls over (as they occasionally do) it restarts it au...
I started hosting sites a while back using Cherokee. For external sources (FastCGI, etc) it has an option to launch the process if it can't find one running on the designated socket or port. This is great because it means if PHP or a Django site falls over (as they occasionally do) it restarts it automatically.
On a new server using PHP-FPM I couldn't use Cherokee (it has a bug with PHP) so I've moved to NGINX. I really like NGINX (for its config style) but I'm having serious issues with processes falling over and never respawning. PHP does this sometimes but Django sites are more of a problem. I've created init scripts for them and they come up on boot but this doesn't help me if they conk out between reboots.
I guess I'm looking for a FastCGI proxy. Something that, like Cherokee, knows what processes should be running on which sockets/ports and respawns them on-demand. Does such a thing exist? Is there any way to build this into NGINX (for ease of config)?
Oli
(16366 rep)
Aug 20, 2010, 11:56 AM
• Last activity: Oct 30, 2014, 09:25 PM
1
votes
1
answers
767
views
goaccess won't run when called from CGI script
I'm trying to make a CGI script (for nginx) that outputs an html page containing the usage statistics for my server. I'm using goaccess 0.7.1 and CentOS 5 x86. I've configured nginx to run my bash script (`stats.sh`) for requests on port 8080. The bash script looks like this: #!/bin/bash cat /var/lo...
I'm trying to make a CGI script (for nginx) that outputs an html page containing the usage statistics for my server. I'm using goaccess 0.7.1 and CentOS 5 x86.
I've configured nginx to run my bash script (
stats.sh
) for requests on port 8080.
The bash script looks like this:
#!/bin/bash
cat /var/log/nginx/mydomain.access.log | goaccess -a > stats.html
echo Content-Type: text/html
echo Content-Length: $(stat -c%s stats.html)
echo
cat stats.html
When I run ./stats.sh
, everything works fine. It prints a bunch of html code in the console window, and if I open stats.html, I see a bunch of html code.
**THE PROBLEM IS**, when I try to access http://www.mydomain.com:8080/
, I just get a blank page. Now when I open stats.html on the server, it's completely empty.
I've confirmed the following permissions:
- stats.sh
: -rwxr-xr-x
- stats.html
: -rw-rw-rw-
- goaccess
: -rwxr-xr-x
I also know that CGI is working properly because if I modify stats.sh
to only output the contents of stats.html
(without writing to the file), it works fine when I hit http://www.mydomain.com:8080/
; it just sends whatever data was in stats.html
from before. So something is going wrong with calling goaccess in a CGI script. Does anyone know why?
**UPDATE**
I also tried this:
echo "TEST" > stats.html
and it works fine when I hit http://www.mydomain.com:8080/
, so something is going wrong when running goaccess
from FastCGI.
I also tried specifying the full path to goaccess
(/usr/local/bin/goaccess
):
/var/log/nginx/mydomain.access.log | /usr/local/bin/goaccess -a >stats.html 2>stats.err
but this also did not work.
AJ Richardson
(121 rep)
Aug 8, 2014, 12:30 AM
• Last activity: Sep 4, 2014, 07:18 PM
1
votes
2
answers
3015
views
PHP+FastCGI+nginx on Debian
I new with Debian. I want to use php on Debian. I do: apt-get install php5-cli php5-cgi spawn-fcgi Create file `/usr/bin/php-fastcgi`: #! /bin/sh PHP_FCGI_CHILDREN=3 PHP_FCGI_MAX_REQUESTS=1000 exec /usr/bin/php5-cgi Create file `/etc/init.d/init-fastcgi`: #!/bin/bash PHP_SCRIPT="/usr/bin/spawn-fcgi...
I new with Debian. I want to use php on Debian.
I do:
apt-get install php5-cli php5-cgi spawn-fcgi
Create file
/usr/bin/php-fastcgi
:
#! /bin/sh
PHP_FCGI_CHILDREN=3
PHP_FCGI_MAX_REQUESTS=1000
exec /usr/bin/php5-cgi
Create file /etc/init.d/init-fastcgi
:
#!/bin/bash
PHP_SCRIPT="/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php-fastcgi"
RETVAL=0
case "$1" in
start)
$PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php5-cgi
RETVAL=$?
;;
restart)
killall -9 php5-cgi
$PHP_SCRIPT
RETVAL=$?
;;
*)
echo "Usage: sudo /etc/init.d/init-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
Ater do:
chmod 755 /usr/bin/php-fastcgi
chmod 755 /etc/init.d/init-fastcgi
Into /etc/nginx/sites-enabled/default
add:
location ~\.php$ {
root /srv/www/ekb.mydomain.com/public_html;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SCRIPT_FILENAME /srv/www/ekb.mydomain.com/public_html$fastcgi_script_name;
}
Create directories:
/srv/www/ekb.mydomain.com/public_html
/srv/www/ekb.mydomain.com/logs
Create file /srv/www/ekb.mydomain.com/public_html/test.php
Start serice:
/etc/init.d/init-fastcgi start
/etc/init.d/nginx start
In browser:
www.ekb.maydomain.com/test.php
but get 404 error.
What i can do wrong?
Kliver Max
(219 rep)
Mar 24, 2014, 11:50 AM
• Last activity: Mar 24, 2014, 08:00 PM
Showing page 1 of 20 total questions