nginx + php 安裝與整合

來源:互聯網
上載者:User

標籤:nginx + php 安裝與整合

環境:

Linux moban 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

1、我們這裡使用的php是5.3.27版本,在企業中一般是5.2.17這個比較經典的版本。
2、安裝之前我們要確認mysql和nginx已經安裝,運行時沒有問題的,最好檢查一遍。

3、檢查相關的包是否安裝:
    rpm -qa zlib libxml libjpeg freetype libpng gd  curl libiconv  zlib-devel libxml2-devel     libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
    不裝不影響安裝,但是將來網站使用的時候會出現問題
    yum install zlib libxml libjpeg freetype libpng gd  curl libiconv  zlib-devel         libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel -y

4、安裝字元集轉換庫相關,是一個命令; 註:必須存在devel
    tar zxf libiconv-1.14.tar.gz
    cd libiconv-1.14
    ./configure --prefix=/usr/local/libiconv
    make
    make install
    cd ../

5、添加一個加密相關的庫
    wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-    2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
    tar zxf libmcrypt-2.5.8.tar.gz
    cd libmcrypt-2.5.8
    ./configure
    make
    make install
    sleep 2
    /sbin/ldconfig
    cd libltdl/
    ./configure --enable-ltdl-install
    make
    make install
    cd ../../

6、安裝mhash加密擴充庫

    wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"
    tar zxf mhash-0.9.9.9.tar.gz
    cd mhash-0.9.9.9/
    ./configure
    make
    make install
    sleep 2
    cd ../

    rm -f /usr/lib64/libmcrypt.*
    rm -f /usr/lib64/libmhash*
    ln -s /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la
    ln -s /usr/local/lib64/libmcrypt.so /usr/lib64/libmcrypt.so
    ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
    ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
    ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a
    ln -s /usr/local/lib64/libmhash.la /usr/lib64/libmhash.la
    ln -s /usr/local/lib64/libmhash.so /usr/lib64/libmhash.so
    ln -s /usr/local/lib64/libmhash.so.2 /usr/lib64/libmhash.so.2
    ln -s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
    ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

7、另一個加密庫
    wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&   big_mirror=0"
    tar zxf mcrypt-2.6.8.tar.gz
    cd mcrypt-2.6.8/
    /sbin/ldconfig
    ./configure LD_LIBRARY_PATH=/usr/local/lib
    make
    make install
    cd ../
    sleep 2

8、yum install libxslt* -y

----------------------------------------上述準備完成後-------------------------------


9、解壓php : tar xf php-5.3.27.tar.gz
            pwd
            /root/php-5.3.27
   配合nginx編譯:./configure \
                --prefix=/application/php5.3.27 \
                --with-mysql=/application/mysql \
                --with-iconv-dir=/usr/local/libiconv \
                --with-freetype-dir \
                --with-jpeg-dir \
                --with-png-dir \
                --with-zlib \
                --with-libxml-dir=/usr \
                --enable-xml \
                --disable-rpath \
                --enable-safe-mode \
                --enable-bcmath \
                --enable-shmop \
                --enable-sysvsem \
                --enable-inline-optimization \
                --with-curl \
                --with-curlwrappers \
                --enable-mbregex \
                --enable-fpm \
                --enable-mbstring \
                --with-mcrypt \
                --with-gd \
                --enable-gd-native-ttf \
                --with-openssl \
                --with-mhash \
                --enable-pcntl \
                --enable-sockets \
                --with-xmlrpc \
                --enable-zip \
                --enable-soap \
                --enable-short-tags \
                --enable-zend-multibyte \
                --enable-static \
                --with-xsl \
                --with-fpm-user=nginx \
                --with-fpm-group=nginx \
                --enable-ftp

    關註:Thank you for using PHP.表示沒有問題。

    繼續:make && make install

    報錯: libmysqlclient.so.18: cannot open shared object file: No such file or directory
           make: *** [ext/phar/phar.php] Error 127   

    解決:  find / -name "libmysqlclient.so.18"
            /home/oldboy/tools/mysql-5.5.32-linux2.6-x86_64/lib/libmysqlclient.so.18
            /application/mysql-5.5.32-linux2.6-x86_64/lib/libmysqlclient.so.18

            把路徑/home/oldboy/tools/mysql-5.5.32-linux2.6-x86_64/lib/ 、/application/mysql-5.5.32-linux2.6-x86_64/lib/追加到/etc/ld.so.conf裡用ldconfig生效。

     報錯:Generating phar.phar
            chmod: 無法訪問"ext/phar/phar.phar":

     解決:mkdir ext/phar/phar.phar -p

     如:echo $?返回為0 即編譯成功。

10、建立軟連結:ln -s /application/php5.3.27/ /application/php

11、拷貝設定檔:cp php.ini-production  /application/php/lib/php.ini

12、開機檔案重新命名:mv /application/php/etc/php-fpm.conf.defult  php-fpm.conf

13、啟動php:/application/php/sbin/php-fpm
             (-t 檢查文法)

14、查看php的9000連接埠是否成功: netstat -lntup|grep php-fpm

           

-----------------------------------整合nginx------------------------------------

編輯nginx的設定檔:

      

    vi ../nginx-1.6.2/conf/extra/blog.conf

    server {
        listen       8000;
        server_name  blog.etiantian.org;
            root   html/blog;
            index  index.php index.html index.htm;
            access_log  logs/blog_access.log;
    location ~ .*\.(php|php5)?$
    {
     fastcgi_pass  127.0.0.1:9000;
     fastcgi_index index.php;
     include fastcgi.conf;

    }
    }

    vi nginx.conf

      server {
            listen       80;
            server_name  blog.etiantian.org;
            root   html/blog;
            index  index.php index.html index.htm;
            access_log  logs/blog_access.log;
        location ~ .*\.(php|php5)?$
        {
         fastcgi_pass  127.0.0.1:9000;
         fastcgi_index index.php;
         include fastcgi.conf;
        }
        }

    建立index.php檔案。

     <?php
    phpinfo ();
    ?>

檢查文法重啟nginx服務。

訪問即可。~               

本文出自 “一如既往” 部落格,謝絕轉載!

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.