Centos6.4 編譯安裝 nginx php

來源:互聯網
上載者:User

標籤:style   class   blog   code   http   tar   

一. 準備依賴庫

安裝make:

yum -y install gcc automake autoconf libtool make

安裝g++:

yum install gcc gcc-c++

二. 編譯安裝pcre

pcre 是一個Regex的庫,編譯nginx需要依賴該庫實現url rewrite

下載源碼

cd /usr/local/srcwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.bz2tar jxvf pcre-8.33.tar.bz2

編譯安裝

cd pcre-8.33./configuremakemake install

三. 編譯安裝zlib庫

zlib 是gzip實現

下載源碼

cd /usr/local/srcwget http://zlib.net/zlib-1.2.8.tar.gztar -zxvf zlib-1.2.8.tar.gz

編譯安裝

cd zlib-1.2.8
./configuremakemake install

四. 安裝openssl

檢查是否安裝了ssl

# rpm -qa|grep opensslopenssl-devel-1.0.1e-16.el6_5.14.x86_64openssl-1.0.1e-16.el6_5.14.x86_64

如果沒有安裝

下載源碼

cd /usr/local/srcwget http://www.openssl.org/source/openssl-1.0.1c.tar.gztar -zxvf openssl-1.0.1c.tar.gz

編譯安裝

./configuremakemake install

五. 編譯安裝nginx

cd /usr/local/srcwget http://nginx.org/download/nginx-1.2.8.tar.gztar -zxvf nginx-1.2.8.tar.gzcd nginx-1.2.8

  ./configure --sbin-path=/usr/local/nginx/nginx \
  --conf-path=/usr/local/nginx/nginx.conf \
  --pid-path=/usr/local/nginx/nginx.pid \
  --with-http_ssl_module \
  --with-pcre=/usr/local/src/pcre-8.33 \
  --with-zlib=/usr/local/src/zlib-1.2.8 \
  --with-openssl=/usr/local/src/openssl-1.0.1c

  make
  make install

安裝成功完畢後驗證是否安裝成功

/usr/local/nginx/nginx netstat -alptn|grep 80

六. 編譯安裝php

新版本的php中已經整合了php-fpm 

1. 準備工作

yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel

2. 下載源碼

wget http://cn2.php.net/distributions/php-5.4.7.tar.gztar zvxf php-5.4.7.tar.gz

3. 編譯安裝

cd php-5.4.7./configure --prefix=/usr/local/php  --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-curl --disable-debug  --disable-rpath --enable-inline-optimization --with-bz2  --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-gd --with-jpegmakemake testmake install

七. 配置啟動

1. 配置php-fpm

cd /usr/local/phpcp /etc/php-fpm.conf.default /etc/php-fpm.confvi /etc/php-fpm.conf

修改
user = llong
group = llong

2. 修改nginx 支援 php-fpm

開啟 nginx.conf 

其中server段增加如下配置,注意標紅內容配置,否則會出現No input file specified.錯誤

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}

3. 測試是否配置成功

在/usr/local/nginx/html下建立index.php檔案,輸入如下內容

<? echo phpinfo(); ?>

啟動php-fpm和nginx

/usr/local/php/sbin/php-fpm (手動打補丁的啟動方式/usr/local/php/sbin/php-fpm start) /usr/local/nginx/nginx

 

 

聯繫我們

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