Apache2 + php7

hello,
I installed apache 2 and php7, but I can't get php7 to work on apache.
Apache is working, because when I access ip 192.168.1.1:81 it returns me It works !, when I access 192.168.1.1:81/index.php it returns me

<? php phpinfo (); ?>,

already looked for some tutorial but nothing. Someone can help me

@trendy can you help me
@slh can you help me

root@OpenWrt:~# opkg list-installed
apache - 2.4.41-1
bandwidthd-php - 2.0.1-35-2
base-files - 204.2-r10947-65030d81f3
bnx2-firmware - 20190416-1
busybox - 1.30.1-5
ca-bundle - 20190110-2
cgi-io - 19
dnsmasq - 2.80-16
dropbear - 2019.78-2
e2fsprogs - 1.44.5-2
firewall - 2019-11-22-8174814a-1
fstools - 2020-01-18-189b41b6-1
fwtool - 2
getrandom - 2019-06-16-4df34a4d-3
icu - 66.1-1
ip6tables - 1.8.3-1
iptables - 1.8.3-1
jshn - 2020-02-27-7da66430-1
jsonfilter - 2018-02-04-c7e938d6-1
kernel - 4.14.171-1-e1dd7676581672f6f0bdb1363506dee1
kmod-bnx2 - 4.14.171-1
kmod-button-hotplug - 4.14.171-3
kmod-e1000 - 4.14.171-1
kmod-e1000e - 4.14.171-1
kmod-hwmon-core - 4.14.171-1
kmod-i2c-algo-bit - 4.14.171-1
kmod-i2c-core - 4.14.171-1
kmod-igb - 4.14.171-1
kmod-input-core - 4.14.171-1
kmod-ip6tables - 4.14.171-1
kmod-ipt-conntrack - 4.14.171-1
kmod-ipt-core - 4.14.171-1
kmod-ipt-nat - 4.14.171-1
kmod-ipt-offload - 4.14.171-1
kmod-lib-crc-ccitt - 4.14.171-1
kmod-mii - 4.14.171-1
kmod-nf-conntrack - 4.14.171-1
kmod-nf-conntrack6 - 4.14.171-1
kmod-nf-flow - 4.14.171-1
kmod-nf-ipt - 4.14.171-1
kmod-nf-ipt6 - 4.14.171-1
kmod-nf-nat - 4.14.171-1
kmod-nf-reject - 4.14.171-1
kmod-nf-reject6 - 4.14.171-1
kmod-ppp - 4.14.171-1
kmod-pppoe - 4.14.171-1
kmod-pppox - 4.14.171-1
kmod-pps - 4.14.171-1
kmod-ptp - 4.14.171-1
kmod-r8169 - 4.14.171-1
kmod-slhc - 4.14.171-1
krb5-libs - 1.17-2
libapr - 1.7.0-1
libaprutil - 1.6.1-2
libblkid1 - 2.34-1
libblobmsg-json - 2020-02-27-7da66430-1
libc - 1.1.24-2
libcomerr0 - 1.44.5-2
libcurl4 - 7.66.0-1
libevent2-7 - 2.1.11-1
libexpat - 2.2.7-1
libext2fs2 - 1.44.5-2
libf2fs6 - 1.12.0-3
libfreetype - 2.10.0-1
libgcc1 - 7.5.0-2
libgmp10 - 6.1.2-2
libidn - 1.35-2
libidn2 - 2.0.5-1
libintl-full8 - 0.19.8.1-2
libip4tc2 - 1.8.3-1
libip6tc2 - 1.8.3-1
libiwinfo-lua - 2019-10-16-07315b6f-1
libiwinfo20181126 - 2019-10-16-07315b6f-1
libjpeg - 9c-2
libjson-c2 - 0.12.1-3
libjson-script - 2020-02-27-7da66430-1
libltdl7 - 2.4.6-2
liblua5.1.5 - 5.1.5-3
liblucihttp-lua - 2019-07-05-a34a17d5-1
liblucihttp0 - 2019-07-05-a34a17d5-1
libmbedtls12 - 2.16.4-1
libmcrypt - 2.5.8-2
libncurses6 - 6.1-5
libnetsnmp - 5.8-1
libnl-tiny - 0.1-5
libopenldap - 2.4.48-1
libopenssl1.1 - 1.1.1e-2
libpam - 1.3.1-1
libpci - 3.6.2-3
libpcre - 8.43-1
libpng - 1.6.37-2
libpq - 11.3-1
libpthread - 1.1.24-2
librt - 1.1.24-2
libsasl2 - 2.1.27-1
libsmartcols1 - 2.34-1
libsqlite3-0 - 3310100-1
libss2 - 1.44.5-2
libstdcpp6 - 7.5.0-2
libubox20191228 - 2020-02-27-7da66430-1
libubus-lua - 2019-12-27-041c9d1c-1
libubus20191227 - 2019-12-27-041c9d1c-1
libuci20130104 - 2019-09-01-415f9e48-3
libuclient20160123 - 2019-05-30-3b3e368d-1
libunistring - 0.9.10-1
libuuid1 - 2.34-1
libxml2 - 2.9.9-2
libxtables12 - 1.8.3-1
logd - 2019-06-16-4df34a4d-3
lua - 5.1.5-3
luci - git-20.089.25318-f89efcf-1
luci-app-firewall - git-20.089.25318-f89efcf-1
luci-app-opkg - git-20.089.25318-f89efcf-1
luci-base - git-20.089.25318-f89efcf-1
luci-lib-ip - git-20.089.25318-f89efcf-1
luci-lib-jsonc - git-20.089.25318-f89efcf-1
luci-lib-nixio - git-20.089.25318-f89efcf-1
luci-mod-admin-full - git-20.089.25318-f89efcf-1
luci-mod-network - git-20.089.25318-f89efcf-1
luci-mod-status - git-20.089.25318-f89efcf-1
luci-mod-system - git-20.089.25318-f89efcf-1
luci-proto-ipv6 - git-20.089.25318-f89efcf-1
luci-proto-ppp - git-20.089.25318-f89efcf-1
luci-theme-bootstrap - git-20.089.25318-f89efcf-1
mkf2fs - 1.12.0-3
mtd - 24
netifd - 2019-08-05-5e02f944-1
odhcp6c - 2019-01-11-e199804b-16
odhcpd-ipv6only - 2019-12-16-e53fec89-3
openssh-sftp-server - 8.0p1-1
openwrt-keyring - 2019-07-25-8080ef34-1
opkg - 2020-01-25-c09fe209-1
partx-utils - 2.34-1
php7 - 7.2.28-1
php7-cgi - 7.2.28-1
php7-cli - 7.2.28-1
php7-fastcgi - 7.2.28-1
php7-fpm - 7.2.28-1
php7-mod-bcmath - 7.2.28-1
php7-mod-calendar - 7.2.28-1
php7-mod-ctype - 7.2.28-1
php7-mod-curl - 7.2.28-1
php7-mod-dom - 7.2.28-1
php7-mod-exif - 7.2.28-1
php7-mod-fileinfo - 7.2.28-1
php7-mod-ftp - 7.2.28-1
php7-mod-gd - 7.2.28-1
php7-mod-gettext - 7.2.28-1
php7-mod-gmp - 7.2.28-1
php7-mod-hash - 7.2.28-1
php7-mod-iconv - 7.2.28-1
php7-mod-imap - 7.2.28-1
php7-mod-intl - 7.2.28-1
php7-mod-json - 7.2.28-1
php7-mod-ldap - 7.2.28-1
php7-mod-mbstring - 7.2.28-1
php7-mod-mysqli - 7.2.28-1
php7-mod-mysqlnd - 7.2.28-1
php7-mod-opcache - 7.2.28-1
php7-mod-openssl - 7.2.28-1
php7-mod-pcntl - 7.2.28-1
php7-mod-pdo - 7.2.28-1
php7-mod-pdo-mysql - 7.2.28-1
php7-mod-pdo-pgsql - 7.2.28-1
php7-mod-pdo-sqlite - 7.2.28-1
php7-mod-pgsql - 7.2.28-1
php7-mod-phar - 7.2.28-1
php7-mod-session - 7.2.28-1
php7-mod-shmop - 7.2.28-1
php7-mod-simplexml - 7.2.28-1
php7-mod-snmp - 7.2.28-1
php7-mod-soap - 7.2.28-1
php7-mod-sockets - 7.2.28-1
php7-mod-sqlite3 - 7.2.28-1
php7-mod-sysvmsg - 7.2.28-1
php7-mod-sysvsem - 7.2.28-1
php7-mod-sysvshm - 7.2.28-1
php7-mod-tokenizer - 7.2.28-1
php7-mod-xml - 7.2.28-1
php7-mod-xmlreader - 7.2.28-1
php7-mod-xmlwriter - 7.2.28-1
php7-mod-zip - 7.2.28-1
php7-pecl-dio - 0.1.0-1
php7-pecl-http - 3.2.0-2
php7-pecl-krb5 - 1.1.2-1
php7-pecl-libevent - 2017-03-24-5a726cee95ef9760fe81a60e595e87655f324594-1
php7-pecl-mcrypt - 1.0.2-1
php7-pecl-propro - 2.1.0-1
php7-pecl-raphf - 2.0.0-2
php7-pecl-redis - 4.3.0-1
ppp - 2.4.7.git-2019-05-25-3
ppp-mod-pppoe - 2.4.7.git-2019-05-25-3
procd - 2020-03-07-09b9bd82-1
r8169-firmware - 20190416-1
rpcd - 2019-12-10-aaa08366-2
rpcd-mod-file - 2019-12-10-aaa08366-2
rpcd-mod-iwinfo - 2019-12-10-aaa08366-2
rpcd-mod-luci - 20191114
rpcd-mod-rrdns - 20170710
terminfo - 6.1-5
ubox - 2019-06-16-4df34a4d-3
ubus - 2019-12-27-041c9d1c-1
ubusd - 2019-12-27-041c9d1c-1
uci - 2019-09-01-415f9e48-3
uclient-fetch - 2019-05-30-3b3e368d-1
uhttpd - 2020-02-12-2ee323c0-1
urandom-seed - 1.0-1
urngd - 2020-01-21-c7f7b6b6-1
usign - 2019-08-06-5a52b379-1
uw-imap - 2007f-3
zlib - 1.2.11-3
zoneinfo-core - 2019b-1

