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개:

추천 게시물

php 로 챗GPT api 사용방법. 라이브러리 그딴거 없이 누구나 쉽게

진짜 최고로 간단하게 만들어 봤습니다. 나의 php소스코드 윗부분에 다음의 함수를 붙여넣는다.  API키만 내가 받은걸로 넣기. function fnGPTComment ( $memo ) {       $api_key = '나의 API키...