메뉴 건너뛰기

XEDITION

project2018

html 문서에서 php 코드가 실행이 안될 때

proin 2018.05.29 12:16 조회 수 : 3

http://www.happyjung.com/lecture/2482?sca=PHP


html 확장자 파일에서 php 코드가 실행이 안될 때가 있습니다.
이런 경우에는  phpinfo() 도 먹히질 않습니다. php 설치의 문제가 아니라 세팅의 문제일 수 있기 때문입니다.


1. php.ini 에서 short_open_tag=Off 를 On으로 변경 합니다. 
[root@localhost ~]# vi /etc/php.ini
short_open_tag = On


2.  httpd.conf 파일에서 AddType application/x-httpd-php 를 찾습니다.
AddType application/x-httpd-php 라는 내용이 없다면 추가합니다.

[root@localhost ~]# vi /etc/httpd/conf/httpd.conf

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

를 아래와 같이 내용 추가

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php4 .php .phtml .ph .inc .html .htm


3. 아파치 재시작
[root@localhost ~]# systemctl restart httpd


참고자료
http://idchowto.com/?p=30828 

 

위로