LAMP Production Ready PHP not running on htdocs folder

Keywords: LAMP/MAMP/WAMP - AWS - Technical issue - Other
bnsupport ID: 8c2f8a01-d972-052e-4455-b67d0f3a7a7e
Description:
I just created a new ready to production environment from the AWS Marketplace with the license https://aws.amazon.com/marketplace/pp/B07TDQQ5KT

All works fine in the Cloud Formation stack, the services run successfully and the SSH connection works great.

  • I deployed my Laravel app in the htdocs due I don’t want to have more applications on this environment.
  • Then I modified the following conf files:
    /opt/bitnami/apache/conf/bitnami/bitnami.conf
    /opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf
  • I made 2 changes in those files:
    • Added this to the Virtual Host DirectoryIndex index.php
    • Changed the document root to /opt/bitnami/apache2/htdocs/public
  • I restarted the services.

Now the web server point to the right folder, but PHP is not running. The web show me the main php file as a plain text.

I executed the Bitnami Support tool getting the next code: 8c2f8a01-d972-052e-4455-b67d0f3a7a7e

The PHP runs ok on the CLI with the 7.4.16 version, but not in the Apache Web Server

Hello @dualklip,

I was not able to reproduce your issue. These are the steps I followed in a clean installation:

  • Change DocumentRoot and Directory in /opt/bitnami/apache/conf/bitnami/bitnami.conf and /opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf files as you suggested.
  • Restart apache
  • Create /opt/bitnami/apache2/htdocs/public and /opt/bitnami/apache2/htdocs/public/index.php file with the following content:
<?php
phpinfo();
  • Access my IP and check that PHP info is properly shown.

Some information is missing in the support tool output, and I cannot reach your IP. Did you check if php-fpm is running?

Regards

Hi @davidg,

Thank you for support me on this issue let me share more info with you in order to clarify what is my setup and know if we have something different:

My solutions is this one, which have the web server behind a bastion instance. I’m wonder if that could be the reason why you can’t reach my IP. I can share that info with you by PM:
https://docs.bitnami.com/aws-templates/infrastructure/lamp-production-ready/administration/deploy-php-application/

My /opt/bitnami/apache2/conf/bitnami/bitnami.conf

# Default Virtual Host configuration.

# Let Apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on

<VirtualHost _default_:80>
  DocumentRoot "/opt/bitnami/apache/htdocs/public"
  DirectoryIndex index.php
  <Directory "/opt/bitnami/apache/htdocs/public">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>

  # Error Documents
  ErrorDocument 503 /503.html
</VirtualHost>

Include "/opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf"

My /opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf

# Default SSL Virtual Host configuration.

<IfModule !ssl_module>
  LoadModule ssl_module modules/mod_ssl.so
</IfModule>

Listen 443
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !EDH !RC4"
SSLPassPhraseDialog  builtin
SSLSessionCache "shmcb:/opt/bitnami/apache/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

<VirtualHost _default_:443>
  DocumentRoot "/opt/bitnami/apache/htdocs/public"
  SSLEngine on
  SSLCertificateFile "/opt/bitnami/apache/conf/bitnami/certs/server.crt"
  SSLCertificateKeyFile "/opt/bitnami/apache/conf/bitnami/certs/server.key"

  <Directory "/opt/bitnami/apache/htdocs/public">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>

  # Error Documents
  ErrorDocument 503 /503.html
</VirtualHost>

