分享

Linux下安装配置php5.5和nginx

 昵称17690251 2015-06-28
           今天我们这篇关于php5.5和nginx的安装介绍的技术文章我们主要为各位朋友们介绍关于Linux环境下面安装nginx和php5.5方面的内容。当然只是为初学者朋友们作为参考的一篇nginx的技术文章哦。

首先,我们需要下载安装php5.5

cd /usr/local/src/
wget http://www./get/php-5.5.0.tar.bz2/from/jp1./mirror


如果以上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


这样子,我们的php就可以说安装好了,至于说到nginx的安装,请大家参考
http://www./index/Article/content/id/185.html
里面的介绍的内容哦,下面我们说说具体的配置一个网站

配置测试站点test.



mkdir /data/logs/nginx/ # 用于存放nginx日志.请看2.3的配置文件
mkdir -p /data/site/test./ # 站点根目录
vim /data/site/test./info.php

保存退出,在nginx.conf的http断中加上如下内容:

server {
listen 80;
server_name test.;
access_log /data/logs/nginx/test..access.log main;

index index.php index.html index.html;
root /data/site/test.;

location /
{
try_files $uri $uri/ /index.php?$args;
}

location ~ .*\.(php)?$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;

}
}


配置讲解
nginx将会连接回环地址9000端口执行PHP文件,需要使用tcp/ip协议,速度比较慢.建议大家换成使用socket方式连接。将fastcgi_pass 127.0.0.1:9000;改成fastcgi_pass unix:/var/run/phpfpm.sock;

启动nginx


/usr/local/nginx-1.4.1/sbin/nginx


访问测试

# curl http://test./info.php
test php


出现如上内容,说明PHP安装完成。

好了,关于php5.5和nginx的安装介绍详解我们就为各位朋友们暂时介绍到这里吧,希望对于各位朋友们特别是初学者朋友们能够有所帮助哦。        

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多