Hi there!

Never used php myself. But it seems to me that OpenWrt php packages do not include mod_php. So you would need to figure out a way to make this work differently.

Maybe look at this link. It's a bit older (2013 or so). It suggests to use the actions module. The OpenWrt apache package installs /usr/lib/apache2/mod_actions.so. So maybe this is a way to get php going.

Best of luck!

Ola @micmac1

AH00526: Syntax error on line 369 of /etc/apache2/apache2.conf:
Invalid command 'Action', perhaps misspelled or defined by a module not included in the server configuration

Try uncommenting the module loading for the actions module. Read some documentation. You can figure this out.

Sorry @tv4you2016 but I haven't installed apache or php in OpenWrt.

Does the same happen when you do it correctly, i.e.

<?php phpinfo(); ?>

instead of

<? php phpinfo (); ?>

(mind the tiny difference)

yes @tmomas.
My apache2.conf
https://pastebin.com/UMTJsEbs
My php.ini
https://pastebin.com/4s6uHgRN

@micmac1 Sorry, you could be more precise, and I don't find great info about it

In your /etc/apache2/apache2.conf that you pasted yesterday you had
this:

#LoadModule actions_module lib/apache2/mod_actions.so

Uncomment this line (remove the '#') so that apache2 loads the module
so that you have access to the module's commands/features.

