Php7 config problem on apache2 // OpenWrt 19.7.2

Hi all, only discovered this amazing software last week, flashed a few devices and had a good play around until ran into a problem trying to setup a small web server...

apache seems to work just fine and /usr/bin/php-cgi also is happy to interpret php files i pass on to it in the terminal, so it must be misscommunication tween the two...

following the suggestions in user guide to use apache's Action directive to handle php scripts i run into "404 Not Found" by requesting index.php from DocumentRoot

apache's error_log contains:
[actions:info] [pid 5046] [client] AH00652: File does not exist: /usr/share/apache2/htdocs/usr/bin/php-cgi/index.php

which is bizarre, I expect Action to run php interpreter with index.php as parameter, instead judging from the error it mangles a request path as follows:
requested_page_path / path_to_php_interpreter / requested_page_filename

what am I missing? here's my apache2.config:

ServerRoot "/usr"


Listen 81

LoadModule mpm_prefork_module lib/apache2/
LoadModule authn_file_module lib/apache2/
LoadModule authn_core_module lib/apache2/
LoadModule authz_host_module lib/apache2/
LoadModule authz_groupfile_module lib/apache2/
LoadModule authz_user_module lib/apache2/
LoadModule authz_core_module lib/apache2/
LoadModule access_compat_module lib/apache2/
LoadModule auth_basic_module lib/apache2/
LoadModule reqtimeout_module lib/apache2/
LoadModule filter_module lib/apache2/
LoadModule mime_module lib/apache2/
LoadModule log_config_module lib/apache2/
LoadModule env_module lib/apache2/
LoadModule headers_module lib/apache2/
LoadModule setenvif_module lib/apache2/
LoadModule version_module lib/apache2/
LoadModule unixd_module lib/apache2/
LoadModule status_module lib/apache2/
LoadModule autoindex_module lib/apache2/

<IfModule !mpm_prefork_module>

	#LoadModule cgid_module lib/apache2/


<IfModule mpm_prefork_module>

	#LoadModule cgi_module lib/apache2/


LoadModule dir_module lib/apache2/

LoadModule actions_module lib/apache2/

LoadModule alias_module lib/apache2/

<IfModule unixd_module>

	User apache
	Group apache



<Directory />

	AllowOverride none
	Require all denied


DocumentRoot "/usr/share/apache2/htdocs"

<Directory "/usr/share/apache2/htdocs">

	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted

	<FilesMatch \.phps$>

		SetHandler application/x-httpd-php



<IfModule dir_module>

	DirectoryIndex index.html


<Files ".ht*">

	Require all denied


ErrorLog "/var/log/apache2/error_log"
LogLevel debug

<IfModule log_config_module>

	LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
	LogFormat "%h %l %u %t \"%r\" %>s %b" common

	<IfModule logio_module>

		LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

	CustomLog "/var/log/apache2/access_log" common


<IfModule alias_module>

	ScriptAlias /cgi-bin/ "/usr/share/apache2/cgi-bin/"

<IfModule cgid_module>

	#Scriptsock cgisock

<Directory "/usr/share/apache2/cgi-bin">

	AllowOverride None
	Options None
	Require all granted

<Directory "/usr/bin">

	AllowOverride None
	Options None
	Require all granted


<IfModule headers_module>

	RequestHeader unset Proxy early

<IfModule mime_module>

	TypesConfig /etc/apache2/mime.types
	AddType application/x-compress .Z
	AddType application/x-gzip .gz .tgz

	AddType application/x-httpd-php .php

<IfModule proxy_html_module>

	Include /etc/apache2/extra/proxy-html.conf

<IfModule ssl_module>

	SSLRandomSeed startup builtin
	SSLRandomSeed connect builtin

Action application/x-httpd-php /usr/bin/php-cgi


1 Like


Did you find a solution to the problem?
I have exatly same problem.
My config is working on 14.07 since 2014.
On 19.07.03 all available external php call method not working, and generate same error, however all method working on 14.07.


the "new" / current apache has no php module afaik

Just to avoid misunderstanding. The "old" apache did not provide a php module neither. The module is provided by PHP itself (but until now the module is not packaged for OpenWrt).

1 Like

Is there a solution,because Ihave the same problem.

Please help.



Can anyone please answer this, I am also having the exact same problems, I have re-install serveral times, different router Dlink 835 and Cisco EA3500 but same results, 404 Not Found, I have followed all the instructions here, installed all the packages everything checks, please please someone help me!! Thank you.

not packaged

1 Like

Sorry I miss-understood that, so just to be clear, the PHP package does not exist for apache2, does it exist for nginx or lighttpd?

1 Like

Im using nginx+php-fcgi

1 Like

Hi all,
I've got the same error, following the instructions in the wiki:

AH00130: File does not exist: /usr/bin/php-cgi/index.php

My solution: enable cgi module in /etc/apache2/apache2.conf, which is not enabled by default

LoadModule cgi_module lib/apache2/