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;
? ? ? ? }

? ?? ??

相关内容