Linux-rhel6.4 編譯安裝PHP,Nginx與php串連

來源:互聯網
上載者:User

標籤:linux   php   rhel   編譯安裝php   串連nginx   


確定依賴包安裝

gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel  

若沒安裝,掛載系統鏡像,從Packages檔案夾裡面找到安裝包安裝,或者有yum源的話可直接yum install安裝。


可利用鏡像自己製作本地yum源:http://kurol.blog.51cto.com/11433546/1927721


從官網擷取,編譯安裝

[[email protected] ~]# wget http://de2.php.net/get/php-5.5.38.tar.gz/from/this/mirror [[email protected] ~]# tar -zxvf php-5.5.38.tar.gz[[email protected] php-5.5.38]# ./configure --prefix=/usr/local/php-5.5.0 --with-config-file-path=/usr/local/php-5.5.0/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64......creating main/internal_functions_cli.c+--------------------------------------------------------------------+| License:                                                           || This software is subject to the PHP License, available in this     || distribution in the file LICENSE.  By continuing this installation || process, you are bound by the terms of this license agreement.     || If you do not agree with the terms of this license, you must abort || the installation process at this point.                            |+--------------------------------------------------------------------+Thank you for using PHP.config.status: creating php5.specconfig.status: creating main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/man1/phpize.1config.status: creating scripts/php-configconfig.status: creating scripts/man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/fpm/php-fpm.confconfig.status: creating sapi/fpm/init.d.php-fpmconfig.status: creating sapi/fpm/php-fpm.serviceconfig.status: creating sapi/fpm/php-fpm.8config.status: creating sapi/fpm/status.htmlconfig.status: creating sapi/cgi/php-cgi.1config.status: creating ext/phar/phar.1config.status: creating ext/phar/phar.phar.1config.status: creating main/php_config.hconfig.status: executing default commands[[email protected] ~]# make[[email protected] ~]# make install[[email protected] ~]# cd php-5.5.38[[email protected] php-5.5.38]# cp php.ini-production /usr/local/php-5.5.0/etc/php.ini[[email protected] php-5.5.38]# cd /usr/local/php-5.5.0/etc/[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf[[email protected] etc]# cd /usr/local/php-5.5.0/sbin[[email protected] sbin]# ./php-fpm


Nginx與php串連

    要點:  

        1:Nginx 預設支援 fastcgi  

        2:php編譯開啟模組:  

            --enable-fpm  

    串連:  

[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf     server {              listen       80;              server_name  localhost;              location / {                root   html;                index  index.html index.php;            }            .......            location ~ \.php$ {                root   html;                fastcgi_pass   127.0.0.1:9000;                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;                include   fastcgi_params;            }        }


重啟nginx:

[[email protected] ~]# cd /usr/local/nginx/sbin[[email protected] sbin]# ./nginx -s reload


添加php測試檔案:

[[email protected] ~]# cd /usr/local/nginx/html[[email protected] ~]# touch info.php[[email protected] ~]# vim info.php
<?phpphpinfo();?>


瀏覽器測試:

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/96/4D/wKioL1kfGlWDkef3AAD-ahlCg6E388.png-wh_500x0-wm_3-wmp_4-s_3438299227.png" title="1495210337(1).png" alt="wKioL1kfGlWDkef3AAD-ahlCg6E388.png-wh_50" />

本文出自 “謝育政” 部落格,請務必保留此出處http://kurol.blog.51cto.com/11433546/1927720

Linux-rhel6.4 編譯安裝PHP,Nginx與php串連

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.