# html확장자에서 PHP 코드 실행이 안됩니다. (Ubuntu 22.04 + Apache2 + PHP7.4)

**URL:** <https://discourse.ubuntu-kr.org/t/html-php-ubuntu-22-04-apache2-php7-4/49443>\
**Category:** 자유 게시판\
**Tags:** 질문\
**Created:** [4월 6, 2024, 2:59오전 UTC](https://discourse.ubuntu-kr.org/t/html-php-ubuntu-22-04-apache2-php7-4/49443 "2024-04-06T02:59:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hunter2go](https://discourse.ubuntu-kr.org/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hunter2go](https://discourse.ubuntu-kr.org/u/hunter2go)\
**Post date:** [4월 6, 2024, 2:59오전 UTC](https://discourse.ubuntu-kr.org/t/html-php-ubuntu-22-04-apache2-php7-4/49443/1 "2024-04-06T02:59:39Z")

</div>

Ubuntu 22.04 + Apache2 + PHP7.4를 설치했습니다.  
(설치할때 [https://hoing.io/archives/7367#comment-3499](https://hoing.io/archives/7367#comment-3499) 를 참고했습니다)

/var/www/html/phpinfo.html 과 /var/www/html/phpinfo.php 각각 파일을 만들었고,  
브라우저에서 엑세스 했을때 확장자 html은 PHP코드를 인식하지 않습니다.  
(크롬에서는 phpinfo.html 파일이 다운로드 되고, 엣지에서는 아무것도 없는 흰화면인데 소스보기를 하면 PHP 코드가 보입니다)

/etc/apache2/mods-enabled/mime.conf 파일  
/etc/apache2/apache2.conf 파일  
/etc/apache2/sites-enabled/000-default.conf 파일에  
각각 AddType application/x-httpd-php .html .php 추가해 보아도 동일 증상입니다.

혹시 어떤 파일에 어떤 내용을 추가해야 하는지 알려주실 수 있을까요?

---

<div class="post-metadata">

**Author:** ![hunter2go](https://discourse.ubuntu-kr.org/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hunter2go](https://discourse.ubuntu-kr.org/u/hunter2go)\
**Post date:** [4월 6, 2024, 11:15오전 UTC](https://discourse.ubuntu-kr.org/t/html-php-ubuntu-22-04-apache2-php7-4/49443/2 "2024-04-06T11:15:53Z")

</div>

아래와 같이 설정해서 해결했습니다.

1. /etc/apache2/apache2.conf 파일에 AddType 추가해도 작동 안됨

2. /etc/apache2/conf-available/php7.4-fpm.conf 파일에 아래 코드 추가

\<FilesMatch “.+.(html|php)$”\>  
SetHandler “proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost”

1. /etc/php-fpm.d/www.conf 파일에 아래 항목 주석 제거후 .html 추가

security.limit\_extensions = .php .php3 .php4 .php5 .html

2, 3번 설정후 재시작 하니 .html 파일에서 PHP가 잘 작동하고 있습니다.
