Souce Install PHP-FPM on CentOS 7
PHP-FPM 소스 인스톨(컴파일) 설치 가이드
PHP-FPM 은 PHP FastCGI Process Manager 의 약자입니다. PHP 를 Nginx 와 연동하기 위해서는 PHP-FPM 을 사용해야 합니다.
의존성 패키지 설치
yum install -y autoconf libtool bison libxml2-devel bzip2-devel libcurl-devel gcc-c++ openssl-devel
유저생성
useradd -M -r -s /sbin/nologin webuser
cd /data/apps/dn wget http://jp2.php.net/get/php-7.1.25.tar.gz/from/this/mirror –content-disposition
압축해제
tar xvzf php-7.1.25.tar.gz
configure
cd php-7.1.25 ./configure –prefix=/data/apps/src/php-7.1.25 –enable-fpm –with-openssl –with-zlib –enable-mysqlnd –with-config-file-path=/data/apps/ln/php/etc/
컴파일 및 설치
make && make install
링크생성
cd /data/apps/ln ln -s /data/apps/src/php-7.1.5 php
php-fpm 설정파일 생성 및 편집
: vi /data/apps/ln/php/etc/php-fpm.conf
https://github.com/fallboyz/umount.net-config/blob/master/php-fpm/php-fpm.conf
php.ini 파일 복사
cp /data/apps/dn/php-7.1.25/php.ini-production /data/apps/ln/php/etc/php.ini
php.ini 파일 편집
: vi /data/apps/ln/php/etc/php.ini (필수 편집 옵션만 나열합니다.)
expose_php = Off sys_temp_dir = /data/webtmps cgi.fix_pathinfo = 0 upload_tmp_dir = /data/webtmps date.timezone = Asia/Seoul session.save_path = /data/webtmps
systemd 파일생성
: vi /etc/systemd/system/php-fpm.service
[Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=simple PIDFile=/data/apps/ln/php/var/run/php-fpm.pid ExecStart=/data/apps/ln/php/sbin/php-fpm –nodaemonize –fpm-config /data/apps/ln/php/etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target
systemd 등록 및 실행
systemctl enable php-fpm systemctl start php-fpm
log directory 링크
ln -s /data/apps/ln/php/var/log/ /data/logs/php-fpm
nginx site config 수정
: vi /data/apps/ln/nginx/conf/sites-enabled/umount.net.conf
server { listen 80; server_name umount.net; charset utf-8; access_log logs/umount_access.log main; error_log logs/umount_error.log crit; root /data/www/umount.net; index index.php; client_max_body_size 128M; location ~ /\.ht { deny all; } location ~ \.php$ { fastcgi_pass unix:/data/apps/php/php-fpm.sock; fastcgi_index index.php; fastcgi_buffers 256 16k; fastcgi_buffer_size 128k; fastcgi_connect_timeout 180s; fastcgi_send_timeout 180s; fastcgi_read_timeout 180s; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_max_temp_file_size 0; fastcgi_intercept_errors on; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { expires max; access_log off; log_not_found off; add_header Pragma public; add_header Cache-Control “public, must-revalidate, proxy-revalidate”; } }
php test 파일 생성
: vi /data/www/umount.net/info.php
<?php echo “hello umount world”; phpinfo(); ?>
nginx 재시작
systemctl restart nginx
웹브라우저 확인