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 192.168.1.241:38550] 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"

ServerName 192.168.1.187

Listen 81

LoadModule mpm_prefork_module lib/apache2/mod_mpm_prefork.so
LoadModule authn_file_module lib/apache2/mod_authn_file.so
LoadModule authn_core_module lib/apache2/mod_authn_core.so
LoadModule authz_host_module lib/apache2/mod_authz_host.so
LoadModule authz_groupfile_module lib/apache2/mod_authz_groupfile.so
LoadModule authz_user_module lib/apache2/mod_authz_user.so
LoadModule authz_core_module lib/apache2/mod_authz_core.so
LoadModule access_compat_module lib/apache2/mod_access_compat.so
LoadModule auth_basic_module lib/apache2/mod_auth_basic.so
LoadModule reqtimeout_module lib/apache2/mod_reqtimeout.so
LoadModule filter_module lib/apache2/mod_filter.so
LoadModule mime_module lib/apache2/mod_mime.so
LoadModule log_config_module lib/apache2/mod_log_config.so
LoadModule env_module lib/apache2/mod_env.so
LoadModule headers_module lib/apache2/mod_headers.so
LoadModule setenvif_module lib/apache2/mod_setenvif.so
LoadModule version_module lib/apache2/mod_version.so
LoadModule unixd_module lib/apache2/mod_unixd.so
LoadModule status_module lib/apache2/mod_status.so
LoadModule autoindex_module lib/apache2/mod_autoindex.so

<IfModule !mpm_prefork_module>

	#LoadModule cgid_module lib/apache2/mod_cgid.so

</IfModule>

<IfModule mpm_prefork_module>

	#LoadModule cgi_module lib/apache2/mod_cgi.so

</IfModule>

LoadModule dir_module lib/apache2/mod_dir.so

#+++
LoadModule actions_module lib/apache2/mod_actions.so

LoadModule alias_module lib/apache2/mod_alias.so


<IfModule unixd_module>

	User apache
	Group apache

</IfModule>


ServerAdmin you@example.com


<Directory />

	AllowOverride none
	Require all denied

</Directory>


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

	</FilesMatch>

</Directory>


<IfModule dir_module>

	DirectoryIndex index.html

</IfModule>


<Files ".ht*">

	Require all denied

</Files>


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

	</IfModule>
    
	CustomLog "/var/log/apache2/access_log" common

</IfModule>


<IfModule alias_module>

	ScriptAlias /cgi-bin/ "/usr/share/apache2/cgi-bin/"
	
</IfModule>


<IfModule cgid_module>

	#Scriptsock cgisock
	
</IfModule>


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

	AllowOverride None
	Options None
	Require all granted
	
</Directory>


<Directory "/usr/bin">

	AllowOverride None
	Options None
	Require all granted

</Directory>


<IfModule headers_module>

	RequestHeader unset Proxy early
	
</IfModule>


<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>

<IfModule proxy_html_module>

	Include /etc/apache2/extra/proxy-html.conf
	
</IfModule>

<IfModule ssl_module>

	SSLRandomSeed startup builtin
	SSLRandomSeed connect builtin
	
</IfModule>

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

Thanks!

1 Like

Hi,

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.

Thanks!

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

Hi
Is there a solution,because Ihave the same problem.

Please help.

CU

KW

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/mod_cgi.so

Felipe