[Solved] Receiving PHP 403 Error
Added by airsoftsoldrecn9 almost 8 years ago
I am attempting to enable the php-fcgi module in my lighttpd configuration with no success. When opening a page with PHP I receive a 403 Forbidden Access error. Using Entware.
This is my lighttpd.conf:
server.document-root = "/opt/share/www/lighttpd"
server.errorlog = "/opt/var/log/lighttpd/error.log"
server.pid-file = "/opt/var/run/lighttpd.pid"
## Load Modules
include "/opt/etc/lighttpd/modules.conf"
##
## Basic Configuration
server.port = 80
## Mimetypes Load
include "/opt/etc/lighttpd/mime.conf"
static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", ".inc", ".pl" )
index-file.names = ( "index.html", "index.php", "index.htm", "default.htm")
$HTTP["host"] == "test123.ddns.net" {
server.document-root = "/opt/share/www/lighttpd/homeserver/http"
$HTTP["url"] =~ "^/download/" {
dir-listing.activate = "enable"
}
server.errorlog = "/opt/share/www/lighttpd/logs/homeserver/error.log"
#server.error-handler-404 = "/e404.php"
}
So far I have enabled the following modules:
#######################################################################
##
## Loaded Module List
## -------------------
##
## modules to load
# at least mod_access and mod_accesslog should be loaded
# all other module should only be loaded if really neccesary
# - saves some time
# - saves memory
server.modules = (
# "mod_rewrite",
# "mod_redirect",
# "mod_alias",
"mod_access",
# "mod_cml",
# "mod_trigger_b4_dl",
# "mod_auth",
"mod_status",
# "mod_setenv",
"mod_fastcgi",
# "mod_proxy",
"mod_simple_vhost",
# "mod_evhost",
# "mod_userdir",
"mod_cgi",
# "mod_compress",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
# "mod_secdownload",
# "mod_rrdtool",
"mod_accesslog" )
The FastCGI modules looks as follows:
#######################################################################
##
## FastCGI Module
## ---------------
##
## See http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModFastCGI
##
server.modules += ( "mod_fastcgi" )
##
## PHP Example
## For PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini.
##
## The number of php processes you will get can be easily calculated:
##
## num-procs = max-procs * ( 1 + PHP_FCGI_CHILDREN )
##
## for the php-num-procs example it means you will get 17*5 = 85 php
## processes. you always should need this high number for your very
## busy sites. And if you have a lot of RAM. :)
##
## Enable/Disable FastCGI Debugging
fastcgi.debug = 1
fastcgi.server = ( ".php" =>
( "php-local" =>
(
"bin-path" => "/opt/bin/php-fcgi",
"socket" => "/opt/tmp/php-fastcgi.socket",
"max-procs" => 1,
"broken-scriptfilename" => "enable",
)
),
( "php-tcp" =>
(
"host" => "127.0.0.1",
"port" => 9999,
"check-local" => "disable",
"broken-scriptfilename" => "enable",
)
),
( "php-num-procs" =>
(
"bin-path" => "/opt/bin/php-fcgi",
"socket" => "/opt/tmp/php-fastcgi.socket",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "10000",
),
"max-procs" => 5,
"broken-scriptfilename" => "enable",
)
),
)
Lastly, my list of installed packages:
alsa-lib - 1.1.0-1a
asterisk11 - 11.22.0-2
asterisk11-app-playtones - 11.22.0-2
asterisk11-app-queue - 11.22.0-2
asterisk11-app-system - 11.22.0-2
asterisk11-chan-alsa - 11.22.0-2
asterisk11-chan-motif - 11.22.0-2
asterisk11-chan-oss - 11.22.0-2
asterisk11-codec-g726 - 11.22.0-2
asterisk11-codec-g729 - 1.3-2
asterisk11-codec-gsm - 11.22.0-2
asterisk11-format-g726 - 11.22.0-2
asterisk11-format-g729 - 11.22.0-2
asterisk11-format-gsm - 11.22.0-2
asterisk11-format-h264 - 11.22.0-2
asterisk11-pbx-dundi - 11.22.0-2
asterisk11-res-adsi - 11.22.0-2
asterisk11-res-musiconhold - 11.22.0-2
asterisk11-res-smdi - 11.22.0-2
asterisk11-res-xmpp - 11.22.0-2
asterisk11-sounds - 11.22.0-2
asterisk11-voicemail - 11.22.0-2
bcg729 - 1.0.0-1
bzip2 - 1.0.6-2
coreutils - 8.23-2
ffmpeg - 2.8.8-2
file - 5.25-1
findutils - 4.6.0-1
grep - 2.25-1
htop - 2.0.2-1
lame-lib - 3.99.5-2
ldconfig - 1.0.17-1
libacl - 20160519-1
libattr - 20160302-1
libblkid - 2.29.2-1
libbz2 - 1.0.6-2
libc - 1.0.17-1
libcap - 2.25-1
libcurl - 7.51.0-1
libdb47 - 4.7.25.4.NC-5
libevent2 - 2.0.22-1
libexif - 0.6.21-1
libexpat - 2.1.0-3
libffi - 3.2.1-2
libffmpeg-full - 2.8.8-2
libffmpegthumbnailer - 2.2.0-1
libflac - 1.3.1-3
libgcc - 5.4.0-1
libgcrypt - 1.6.6-1
libgdbm - 1.11-1
libgmp - 6.1.1-1
libgnutls - 3.5.6-1
libgpg-error - 1.25-1
libiconv-full - 1.11.1-3
libid3tag - 0.15.1b-4
libidn - 1.33-1
libiksemel - 1.4-1
libintl-full - 0.19.8.1-1
libjpeg - 9a-1
liblzma - 5.2.2-1
libmagic - 5.25-1
libmysqlclient - 5.1.73-2
libncurses - 6.0-1c
libncursesw - 6.0-1c
libnettle - 3.2-1
libogg - 1.3.2-2
libopenssl - 1.0.2j-1a
libopus - 1.1.3-2
libpcre - 8.39-1
libpng - 1.2.56-1
libpopt - 1.16-1
libpthread - 1.0.17-1
libreadline - 7.0-1
librt - 1.0.17-1
libspeex - 1.2rc1-1
libsqlite3 - 3130000-2
libssp - 5.4.0-1
libstdcpp - 5.4.0-1
libtasn1 - 4.8-2
libuuid - 2.28-1b
libvorbis - 1.3.5-1
libx264 - snapshot-20160815-2245-stable-3
libxml2 - 2.9.4-1
lighttpd - 1.4.45-3
lighttpd-mod-access - 1.4.45-3
lighttpd-mod-accesslog - 1.4.45-3
lighttpd-mod-auth - 1.4.44-1b
lighttpd-mod-authn_file - 1.4.44-1b
lighttpd-mod-cgi - 1.4.45-3
lighttpd-mod-fastcgi - 1.4.45-3
lighttpd-mod-simple_vhost - 1.4.45-3
lighttpd-mod-status - 1.4.45-3
minidlna - 1.1.5-1a
mysql-server - 5.1.73-2
nano - 2.7.1-1
ntpd - 4.2.8p10-1
parted - 3.2-1
perl - 5.22.1-3
php5 - 5.6.30-1
php5-cgi - 5.6.30-1
php5-fastcgi - 5.6.30-1
php5-mod-sockets - 5.6.30-1
php7 - 7.0.13-1
python3 - 3.5.2-1a
python3-asyncio - 3.5.2-1a
python3-base - 3.5.2-1a
python3-codecs - 3.5.2-1a
python3-ctypes - 3.5.2-1a
python3-dbm - 3.5.2-1a
python3-decimal - 3.5.2-1a
python3-dev - 3.5.2-1a
python3-distutils - 3.5.2-1a
python3-email - 3.5.2-1a
python3-gdbm - 3.5.2-1a
python3-lib2to3 - 3.5.2-1a
python3-light - 3.5.2-1a
python3-logging - 3.5.2-1a
python3-lzma - 3.5.2-1a
python3-multiprocessing - 3.5.2-1a
python3-ncurses - 3.5.2-1a
python3-openssl - 3.5.2-1a
python3-pip - 8.1.2-1a
python3-pydoc - 3.5.2-1a
python3-setuptools - 27.2.0-1
python3-sqlite3 - 3.5.2-1a
python3-unittest - 3.5.2-1a
python3-xml - 3.5.2-1a
samba36-server - 3.6.25-5
tar - 1.29-2
terminfo - 6.0-1c
tftp-hpa - 5.2-1
tftpd-hpa - 5.2-1
transmission-daemon-openssl - 2.92-3
transmission-web - 2.92-3
xinetd - 2.3.15-4
xz - 5.2.2-1
xz-utils - 5.2.2-1
zip - 3.0-2
zlib - 1.2.8-1
Replies (5)
RE: Receiving PHP 403 Error - Added by gstrauss almost 8 years ago
Comment out your "php-local" settings or your "php-num-procs". They can not both point to the same "socket" => "/opt/tmp/php-fastcgi.socket".
(Or change the "socket" paths to be slightly different)
RE: Receiving PHP 403 Error - Added by airsoftsoldrecn9 almost 8 years ago
Thank you! I tried something to that effect earlier with no results. I suppose a socket file should be created in /opt/tmp? I do not see anything in this directory. The best approach I suppose would be some debugging in the lighttpd error.log.
#######################################################################
##
## FastCGI Module
## ---------------
##
## See http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModFastCGI
##
server.modules += ( "mod_fastcgi" )
##
## PHP Example
## For PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini.
##
## The number of php processes you will get can be easily calculated:
##
## num-procs = max-procs * ( 1 + PHP_FCGI_CHILDREN )
##
## for the php-num-procs example it means you will get 17*5 = 85 php
## processes. you always should need this high number for your very
## busy sites. And if you have a lot of RAM. :)
##
## Enable/Disable FastCGI Debugging
fastcgi.debug = 1
fastcgi.server = ( ".php" =>
((
"bin-path" => "/opt/bin/php-fcgi",
"socket" => "/opt/tmp/php-fastcgi.socket",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "10000",
),
"max-procs" => 5,
"broken-scriptfilename" => "enable",
))
)
RE: Receiving PHP 403 Error - Added by gstrauss almost 8 years ago
FYI: you are not the first to attempt to do this. Please use your favorite search engine for "entware lighttpd php-fcgi" and you'll find a number of tutorials, including https://www.hqt.ro/lighttpd-web-server-with-php-support-through-entware-ng/
Check the file permissions on /opt/tmp and ensure that it is writable by the user running lighttpd.
RE: Receiving PHP 403 Error - Added by airsoftsoldrecn9 almost 8 years ago
Did take a look at that article as well during the course of this process. After more and more digging, I found the problem(s) with my installation. Just thought I would note them here for others to see:
- Make sure to include the configuration files from conf.d
include "/opt/etc/lighttpd/conf.d/10-php-fcgi.conf" OR include "/opt/etc/lighttpd/conf.d/*.conf"
After I fixed that I received this error when opening php files: "No input file specified"
- https://redmine.lighttpd.net/projects/1/wiki/FrequentlyAskedQuestions
Really important section on FastCGI. Make sure the Php.ini file is configured correctly.
Document Root path (doc_root & user_dir) was specified in my php.ini but was not pointing to the same place as the document root path for lighttpd. I chose to comment this out in my php.ini.
Thank you again for your help!
RE: [Solved] Receiving PHP 403 Error - Added by gstrauss almost 8 years ago
Glad you were able to figure it out. Thanks for sharing your solution.