When I run sudo service bitnami status

 bitnami.service - LSB: Bitnami Init Script
   Loaded: loaded (/etc/init.d/bitnami; generated)
   Active: active (running) since Tue 2021-04-27 13:17:46 UTC; 1min 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 5823 ExecStart=/etc/init.d/bitnami start (code=exited, status=0/SUCCESS)
    Tasks: 35 (limit: 2373)
   Memory: 122.0M
   CGroup: /system.slice/bitnami.service
           β”œβ”€ 763 /opt/bitnami/gonit/bin/gonit
           β”œβ”€5838 php-fpm: master process (/opt/bitnami/php/etc/php-fpm.conf)
           β”œβ”€5842 php-fpm: pool www
           β”œβ”€5843 php-fpm: pool www
           β”œβ”€5844 php-fpm: pool www
           β”œβ”€5845 php-fpm: pool www
           β”œβ”€5846 php-fpm: pool www
           β”œβ”€5847 php-fpm: pool www
           β”œβ”€5848 php-fpm: pool www
           β”œβ”€5849 php-fpm: pool www
           β”œβ”€5850 php-fpm: pool www
           β”œβ”€5851 php-fpm: pool www
           β”œβ”€5852 php-fpm: pool www
           β”œβ”€5853 php-fpm: pool www
           β”œβ”€5854 php-fpm: pool www
           β”œβ”€5855 php-fpm: pool www
           β”œβ”€5856 php-fpm: pool www
           β”œβ”€5857 php-fpm: pool www
           β”œβ”€5858 php-fpm: pool www
           β”œβ”€5859 php-fpm: pool www
           β”œβ”€5860 php-fpm: pool www
           β”œβ”€5861 php-fpm: pool www
           β”œβ”€5874 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf
           β”œβ”€5876 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf
           β”œβ”€5877 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf
           β”œβ”€5878 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf
           β”œβ”€5879 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf
           β”œβ”€5880 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf
           └─5901 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf

Apr 27 13:17:37 ip-10-0-32-168 systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Apr 27 13:17:37 ip-10-0-32-168 systemd[1]: Starting LSB: Bitnami Init Script...
Apr 27 13:17:38 ip-10-0-32-168 bitnami[5823]: 2021-04-27T13:17:38.576Z - info: Saving configuration info to disk
Apr 27 13:17:38 ip-10-0-32-168 bitnami[5823]: 2021-04-27T13:17:38.799Z - info: Performing service start operation for php
Apr 27 13:17:43 ip-10-0-32-168 bitnami[5823]: php 13:17:43.97 INFO  ==> php-fpm started
Apr 27 13:17:43 ip-10-0-32-168 bitnami[5823]: 2021-04-27T13:17:43.972Z - info: Performing service start operation for apache
Apr 27 13:17:44 ip-10-0-32-168 bitnami[5823]: apache 13:17:44.22 INFO  ==> apache started
Apr 27 13:17:44 ip-10-0-32-168 bitnami[5823]: 2021-04-27T13:17:44.433Z - info: Starting gonit monitoring service
Apr 27 13:17:46 ip-10-0-32-168 bitnami[5823]: 2021-04-27T13:17:46.444Z - info: Start monitoring all services from gonit
Apr 27 13:17:46 ip-10-0-32-168 systemd[1]: Started LSB: Bitnami Init Script.

Whe I do ls -la /opt/bitnami/apache2/htdocs/

total 452
drwxr-xr-x  15 bitnami bitnami   4096 Apr 26 10:29 .
drwxr-xr-x  17 root    root      4096 Mar  4 12:25 ..
drwxr-xr-x  10 bitnami bitnami   4096 Apr 26 06:59 app
-rw-r--r--   1 bitnami bitnami   1686 Apr 26 09:58 artisan
drwxr-xr-x   3 bitnami bitnami   4096 Apr 26 09:58 bootstrap
-rw-r--r--   1 bitnami bitnami   3511 Apr 26 09:58 composer.json
-rw-r--r--   1 bitnami bitnami 347093 Apr 26 09:58 composer.lock
drwxr-xr-x   2 bitnami bitnami   4096 Apr 26 09:58 config
drwxr-xr-x   5 bitnami bitnami   4096 Apr 26 06:59 database
-rw-r--r--   1 bitnami bitnami   1778 Apr 26 09:58 .env
-rw-r--r--   1 bitnami bitnami   4688 Apr 14 21:55 index.html
drwxr-xr-x  10 bitnami bitnami   4096 Apr 26 09:58 laravel-nova
drwxr-xr-x 701 bitnami bitnami  20480 Apr 26 09:59 node_modules
drwxr-xr-x  10 bitnami bitnami   4096 Apr 26 06:59 nova-components
-rw-r--r--   1 bitnami bitnami    122 Apr 26 09:58 .npmrc
drwxr-xr-x   7 bitnami bitnami   4096 Apr 26 10:29 public
drwxr-xr-x   7 bitnami bitnami   4096 Apr 26 06:59 resources
drwxr-xr-x   2 bitnami bitnami   4096 Apr 26 09:59 routes
-rw-r--r--   1 bitnami bitnami    563 Apr 26 09:58 server.php
drwxrwxr-x   5 bitnami bitnami   4096 Apr 26 06:59 storage
-rw-r--r--   1 bitnami bitnami    573 Apr 26 09:58 tailwind.config.js
drwxr-xr-x   4 bitnami bitnami   4096 Apr 26 09:59 tests
drwxr-xr-x  55 bitnami bitnami   4096 Apr 26 09:59 vendor
-rw-r--r--   1 bitnami bitnami    689 Apr 26 09:58 webpack.mix.js

