centos安裝php php-fpm

來源:互聯網
上載者:User

標籤:

1、下載php源碼包

http://www.php.net/downloads.php

2 、安裝php

tar -xvf php-5.5.13.tar.bz2

cd php-5.5.13

./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear

出現錯誤: congigure error: xml2-config not found.

解決辦法:

執行命令: sudo yum install libxml2-devel

查看是否成功: find / -name "xml2-config"

出現錯誤: congigure error: Cannot find OpenSSL‘s <evp.h>

解決辦法:

yum install openssl openssl-devel

ln -s /usr/lib64/libssl.so /usr/lib/

出現錯誤: configure: error: Please reinstall the BZip2 distribution

解決辦法:yum install bzip2 bzip2-devel

出現錯誤: configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/

解決辦法:yum -y install curl-devel

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

sudo yum install libmcrypt libmcrypt-devel mcrypt mhash

configure: error: Please reinstall readline - I cannot find readline.h
sudo yum install readline-devel

make 

make install 

如果出現有提示make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1錯誤。的/configure 後面加上--disable-fileinfo, 再次./configure即可。

如果出現make: *** [sapi/cli/php] Error 1 修改Makefile  在EXTRA_LIBS = 最後加 -liconv 然後重新再次 make 即可。

添加 PHP 命令到環境變數

vim /etc/profile

在末尾加入

PATH=$PATH:/usr/local/php/bin

export PATH

要使改動立即生效執行

. /etc/profile 或 source /etc/profile

查看環境變數

echo $PATH

查看php版本

php -v 

PHP 5.5.13 (cli) (built: Jun 20 2014 11:11:26)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

配置php-fpm

cd /usr/local/php/etc

cp php-fpm.conf.default php-fpm.conf

啟動php-fpm

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

修改nginx的設定檔(/etc/nginx/conf.d/default.conf)

location / {

root web根目錄;

index index.html index.htm index.php;

}

location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME web根目錄$fastcgi_script_name;

include fastcgi_params;

}

重啟nginx

/etc/init.d/nginx restart

在web根目錄下建立index.php

<?php echo phpinfo(); ?>

在瀏覽器中輸入http://ip/index.php查看成功即可。

//註:根據自己的配置修改web根目錄即可,如我的為/usr/share/nginx/html。

如果啟動php-fpm出現錯誤: can not get uid for www,修改php-fpm.conf中user為nginx group為nginx

centos安裝php php-fpm

聯繫我們

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