您好,欢迎访问一九零五行业门户网

centos安装php php-fpm 以及 配置nginx

下载php源码包
http://www.php.net/downloads.php
安装php
tar -xvf php-5.5.13.tar.bz2cd 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
解决办法:
1.执行命令:
sudo yum install libxml2-devel
2.查看是否成功:
find / -name xml2-config
出现错误: congigure error: cannot find openssl's
解决办法:
yum install openssl openssl-develln -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 /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
可能出现的错误
编译php5.5 make 时出现错误
make: *** [ext/fileinfo/libmagic/apprentice.lo] error 1
解决办法:
这是由于内存小于1g所导致.disable fileinfo support 禁用 fileinfo
在./configure加上选项:
--disable-fileinfo
配置环境变量
添加 php 命令到环境变量
vim /etc/profile
在末尾加入
path=$path:/usr/local/php/binexport 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/etccp php-fpm.conf.default php-fpm.conf
启动php-fpm
sudo /usr/local/php/sbin/php-fpm
配置nginx
修改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; //这个ip和端口对应php-fpm设置的端口fastcgi_index index.php;fastcgi_param script_filename web根目录$fastcgi_script_name;include fastcgi_params;}
重启nginx
/etc/init.d/nginx restart
在web根目录下创建index.php
在浏览器中输入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 以及 配置nginx,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息