and public folder ls -la /opt/bitnami/apache2/htdocs/public/

total 52
drwxr-xr-x  7 bitnami bitnami 4096 Apr 26 10:29 .
drwxr-xr-x 15 bitnami bitnami 4096 Apr 26 10:29 ..
drwxr-xr-x  2 bitnami bitnami 4096 Apr 26 09:59 css
-rw-r--r--  1 bitnami bitnami    0 Apr 26 09:59 favicon.ico
drwxr-xr-x  3 bitnami bitnami 4096 Apr 26 06:59 fonts
-rw-r--r--  1 bitnami bitnami  603 Apr 26 09:59 .htaccess
drwxr-xr-x  2 bitnami bitnami 4096 Apr 26 09:59 images
-rw-r--r--  1 bitnami bitnami 1735 Apr 26 09:59 index.php
-rw-r--r--  1 bitnami bitnami   20 Apr 26 10:29 info.php
drwxr-xr-x  2 bitnami bitnami 4096 Apr 26 09:59 js
-rw-r--r--  1 bitnami bitnami   71 Apr 26 09:59 mix-manifest.json
-rw-r--r--  1 bitnami bitnami   24 Apr 26 09:59 robots.txt
drwxr-xr-x  3 bitnami bitnami 4096 Apr 26 06:59 vendor
-rw-r--r--  1 bitnami bitnami 1183 Apr 26 09:59 web.config

The server can be checked in:
https://sukyandaru.com/
or
https://sukyandaru.com/info.php

Hello @dualklip,

I was able to reproduce the issue. It seems there are some differences between our PR and our single VM (where it works fine) apache configurations. I will forward it to the engineering team so they can fix it and provide you with a workaround.

Regards

1 Like

In the meantime I created another stack, but this time I’m not deploy a Laravel, only created a new file with the code <?php phpinfo(); ?>, this new stack neither work

https://mlexperience.es/info.php

Hi @dualklip,

I was checking your data in the bnsupport and in your logs of apache appears an error:

[Mon Apr 26 09:19:25.503314 2021] [autoindex:error] [pid 14675] [client 10.0.148.62:61202] AH01276: Cannot serve directory /opt/bitnami/apache/htdocs/public/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
[Mon Apr 26 09:19:36.792609 2021] [autoindex:error] [pid 14764] [client 10.0.135.37:6476] AH01276: Cannot serve directory /opt/bitnami/apache/htdocs/public/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

Could you try adding to opt/bitnami/apache2/conf/bitnami/bitnami.conf index.html?

. . .
DirectoryIndex index.html index.php
. . .

after that, you need to restart apache.

Hi @Ibone,

Thank you for support me on this issue. I tried your solution (including Β΄sudo service bitnami restartΒ΄) but no success.

In order to refresh that log you mention I created a new support bundle with the number ff52b31c-a178-3f2c-4bef-fd6265c763b7.

the bitnami.conf file after your comment:

# Default Virtual Host configuration.

# Let Apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on

<VirtualHost _default_:80>
  DocumentRoot "/opt/bitnami/apache/htdocs/public"
  DirectoryIndex index.html index.php
  <Directory "/opt/bitnami/apache/htdocs/public">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>

  # Error Documents
  ErrorDocument 503 /503.html
</VirtualHost>

Include "/opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf"

Hi @dualklip,

I have a question if you left the default configuration of apache and if you create the file info.php (https://sukyandaru.com/info.php) in htdocs, does it work?

Thanks,
Ibone

Hi @Ibone,

no, It doesn’t work. I have another stack created from the scratch with other domain. The only difference is a file called info.php is on the htdocs folder:
https://mlexperience.es/info.php

Hi @dualklip,

We have been able to reproduce it, I’m going to create an internal task to fix this bug. We will update the thread when we have more information.
Thanks for reporting!

1 Like