How to run PHP sctipt from subfolder

Greetings,

Im really a beginner user. I installed fresh HestiaCP VPS (Vultr) on Ubuntu 22.04 (NGINX, php-fpm).

I left all settings to default and uplaoded my PHP script to public_html directory and the script executes correctly by opening https://<domain.tld> in a web browser.

But if I add a subdirectory under public_html/newfolder/ and put my PHP script there I cannot execute it by opening https://<domain.tld>/newfolder
I get HTTP Error 500 in web browser.

I guess it has something to do with NGINX configuration but would appriciate any help to fix that or reconfigure HestiaCP in order to run PHP scripts in subdirectories.

Please help.

check your error log, in special why you get a 500 internal

Can you asssit me find that log?

thank you for the link.

Here is the output (IP is obfuscated):

XXX.XXX.XXX.XXX - - [26/Aug/2023:15:59:43 +0000] “GET /contact/ HTTP/2.0” 500 0 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36”

XXX.XXX.XXX.XXX - - [26/Aug/2023:15:59:46 +0000] “GET / HTTP/2.0” 200 24696 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36”

… but it doesnt tell me any more then I previously knew.

You shared your webserver log. You may want to review your PHP log.

2023/08/26 15:59:43 [error] 8384#8384: *139 FastCGI sent in stderr: “PHP message: PHP Parse error: syntax error, unexpected identifier “version” in /home/admin/web/domain.com/public_html/contact/main.html on line 96” while reading response header from upstream, client: 94.253.205.119, server: domain.com, request: “GET /contact/ HTTP/2.0”, upstream: “fastcgi://unix:/run/php/php8.2-fpm-domain.com.sock:”, host: “domain.com

You need to checkk your php code …

Hard to guess what is wrong…

OK It executes PHP, which is pretty simple.
PHP calls main.html file from the same folder. main.html is very simple html file. This same PHP script works like a charm on pure Apache+PHP setup.

<?php include "main.html"; ?>

Error is on line 96 in main.html

But I don’t have server access so I can’t debug it … But it is a syntax error. Nothing to do with Hestia…

Seems like I figured it. Default server PHP include path is set to: .:/usr/share/php

On clean Apache install it was the same as php file.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.