1 Like

@micmac1, the error was solved but now this appears when I try to access index.php:

Forbidden

You don't have permission to access this resource.

Do what needs doing. Check the documentation, check the logs. Can't expect me to do it for you :rofl:

Anything usefull in apaches error log?

hi @tmomas

New apache 2
https://pastebin.com/wLQ2iHRj

New php ini
https://pastebin.com/raw/t8S8WkTx

Acesslog
192.168.1.83 - - [02/Apr/2020:20:04:21 +0000] "GET / HTTP/1.1" 403 199
192.168.1.83 - - [02/Apr/2020:20:04:25 +0000] "GET /index.php HTTP/1.1" 403 199
192.168.1.83 - - [02/Apr/2020:20:07:55 +0000] "GET /index.php HTTP/1.1" 403 199
192.168.1.83 - - [02/Apr/2020:20:07:56 +0000] "GET /index.php HTTP/1.1" 403 199
192.168.1.83 - - [02/Apr/2020:20:07:57 +0000] "GET /favicon.ico HTTP/1.1" 404 196
192.168.1.83 - - [02/Apr/2020:20:07:57 +0000] "GET /index.php HTTP/1.1" 403 199
192.168.1.83 - - [02/Apr/2020:20:07:57 +0000] "GET /favicon.ico HTTP/1.1" 404 196
192.168.1.83 - - [02/Apr/2020:20:07:57 +0000] "GET /index.php HTTP/1.1" 403 199
192.168.1.83 - - [02/Apr/2020:20:07:57 +0000] "GET /favicon.ico HTTP/1.1" 404 196

