2018년 11월 11일

CentOS7 apache 에서 .htm .html 파일에서 php 코드 실행하기

일단 경로를 보자면
/etc/httpd/conf/httpd.conf
에 AddType 관련한 설정을 찾아봤는데 php관련 설정은 안보인다.
/etc/httpd/conf.d/php.conf
라고해서 php관련한 설정을 이 파일에 따로 하는것을 알수있었다..
내용이 얼마 안되니까 풀코드를 써보겠다.
아래 부분중 붉은 색부분이 추가된 내용이다.(코드뷰가 색깔을 지가 맘대로 지정해서 붉은색 시가 잘 안난다. 그래서 글자를 키웠다. 큰 글씨가 추가된 부분임.
#
# Allow php to handle Multiviews
#
AddType text/html .php .html .htm

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

# mod_php options
<IfModule  mod_php7.c>
    #
    # Cause the PHP interpreter to handle files with a .php extension.
    #
    <FilesMatch \.(php|phar|htm|html)$>
        SetHandler application/x-httpd-php
    </FilesMatch>

    #
    # Uncomment the following lines to allow PHP to pretty-print .phps
    # files as PHP source code:
    #
    #<FilesMatch \.phps$>
    #    SetHandler application/x-httpd-php-source
    #</FilesMatch>

    #
    # Apache specific PHP configuration options
    # those can be override in each configured vhost
    #
    php_value session.save_handler "files"
    php_value session.save_path    "/var/lib/php/session"
    php_value soap.wsdl_cache_dir  "/var/lib/php/wsdlcache"

    #php_value opcache.file_cache   "/var/lib/php/opcache"
</IfModule>
변경된 설정을 저장하고 아파치 재시작 해주면 끝
systemctl restart httpd

댓글 1개:

추천 게시물

[모닝갤러리] Alex Katz (1927 ~ )

대담한 단순함과 강렬한 색상이 특징인 '알렉스 카츠'의 그림은 대부분이 폭 3~4m가 되는 커다란 작품들입니다. 1960년대 초 영화와 TV, 빌보드 광고 등의 영향을 받아, 과감한 클로즈업과 대담하게 잘려진 구성으로 작업을 하죠. 아내...