linux搭建php5 nginx

來源:互聯網
上載者:User
1 php配置:

首先,我們需要下載安裝php5

cd /usr/local/src/

wget http://cn2.php.net/get/php-5.5.33.tar.bz2/from/this/mirror

官網http://php.net/downloads.php



確保安裝之前有安裝gd,png,curl,xml等等lib開發庫。如果不確定,執行以下命令:
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
以下參數支援,ftp,圖片函數,pdo等支援,因為使用了php內建的mysqlnd,所以不需要額外安裝mysql的lib庫了.如果你是64位系統,參數後面加上–with-libdir=lib64,如果不是可以跳過。
tar -xjf php-5.5.0.tar.bz2
cd php-5.5.0
./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
make
make install
備忘:如果PHP不需要curl和ftp的支援,可以將以上的–with-curl –enable-ftp去掉. 如果你是專業的linux從業人員,你完全可以看著help來選擇你的安裝參數,如果你不是的話,我建議你直接複製黏貼我的配置參數.這樣可以少走一些彎路.
已經安裝完成了php,下面我們針對php,配置php
cp php.ini-production /usr/local/php-5.5.0/etc/php.ini
cp /usr/local/php-5.5.0/etc/php-fpm.conf.default /usr/local/php-5.5.0/etc/php-fpm.conf
其實我們只是使用它預設提供給我們的一個配置,當然大家也可以根據自己需要進行修改配置資訊,然後進行啟動php-fpm
/usr/local/php-5.5.0/sbin/php-fpm
執行以上命令,如果沒報錯一般情況下表示啟動正常,如果不放心,也可以通過連接埠判斷是PHP否啟動
# netstat -lnt | grep 9000

tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN

2 nginx配置

http://nginx.org/en/download.html

下載 wget http://nginx.org/download/nginx-1.6.3.tar.gz

cd nginx-1.6.3

./configure --prefix=/usr/local/nginx-1.6.3 --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-pcre

make

make install

紹,讓大家大致明白組建組態檔案的介紹
–with-http_stub_status_module:支援nginx狀態查詢
–with-http_ssl_module:支援https
–with-http_spdy_module:支援google的spdy,想瞭解請百度spdy,這個必須有ssl的支援
–with-pcre:為了支援rewrite重寫功能,必須制定pcre
最後輸出如下內容,表示configure OK了。
checking for zlib library ... found
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx-1.5.1"
nginx binary file: "/usr/local/nginx-1.5.1/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx-1.5.1/conf"
nginx configuration file: "/usr/local/nginx-1.5.1/conf/nginx.conf"
nginx pid file: "/usr/local/nginx-1.5.1/logs/nginx.pid"
nginx error log file: "/usr/local/nginx-1.5.1/logs/error.log"
nginx http access log file: "/usr/local/nginx-1.5.1/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
# make //確定你的伺服器有安裝make,如果沒有安裝請執行yum install make
# make install
好了,nginx的安裝還是非常的簡單的,當然這裡沒有過多的介紹關於nginx遇到的問題。因為問題可能類型會非常的多,大家可以根據具體的錯誤的提示的內容,直接Google或者百度一下就可以了。下面我們來說說關於nginx的啟動、關閉、重設nginx的內容。
啟動:直接執行以下命令,nginx就啟動了,不需要改任何設定檔,nginx配置多網域名稱虛擬機器主機請參考後續文章.
/usr/local/nginx-1.5.1/sbin/nginx
測試一下我們的nginx是否可以成功的啟動了
[root@ns conf]# curl -s http://localhost | grep nginx.com
nginx.com.
接下來說說如何進行把nginx的服務關閉掉,我們可以通過下面的方式
/usr/local/nginx-1.5.1/sbin/nginx -s stop
新視窗
當然,在我們的nginx運行過程中,可能你需要修改nginx的相關配置,可以重設載入配置資訊
/usr/local/nginx-1.5.1/sbin/nginx -s reload

以上就介紹了linux搭建php5 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.