errorlog

[Thu Apr 02 20:04:18.413685 2020] [mpm_prefork:notice] [pid 1721] AH00163: Apache/2.4.41 (Unix) configured -- resuming normal operations
[Thu Apr 02 20:04:18.413699 2020] [core:notice] [pid 1721] AH00094: Command line: '/usr/sbin/apache2'
[Thu Apr 02 20:04:21.751639 2020] [access_compat:error] [pid 4508] [client 192.168.1.83:56897] AH01797: client denied by server configuration: /usr/bin/php-cgi
[Thu Apr 02 20:04:25.616239 2020] [access_compat:error] [pid 4508] [client 192.168.1.83:56897] AH01797: client denied by server configuration: /usr/bin/php-cgi
[Thu Apr 02 20:07:52.760251 2020] [mpm_prefork:notice] [pid 1721] AH00173: SIGHUP received. Attempting to restart
[Thu Apr 02 20:07:52.766160 2020] [mpm_prefork:notice] [pid 1721] AH00163: Apache/2.4.41 (Unix) configured -- resuming normal operations
[Thu Apr 02 20:07:52.766173 2020] [core:notice] [pid 1721] AH00094: Command line: '/usr/sbin/apache2'
[Thu Apr 02 20:07:55.178782 2020] [access_compat:error] [pid 4954] [client 192.168.1.83:56906] AH01797: client denied by server configuration: /usr/bin/php-cgi
[Thu Apr 02 20:07:56.984096 2020] [access_compat:error] [pid 4954] [client 192.168.1.83:56906] AH01797: client denied by server configuration: /usr/bin/php-cgi
[Thu Apr 02 20:07:57.279114 2020] [access_compat:error] [pid 4954] [client 192.168.1.83:56906] AH01797: client denied by server configuration: /usr/bin/php-cgi
[Thu Apr 02 20:07:57.460289 2020] [access_compat:error] [pid 4954] [client 192.168.1.83:56906] AH01797: client denied by server configuration: /usr/bin/php-cgi

I do not understand the reason for the error, because in the apache file I am giving you permission

**Sem Título

I have a project in mind for short that needs php

i has the same problem! do you resolve it ?

thanks

1 Like

Yes I decided, instead of using apache I used nginx.
none of the above answers helped me or I was able to find where I got the error

Edit the below file ( with whatever means Eg. WinSCP, PuTTy + nano):

/etc/apache2/apache2.conf

Find the line below & UNCOMMENT (Remove comment):

#LoadModule actions_module lib/apache2/mod_actions.so

Is it possible to use apache + php7 ?? I have apache installed and php7 also does not work with php, I have the file phpinfo.php and does not run php, does is download the file

This doesn't seem to be OpenWrt specific.
Please use the search engine of your choice to search the web for answers.

Some inspiration:

If your browser prompts you to download php.info instead of executing it, then something is wrong: