html에서 php 실행이 안될 때 채택완료

- ubuntu 18.04

- nginx

- php 7.4.20

에서

test.html 파일에서

<table width="100%" border="1" align="center">
<?php for($i=1; $i<10; $i++) { ?>
<tr bgcolor="#ff0000">
    <td>test name</td><td>test</td>
</tr>
<?php } ?>
</table>

하면  php 코드 자체가 실행이 되지 않는데 설정에서 어디를 수정 해야 하나요?

답변 2개

채택된 답변
+20 포인트

답변에 대한 댓글 3개

감사합니다.
사이트에서 설명하는 처럼 모두 했습니다.
test.html
<div><?php echo "hello world"; ?></div>
아무것도 화면에 출력이 되지 않습니다.
test.php
<?php echo "hello world"; ?>
출력이 됩니다.
<html>
<body>
<div style="background:#4d9; padding:5px; margin:10px; ">
<?php
$color ="#F00";
$text ="빨간색";
echo "장미꽃의 색깔은 <span style='color:".$color."'>".$text."</span>입니다.";
?>
</div>
</body>
</html>

화면에 출력 결과
".$text."입니다."; ?>
이렇게 출력이 됩니다.
https://stackoverflow.com/questions/36800899/nginx-execute-embedded-php-in-html-file

https://stackoverflow.com/questions/32038568/php-code-inside-html-files-not-executed

이것도 참고해 보세요.

댓글을 작성하려면 로그인이 필요합니다.

답변에 대한 댓글 1개

답변에 감사드립니다.
저도 구글에서 검색했습니다.
아파치에 대한 방법은 있는데 php7.4와 nginx에서 방법이 없어서 문의 드립니다.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고