運維筆記:PHP+nginx編譯安裝參考

前言

因爲不少新手問我怎麼作編譯安裝,因此就蠻整理一下。學會編譯安裝,不管是開發或者運維,都是皆要掌握的硬性要求php

PHP

依賴

yum install libxml2-devel bzip2-devel libcurl-devel libpng-devel libXpm-devel libjpeg-turbo-devel gmp-devel freetype-devel libvpx-devel krb5-devel zlib-devel pcre-devel pam-devel openssl openssl-devel libmcrypt libmcrypt-devel
libmcrypt libmcrypt-devel 可能不存在
須要添加repo 
yum install epel-release
yum install libmcrypt libmcrypt-develmysql

安裝步驟參考

  • 下載包 wget http://php.net/get/php-7.2.5....
  • 拓展差別 PHP7.2 enable-gd-native-ttf with-mcrypt 已經不支持
  • 編譯參數 酌情加減(可移步其餘文章瞭解參數 PHP編譯參數詳解)
    ./configure --prefix=/opt/php72 --with-config-file-scan-dir=/opt/php72/etc/php.d --disable-debug --with-pic --with-bz2 --with-gettext --with-gmp --enable-mbregex --enable-mbstring --with-openssl --with-zlib --with-layout=GNU --enable-exif --enable-zip --enable-sockets --enable-xml --with-pear --enable-fpm --with-pdo-mysql --with-curl --with-gd --with-mysqli --enable-soap --with-fpm-user=www --with-fpm-group=www --with-freetype-dir --enable-mbstring --enable-bcmath --with-jpeg-dir --with-ldap-dir

配置文件整理

cp php-fpm.conf.default php-fpm.conf
cp www.conf.default www.conf
cp php.ini-production /opt/php7/etc/php.ini 從源碼包複製php.ini配置nginx

nginx

安裝步驟參考

yum install gcc #編譯須要
yum install -y pcre-devel #rewrite
yum install -y zlib-devel #HTTP gzip
yum install openssl* #支持ssl
wget http://nginx.org/download/ngi...
tar xvzf nginx-1.11.5.tar.gz
./configure --prefix=/opt/nginx --user=www --group=www --with-http_ssl_module --with-pcre
make && make installsql

常見編譯參數說明

./configure --help
./configure
--prefix=/opt/nginx
--user=apache
--group=apache
--with-http_stub_status_module:支持nginx狀態查詢
--with-http_ssl_module:支持https
--with-http_spdy_module:支持google的spdy,想了解請百度spdy,這個必須有ssl的支持
--with-pcre:爲了支持rewrite重寫功能,必須制定pcreapache

相關文章
相關標籤/搜索