5、CentOS 6.5系統安裝配置Nginx-1.2.7+PHP-5.3.22環境

來源:互聯網
上載者:User

標籤:style   http   os   io   使用   ar   strong   檔案   sp   

一,作業系統

以最小伺服器形式安裝系統,並添加開發工具庫,便於後期編譯使用。

此處基本都是下一步,下一步,不再廢話。

安裝完成,進入系統,調通網路,關閉防火牆或開啟相應的WEB連接埠。

以下安裝操作預設都在/root目錄下進行。

二,nginx安裝

下載pcre和zlib,地球人都知道……

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz

tar -zxvf pcre-8.32.tar.gz

cd pcre-8.32

./configure

make && make install

wget http://zlib.net/zlib-1.2.7.tar.gz

tar -zxvf zlib-1.2.7.tar.gz

cd zlib-1.2.7

./configure

make && make install

下載當前最新的穩定版本 nginx-1.2.7

cd

wget http://nginx.org/download/nginx-1.2.7.tar.gz

tar -zxvf nginx-1.2.7.tar.gz

cd nginx-1.2.7

./configure --prefix=/usr/local/nginx/  --with-pcre=/root/pcre-8.32  --with-zlib=/root/zlib-1.2.7

make && make install

/usr/local/nginx/sbin/nginx

啟動了,開啟瀏覽器測試一下nginx吧。

三,安裝PHP環境

下載當前穩定版本 php-5.3.22

wget http://www.php.net/get/php-5.3.22.tar.gz/from/cn1.php.net/mirror

tar -zxvf php-5.3.22.tar.gz

在開始編譯前,安裝一些php基本的軟體包,直接yum安裝。

yum -y install gd curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql mysql-devel

準備好後,進行php目錄進行編譯

cd php-5.3.22

./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm --enable-debug --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-curl --with-mysql=/usr/bin/mysql --with-mysqli=/usr/bin/mysql_config

make && make install

cp php.ini-development /usr/local/php/lib/php.ini

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

安裝完成後即可啟動php了

/usr/local/php/sbin/php-fpm

運行後,未提示錯誤,啟動成功。

四,關聯nginx和php

開啟nginx設定檔找到下面這段配置

vi /usr/local/nginx/conf/nginx.conf

        # location ~ \.php$ {

        #    root           html;

        #    fastcgi_pass   127.0.0.1:9000;

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        #    include        fastcgi_param;

        # }

將這段配置的注釋去掉,並將include fastcgi_param改為include fastcgi.conf

儲存重啟nginx

/usr/local/nginx/sbin/nginx -s reload

預設web目錄是html檔案夾,在下面建立一個測試檔案

touch /usr/local/nginx/html/test.php

vi /usr/local/nginx/html/test.php

寫入<?php phpinfo();?>

儲存後,在瀏覽器中訪問該頁,如顯示php配置資訊,則大功告成。

5、CentOS 6.5系統安裝配置Nginx-1.2.7+PHP-5.3.22環境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.