Nginx編程開發教程之PHP編譯安裝方法,nginx編程開發
擷取PHP:
????http://php.net/????
編譯安裝PHP:
????yum -y install libxml2-devel? ? #先安裝依賴包
????yum -y install curl-devel
????yum -y install libjpeg-devel
????yum -y install libpng-devel
????yum -y install freetype-devel
????yum install -y libmcrypt-devel
????./configure ? ?--prefix=/usr/local/php ? ? --enable-fpm ? ? --with-zlib ? ?--enable-zip ? ? --enable-mbstring ? ? --with-mcrypt ? ? --with-mysql ? ? --with-mysqli ? ?--with-pdo-mysql ? ? --with-gd ? ? --with-jpeg-dir ? ? --with-png-dir ? ? --with-freetype-dir ? ? --with-curl ? ? --with-openssl ? ? --with-mhash ? ? --enable-bcmath ? ? --enable-opcache?? ? #編譯
????
? ? make && make install????
????? ?
PHP和Nginx整合:? ? 配置PHP-FPM
????? ? cd?/usr/local/php/etc
????????cp php-fpm.conf.default php-fpm.conf
????????cp /tmp/php-5.6.33/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm? ? #配置service方式運行
????????chmod +x /etc/init.d/php-fpm
????????chkconfig --add php-fpm
????????
????????service php-fpm start? ? #netstat -tlnp|grep php 查看連接埠
????????service php-fpm reload
????????service php-fpm restart
????????service php-fpm stop
????配置PHP:????? ? cp /tmp/php-5.6.33/php.ini-development /usr/local/php/lib/? ? #選擇一個改為php.ini
????????cp /tmp/php-5.6.33/php.ini-development /usr/local/php/lib/
????????cp /tmp/php-5.6.33/php.ini-development /usr/local/php/lib/php.ini
? ? Nginx支援PHP:????????root html;
index index.html index.htm index.php;
? ? ? ? location ~ \.php$ {
? ? ? ? ?????try_files $uri =404
? ? ? ? ? ? fastcgi_pass ? 127.0.0.1:9000;
? ? ? ? ? ? #fastcgi_param ?SCRIPT_FILENAME ?/scripts$fastcgi_script_name;
? ? ? ? ? ? #include ? ? ? ?fastcgi_params;
include ? ? ? ?fastcgi.conf;
? ? ? ? }
? ?? ??