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

추천 게시물

nVidia Jetson Orin Nano Developer Kit 8GB 설치 및 사용기 (AI서버)

 4일동안 삽질하다가 설치 성공 사례를 남깁니다. AI한테 물어보실봐도 모델과 현재 상황을 정확하게 인지 시켜줘야 제대로 대답을 하지 그냥 물어봐서는 저처럼 계속해서 삽질만 하게 될껍니다.   그럼 시작합니다. 사전에 알아야 할 내용 1.  JetPa...