手把手教你在centos下编译安装配置高性能web服务器环境nginx+php(fast-cgi)+mysql等/适合小内存vps使用

本文为实战操作过程的全程记录,采用一台新创建的linode vps(512M内存)环境,操作系统采用centos 6.2,以从源码编译的方式安装配置nginx, php(fast-cgi模式)web环境。

我们的目标:配置一台高性能、安全的web服务器。

所需软件如下:

Nginx(英文) Nginx(简体中文) 公认的高性能web服务器[下载 http://nginx.org/en/download.html]

PHP 应用最广泛的web开发语言[下载 http://www.php.net/downloads.php]

MySQL 广泛应用于web服务器上的数据库,速度快[下载 http://www.mysql.com/downloads/mysql/]

phpMyAdmin 使用php开发的基于web的MySQL管理工具 [下载 http://www.phpmyadmin.net/home_page/downloads.php]

准备工作:

我的这台vps主机名为fsvps,有一个普通用户名为feng,通常我就使用这个用户登录管理,只有需要使用root身份时才su切换到管理员,只要不再需要使用root权限就退回到普通用户下。建议你也这样操作,以免误操作造成不可挽回的灾难。

通过ssh(windows下可以使用putty,建议去官方下载英文原版)登录服务器,确保已经安装过过如下的必要的软件(linux下软件编译环境)

centos 6.x下的 MySQL安装

我们先做最简单的,安装mysql. 因为我们不打算自己编译它,使用centos的yum安装就可以了。当然,如果你愿意,完全是可以的,参看这里{从源码编译并安装mysql数据库[本文待写]}

centos下,只需要一条命令就可以安装mysql服务器,执行su,按提示输入root密码,切换到root身份,然后运行yum install mysql-server

[feng@fsvps ~]$ su
[root@fsvps feng]# yum install mysql-server mysql-devel -y

yum安装了好几个包,其中

mysql-server-5.1.61-1.el6_2.1.i686.rpm 才是我们平时说的mysql;

mysql-5.1.61-1.el6_2.1.i686.rpm是命令行界面的mysql客户端,我们可以用它在服务器上创建数据库,管理mysql用户等,但我们通常使用更好用的phpMyAdmin;

mysql-devel-5.1.61-1.el6_2.1.i686.rpm则是mysql客户端源码的开发头文件,接下来编译php时要用的,所以安装mysql这一步要先做。

yum还安装好几个依赖包,如mysql-5.1.61-1.el6_2.1.i686.rpm, openssl-1.0.0-20.el6_2.5.i686.rpm, zlib-devel-1.2.3-27.el6.i686.rpm, openssl-devel-1.0.0-20.el6_2.5.i686.rpm等几个在php编译也会用到。

注:这里的几个包,你在操作时,其版本号可能不完全一致,这是因为yum源里的包会不定期升级,但不影响我们接下来的编译过程。

我们启动mysql服务,mysqld将完成初始化操作。运行 /etc/init.d/mysqld start 如下

[root@fsvps feng]# /etc/init.d/mysqld start
.....
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h fsvps password 'new-password'
.....
                                                         [确定]
正在启动 mysqld:                                          [确定]

注意消息里有如上斜体显示的部分。这时候,你的mysql的root用户还是空密码的,这非常不安全的,斜体行就是修改root密码的命令。假设我要把mysql 的 root密码修改成 Path8.net ,执行命令如下:

[root@fsvps feng]# /usr/bin/mysqladmin -u root password 'Path8.net'

[tips] 注意,mysql的root用户与linux系统的root用户是没有任何关系的,mysql 的root用户只用于登录mysql服务器。最好给他们设置成不同的密码,这样会安全一点。

试着登录一下,确认root密码已修改成功:

[root@fsvps feng]# mysql -uroot -pPath8.net
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

你没看错,mysql -uroot -pPath8.net 这行命令里, -u 与 -p 后面不必要加空格

如果你看到上面最后一行的 mysql> 提示符,说明已经成功登录。输入执行 show variables; 感受一下mysql

mysql> show variables;
+-----------------------------------------+------------------+
| Variable_name                           | Value            |
+-----------------------------------------+------------------+
| auto_increment_increment                | 1                |
| auto_increment_offset                   | 1                |
| autocommit                              | ON               |
.......(下略)

列出了很多变量,我们优化MySQL,主要是就是靠修改这些参数实现的。

输入exit ,退出mysql客户端。mysql安装配置至此结束,这一步简单吧!

Nginx安装

接下来编译Nginx,稍微复杂一点,照着做,肯定可以很顺利完成。

[强烈建议]如果你还在使用root用户,建议你执行exit退出root身份,使用普通用户的身份继续操作。

进入该普通用户的家目录,建两个目录  source 与 build ,分别用于存储下载的源代码及作为编译的工作目录。当然放到其它目录下也可以,名字也可以任意取,只要方便使用管理。

[root@fsvps feng]# mkdir source build

你没看错,一条命令就建了这两个目录。进入build目录

[root@fsvps feng]# cd build/

安装nginx的依赖包:pcre, pcre-devel

因为nginx需要安装一个叫PCRE的软件,在centos上可能找不到。笔者的经验是,就算你通过yum 安装了这个包,nginx也不认。 编译nginx事实上需要的依赖包是pcre-devel,可以执行yum install pcre-devel 安装它。不过这个包的编译安装很简单,正好我们拿它练练手,熟悉熟悉linux编译安装软件的一般过程。

[tips] linux下从源码编译安装软件一般是三步:配置、编译、安装。具体一点说就依次是执行三条命令:configure, make, make install. 不多讲理论,实际操作一下就明白了。

 在build目录下创建子目录pcre

[feng@fsvps build]$ mkdir pcre
[feng@fsvps build]$ cd pcre

使用wget 工具从pcre官方下载 pcre 包,下载链接为 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.zip,将它解压缩到pcre目录下

[feng@fsvps build]$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.zip

几秒钟就可以下载完成。(如果提示 bash: wget: command not found 那是你还没有安装wget,切换到root用户,yum install wget -y 安装之)

[feng@fsvps pcre]$ ls
pcre-8.21.zip

看一下,刚下载的 pcre源码包,这是个zip包,使用unzip命令解压缩之

[feng@fsvps pcre]$ unzip pcre-8.21.zip
[feng@fsvps pcre]$ ll
总用量 1680
drwxr-xr-x 6 feng feng    4096 12月 12 2011 pcre-8.21
-rw-rw-r-- 1 feng feng 1709377  6月 30 13:50 pcre-8.21.zip
[feng@fsvps pcre]$ cd pcre-8.21

进去看看里面都是些什么文件,特别注意一下configure文件

[feng@fsvps pcre-8.21]$ ll
总用量 3716
-rwxr-xr-x 1 feng feng   6961 10月  5 2009 132html
-rw-r--r-- 1 feng feng 338277 12月 11 2011 aclocal.m4
........  (略)
-rwxr-xr-x 1 feng feng 595700 12月 11 2011 configure
........  (略)
-rw-r--r-- 1 feng feng   3460  8月  2 2011 ucp.h

这个configure文件,就是“源码安装三步曲”的第一步的configure,它将检查你的系统是否具备了编译pcre必要的软件包,配置出用于编译pcre的环境,供第二步用。如果缺少某些软件,它会给出提示。

[tips] 另外,注意这个目录里还有几个文件README, INSALL,LICENCE,它们都是普通的文本文件,供使用人阅读,分别是 自述文件,安装说明,授权协议。通常linux/unix世界的源码包里都有这几个文件(有时作者会把INSTALL并成到README里),建议阅读一下,尤其是README与INSTALL。

执行第一步 configure

[feng@fsvps pcre-8.21]$ ./configure

注意configure命令前面要带上 ./ ,因为我们要执行的是在当前目录下的configure文件,。

configure过程中可能出现的几个报错,及原因:

  • 1) ./configure: error: C compiler gcc is not found 原因:你没有安装gcc ,这样可能你也没安装下面几个包,请一并安装
    yum install gcc gcc-c++ autoconf make
  • 2) Makefile: 权限不够 原因:当前用户没有权限读写nginx源码目录,请切换到root下运行如下命令,作用是将当前目录的所有文件所有者都设为我们正在使用的普通用户。
    [root@fsvps nginx-1.2.1]# chown -R feng:feng  ./
    [root@fsvps nginx-1.2.1]# exit

    然后exit退出到普通用户状态下。 chown 后的 feng:feng 分别是所使用的普通账号的用户名,及其用户组名。

开始编译,这步非常简单,运行make就可以,可能要花费几分钟时间,你可以干点其它,比如起身活动一下。

[feng@fsvps pcre-8.21]$ make

完了如果看到下面的消息:make[1]: Leaving directory `/home/feng/build/pcre/pcre-8.21'
说明编译完成了,那么开始安装。安装很简单,使用root用户权限,运行make install 就可以了。所以su,按提示输入root密码,切换到root身份

[feng@fsvps pcre-8.21]$ su
[feng@fsvps pcre-8.21]# make install

完了消息应该是 make[1]: Leaving directory `/home/feng/build/pcre/pcre-8.21'

这样pcre就安装好了。然后exit退回到普通用户状态下。

编译安装nginx

接下来才是真正安装nginx,过程差不多,但我们要多配置几个参数选项。

到 nginx官网上 http://nginx.org/en/download.html 找最新的稳定版的下载链接,写本文时2012-06-30 最新版本为 nginx-1.2.1  下载链接为 http://nginx.org/download/nginx-1.2.1.tar.gz 使用wget 将其下载到vps上。

[root@fsvps build]$ wget http://nginx.org/download/nginx-1.2.1.tar.gz

几秒钟就可以下载完成。(如果提示 bash: wget: command not found 那是你还没有安装wget,切换到root用户,yum install wget -y 安装之)

解压缩,然后把压缩包移动到source目录,以备不时之需。

[root@fsvps build]$ ll
总用量 708
-rw-r--r-- 1 root root 718161  6月  5 14:10 nginx-1.2.1.tar.gz
[root@fsvps build]$ tar xf nginx-1.2.1.tar.gz 
[root@fsvps build]$ ll
总用量 712
drwxr-xr-x 8 1001 1001   4096  6月  5 14:02 nginx-1.2.1
-rw-r--r-- 1 root root 718161  6月  5 14:10 nginx-1.2.1.tar.gz
[root@fsvps build]$ mv nginx-1.2.1.tar.gz ../source/

[tips] 文件名很长,打字太累? 试试tab键,比如先打出 mv ngi 然后按tab 键一次,没反应,再按一次,看有什么变化;然后继续打一个句点,再按一次tab键。相信你已经能悟出点什么了。

进入nginx源码目录,浏览一下里面的文件

[root@fsvps build]$ cd nginx-1.2.1/
[root@fsvps nginx-1.2.1]$ ll
总用量 560
drwxr-xr-x 6 1001 1001   4096  6月 30 11:39 auto
-rw-r--r-- 1 1001 1001 207988  6月  5 14:02 CHANGES
-rw-r--r-- 1 1001 1001 317085  6月  5 14:02 CHANGES.ru
drwxr-xr-x 2 1001 1001   4096  6月 30 11:39 conf
-rwxr-xr-x 1 1001 1001   2345  1月 18 15:07 configure
drwxr-xr-x 3 1001 1001   4096  6月 30 11:39 contrib
drwxr-xr-x 2 1001 1001   4096  6月 30 11:39 html
-rw-r--r-- 1 1001 1001   1365  1月 18 15:07 LICENSE
drwxr-xr-x 2 1001 1001   4096  6月 30 11:39 man
-rw-r--r-- 1 1001 1001     49 10月 31 2011 README
drwxr-xr-x 8 1001 1001   4096  6月 30 11:39 src

运行configure,就是本目录下的该文件,上面标红加;目录是配置nginx的编译环境,运行如下命令,参数比较长,可以直接复制帖。

[root@fsvps nginx-1.2.1]$ ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/conf/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --with-http_stub_status_module --with-http_gzip_static_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_random_index_module --with-cpu-opt=pentium4

注意configure命令要带上./ ,上面已经标红显示。大致讲一下是什么意思 [注]如果你仅仅想编译一个web环境用,而不想学习编译linux程序的一般方法,这部分那可以跳过不用看。

把参数重排下版,一行一个参数,简单注释一下

--prefix=/usr/local/nginx    #编译后安装到目录 /usr/local/nginx 
--sbin-path=/usr/local/sbin/nginx #
--conf-path=/usr/local/conf/nginx/nginx.conf #主配置文件路径
--error-log-path=/var/log/nginx/error.log  #错误日志目录
--pid-path=/var/run/nginx.pid    #nginx程序启用后,自动将其进程号写到该文件
--lock-path=/var/run/nginx.lock  #lock文件路径
--with-http_stub_status_module   #通过web查看nginx运行状态
--with-http_gzip_static_module   #gzip压缩支持
--with-http_sub_module     #加入ngx_http_sub_module模块
--with-http_flv_module     #加入flv模块
--with-http_mp4_module     #mp4模块
--with-http_random_index_module   #http_random_index_module模块
--with-cpu-opt=pentium4    #针对intel cpu优化

--with-xxxx_module的那些模块,如果你确定不需要,那就可以不要加入。那就这样指定参数

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/conf/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock  --with-http_stub_status_module --with-http_gzip_static_module

只带两个比较有用的模块。事实上这些参数一个都不指定,也是可以,这样就是按nginx的默认配置编译了。如果你想查看ngix的configure都有哪些参数选项可以运行 ./configure --help 查看,这里不多讲了。

如果报错:./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

这是因为没有找到PCRE包,请检查是否正确安装了PCRE包:

不出意外,应该能看到这样报告消息:

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/sbin/nginx"
  nginx configuration prefix: "/usr/local/conf/nginx"
  nginx configuration file: "/usr/local/conf/nginx/nginx.conf"
  nginx pid file: "/var/run/nginx.pid"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/usr/local/nginx/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"

有些软件的configure完成后会给出类似的一个配置报告,供我们检查配置选项是否正确。如果有不正确处,或还想改改,那就再运行一次configure --xx --yyy.

确认无误,开始编译

[feng@fsvps nginx-1.2.1]$ make

开始编译,非常快,可能一分钟就编译完成,最后消息大致如:make[1]: Leaving directory `/home/feng/build/nginx-1.2.1'

接下来,你应该知道了,切换到root身份,make install 安装。

nginx运行测试

下面的操作要在root身份下操作。

我们测试一下nginx是否正常工作。因为我们把nginx的二进制执行文件配置安装在 /usr/local/sbin/nginx  (前面的configure参数 --sbin-path=/usr/local/sbin/nginx ),目录/usr/local/sbin/默认在linux的PATH环境变量里,所以我们可以省略路径执行它:

[root@fsvps nginx-1.2.1]# nginx

它不会有任何信息显示。打开浏览器,通过IP地址访问你的nginx站点,如果看到这样一行大黑字,就证明nginx已经工作了:

Welcome to nginx!

看上去很简陋,只是因为没有给它做漂亮的页面。我们来简单配置一下它的运行配置。我们configure的参数--conf-path=/usr/local/conf/nginx/nginx.conf 这就是它的配置文件。我们去看看。

[root@fsvps nginx-1.2.1]# cd /usr/local/conf/nginx/
[root@fsvps nginx]# ls
fastcgi.conf          fastcgi_params.default  mime.types          nginx.conf.default   uwsgi_params
fastcgi.conf.default  koi-utf                 mime.types.default  scgi_params          uwsgi_params.default
fastcgi_params        koi-win                 nginx.conf          scgi_params.default  win-utf

如果这里没有nginx.conf,但有个 nginx.conf.default,我们用它复制个副本nginx.conf (早期版本默认是没有nginx.conf的)

用你熟悉的编辑器打开它,推荐使用vim;如果不会用,那可以使用nano, 功能简单,但一看就会用: nano nginx.conf

找到如下的部分,大概在35行,

server {
        listen       80 default;
        server_name  localhost;
        root /var/www/html/default;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
        #    root   html;
            index  index.html index.htm;
        }
................
}

如上红色加粗显示部分,做三处修改:

  • listen 80 后插入“空格default”
  • 在里面加入一行 root /var/www/html/default;
  • 注释掉root html;一行

上面的server{....}是定义的一台虚拟主机,我们刚加入的一行是定义这个虚假主机的web目录。listen 行的default是表示这一个server{...}节点是默认的虚假主机(默认站点)

执行 nginx -t 测试刚才的nginx配置文件是否有语法错误:

[root@fsvps nginx]# nginx -t
nginx: the configuration file /usr/local/conf/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/conf/nginx/nginx.conf test is successful

显示没有错误,检测通过。如果不是这样,请返回仔细检查你的配置文件是否哪里写错了,注意行尾要有英文分号。

我们在硬盘上创建这个目录:

[root@fsvps nginx]# mkdir -p /var/www/html/default

写一个html文件index.html/var/www/html/default目录里,使用你熟悉的编辑器,随便写什么内容、怎么排版。

然后让nginx重新加载配置文件,看看刚才创作的html页面效果如何。

常见错误FAQ

1) 如果通常访问时看到还是 Welcome to nginx! ,请返回检查,重点在这几处:

  • 请确认/var/www/html/default 目录下有你创作的index.html 文件?
  • 检查该文件权限,other用户是否有读的权限? 如果不懂linux文件权限,请执行 chmod 755 /var/www/html/default/index.html
  • 检查nginx.conf配置文件里,只否只有一个server{...} 节点,并且该节点里是否有 listen       80 default;   一行,注意其中要有 default
  • 检查上述server{...}节点里是否有 root /var/www/html/default; 一行,注意路径是拼写是否正确。
  • 检查其中 location / {...} 节点里的 #    root   html;  一行,是否注释掉了。

2) 如果看到的是 404 Not Found 或者“找不到该页面”类似的提示:

  • 检查上述 location / {...} 节点中是否有这一行 index  index.html index.htm;

3) 如果访问时,显示“找不到服务器”、“无法连接到服务器”这样的错误:

  • 运行检查nginx进程在运行,运行ps aux |grep nginx 命令,正常情况有如下三条:
    nginx: master process nginx
    nginx: worker process
    grep nginx
    如果只有第三条,请运行nginx 重新启用nginx,如有报错请照说明检查。一般是配置文件的语法错误。
  • 请运行nginx -t 检查配置文件是否有语法错误。

[tips] location / {...} 节点里的 #    root   html;  一行,不注释掉也可以:请把你创造的index.html 放到/var/www/html/default/html目录下。

至此,我们的nginx也可以正常工作了。是否在纳闷“nginx怎么这么简陋?只能显示几个干巴巴的页面”,这是因为我们还没有给它装备PHP这个核动力引擎。

建议你稍微休息一下,然后进入下一步的“php安装”,要做好持久战的准备,它比前面所有要花费时间都长。

php的安装

php版本选择

php官方提供了很多版本,我们照例使用最新稳定版,http://www.php.net/downloads.php

本文写作时[2012-07-01],php最新版本有两个分支,分别是是PHP 5.4.4 (Current stable) 与 PHP 5.3.14 (Old stable),据说php 5.4分支的改动,会不支持比较旧的php程序,所以我们选择php 5.3分支(当前为php-5.3.14)。虽然仍会有极少数非常古老的程序,必须在更旧版下才能运行,但我们这里不迁就它们了,因为我们要使用fast-cgi,而5.2版本本身不带FPM (fast-cgi process manager),要打fpm补丁,会麻烦一些。如有兴趣,可参阅张宴的 Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版) http://blog.s135.com/nginx_php_v6/

下载php源码到vps上

从php官方下载页面上http://www.php.net/downloads.php 点所选的版本,选择距离最近的下载镜像。如果是美国vps,就选个美国的镜像,这样更快。我选择yahoo! inc.镜像,应该全球访问速度都比较快(php.net官方似乎就是yahoo! inc.镜像)。复制所选下载地址,通过wget下载到build/php目录下,并解压缩,然后把原始压缩包移动到source目录存档。

[root@fsvps php]$ wget http://cn.php.net/get/php-5.3.14.tar.bz2/from/www.php.net/mirror
[root@fsvps php]$ ll
总用量 11160
-rw-r--r-- 1 root root 11408016  6月 14 16:10 php-5.3.14.tar.bz2
[root@fsvps php]$ tar xf php-5.3.14.tar.bz2 
[root@fsvps php]$ mv php-5.3.14.tar.bz2 ../../source
[root@fsvps php]$ cd php-5.3.14/

进入php源码目录,浏览一下,里面文件相当多,注意里面也有configure, README等文件,还有其它的几个大写文件名的文件,有兴趣参阅一下。

[root@fsvps php-5.3.14]$ ll
总用量 4796
-rw-r--r--  1 101 101    3460  6月 13 08:20 acconfig.h
-rw-r--r--  1 101 101      28  6月 13 08:18 acconfig.h.in
-rw-r--r--  1 101 101   76103  6月 13 08:18 acinclude.m4
-rw-r--r--  1 101 101  306427  6月 13 08:20 aclocal.m4
drwxr-xr-x  2 101 101    4096  6月 13 08:18 build
-rwxr-xr-x  1 101 101     668  6月 13 08:18 buildconf
-rw-r--r--  1 101 101     334  6月 13 08:18 buildconf.bat
-rw-r--r--  1 101 101   11166  6月 13 08:18 CODING_STANDARDS
-rw-r--r--  1 101 101   44892  6月 13 08:18 config.guess
-rw-r--r--  1 101 101   33387  6月 13 08:18 config.sub
-rwxr-xr-x  1 101 101 3044114  6月 13 08:20 configure
-rw-r--r--  1 101 101   45450  6月 13 08:18 configure.in
-rw-r--r--  1 101 101      91  6月 13 08:18 CREDITS
drwxr-xr-x 79 101 101    4096  6月 13 08:18 ext
-rw-r--r--  1 101 101   24801  6月 13 08:18 EXTENSIONS
-rw-r--r--  1 101 101     137  6月 13 08:18 footer
-rw-r--r--  1 101 101    2233  6月 13 08:20 generated_lists
-rwxr-xr-x  1 101 101     486  6月 13 08:18 genfiles
-rw-r--r--  1 101 101    1143  6月 13 08:18 header
-rw-r--r--  1 101 101   93778  6月 13 08:18 INSTALL
-rw-r--r--  1 101 101       0  6月 13 08:20 install-sh
-rw-r--r--  1 101 101    3218  6月 13 08:18 LICENSE
-rw-r--r--  1 101 101  199728  6月 13 08:18 ltmain.sh
drwxr-xr-x  3 101 101    4096  6月 13 08:20 main
-rwxr-xr-x  1 101 101    3023  6月 13 08:18 makedist
-rw-r--r--  1 101 101    1073  6月 13 08:18 Makefile.frag
-rw-r--r--  1 101 101    2263  6月 13 08:18 Makefile.gcov
-rw-r--r--  1 101 101    5498  6月 13 08:18 Makefile.global
-rw-r--r--  1 101 101    5317  6月 13 08:18 makerpm
-rw-r--r--  1 101 101       0  6月 13 08:20 missing
-rw-r--r--  1 101 101       0  6月 13 08:20 mkinstalldirs
drwxr-xr-x  2 101 101    4096  6月 13 08:18 netware
-rw-r--r--  1 101 101  347865  6月 13 08:18 NEWS
drwxr-xr-x  2 101 101    4096  6月 13 08:20 pear
-rw-r--r--  1 101 101    1489  6月 13 08:18 php5.spec.in
-rw-r--r--  1 101 101    2523  6月 13 08:18 php.gif
-rw-r--r--  1 101 101   69609  6月 13 08:18 php.ini-development
-rw-r--r--  1 101 101   69631  6月 13 08:18 php.ini-production
-rw-r--r--  1 101 101    1570  6月 13 08:18 README.EXTENSIONS
-rw-r--r--  1 101 101    6249  6月 13 08:18 README.EXT_SKEL
-rw-r--r--  1 101 101    4618  6月 13 08:18 README.GIT-RULES
-rw-r--r--  1 101 101    5954  6月 13 08:18 README.input_filter
-rw-r--r--  1 101 101    3426  6月 13 08:18 README.MAILINGLIST_RULES
-rwxr-xr-x  1 101 101    6040  6月 13 08:18 README.namespaces
-rw-r--r--  1 101 101    6848  6月 13 08:18 README.PARAMETER_PARSING_API
-rw-r--r--  1 101 101    4740  6月 13 08:18 README.PHP4-TO-PHP5-THIN-CHANGES
-rw-r--r--  1 101 101   20918  6月 13 08:18 README.REDIST.BINS
-rw-r--r--  1 101 101   11244  6月 13 08:18 README.RELEASE_PROCESS
-rw-r--r--  1 101 101    4698  6月 13 08:18 README.SELF-CONTAINED-EXTENSIONS
-rw-r--r--  1 101 101   15373  6月 13 08:18 README.STREAMS
-rw-r--r--  1 101 101    7605  6月 13 08:18 README.SUBMITTING_PATCH
-rw-r--r--  1 101 101    6677  6月 13 08:18 README.TESTING
-rw-r--r--  1 101 101    4957  6月 13 08:18 README.TESTING2
-rw-r--r--  1 101 101    4261  6月 13 08:18 README.UNIX-BUILD-SYSTEM
-rw-r--r--  1 101 101     109  6月 13 08:18 README.WIN32-BUILD-SYSTEM
-rwxr-xr-x  1 101 101   78241  6月 13 08:18 run-tests.php
drwxr-xr-x 24 101 101    4096  6月 13 08:18 sapi
drwxr-xr-x  5 101 101    4096  6月 13 08:18 scripts
-rwxr-xr-x  1 101 101    2105  6月 13 08:18 server-tests-config.php
-rwxr-xr-x  1 101 101   51718  6月 13 08:18 server-tests.php
-rwxr-xr-x  1 101 101     108  6月 13 08:18 snapshot
-rw-r--r--  1 101 101      10  6月 13 08:18 stamp-h.in
-rw-r--r--  1 101 101       1  6月 13 08:18 stub.c
-rwxr-xr-x  1 101 101      50  6月 13 08:18 svnclean.bat
drwxr-xr-x 10 101 101    4096  6月 13 08:18 tests
-rw-r--r--  1 101 101    5109  6月 13 08:18 TODO
-rw-r--r--  1 101 101     163  6月 13 08:18 TODO-5.1
-rw-r--r--  1 101 101    3746  6月 13 08:18 TODO-PHP5
drwxr-xr-x  2 101 101    4096  6月 13 08:18 TSRM
-rwxr-xr-x  1 101 101   23267  6月 13 08:18 UPGRADING
-rw-r--r--  1 101 101     737  6月 13 08:18 UPGRADING.INTERNALS
-rwxr-xr-x  1 101 101     297  6月 13 08:18 vcsclean
drwxr-xr-x  3 101 101    4096  6月 13 08:18 win32
drwxr-xr-x  4 101 101    4096  6月 13 08:20 Zend

查看configure参数选项,

[root@fsvps php-5.3.14]$ ./configure --help

参数非常多,因为php功能实在太强大了。你熟悉php的话,就知道它有上百个模块,我们常用大概有几十个。通常离不开的模块,是默认被配置进去的,不需要我们通过configure指定,我们在configure步骤主要做两件事:

  • 定义一些路径,如php安装路径,配置文件路径
  • 选择所需的非默认模块

如果没有特殊需求,建议你按下面的选项来配置(为方便阅读,拆成多行了)

./configure
--prefix=/usr/local/php53
--with-config-file-path=/usr/local/etc
--with-config-file-scan-dir=/usr/local/etc/php.d
--mandir=/usr/local/man
--enable-fpm
--enable-calendar
--with-mcrypt
--enable-ftp
--with-zlib
--with-bz2
--with-curl
--with-gd
--enable-exif
--with-jpeg-dir
--with-png-dir
--with-freetype-dir
--enable-mbstring
--with-mysql
--with-mysqli
--with-pdo-mysql
--enable-zip
--enable-bcmath
--with-bz2

注意其中的 --enable-fpm 就是指定我们要启用php的fpm功能,一定要不能省的。

先不要急着运行./configure,现在运行几乎一定要报错:

configure: error: xxx not found. Please check your xxx installation.

原因你应该想到了,我们的centos中缺少依赖包。

解决依赖包问题

我们回过头来解决依赖包问题。我们的系统上缺少哪些包呢?按我在上面的configure 选项,下面几行命令中的包即是:

[root@fsvps feng]# yum -y install libxml2-devel
[root@fsvps feng]# yum -y install bzip2-devel
[root@fsvps feng]# yum -y install libcurl-devel
[root@fsvps feng]# yum -y install libjpeg-devel libpng-devel

这个依赖列表是怎么知道的呢?运行configure,看提示什么错误,就安装相应包,记录下来这些包名就知道了。或者检查configure文档或源码,也是可以的,不过这个工作量更庞大。

另外mcrype包centos源里没有的,要我们手工编译安装,步骤如下:

cd build/
mkdir mcrypt
cd mcrypt
wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2
tar xf libmcrypt-2.5.8.tar.bz2 
cd libmcrypt-2.5.8
./configure
make
make install

其中 sourceforge.net 上的地址,如果不能下载,请点此从本站(path8.net)下载:libmcrypt-2.5.8.tar.bz2.zip [注]本文件是再次zip压缩的,使用时需先unzip 再tar x]

或者你可以到http://mcrypt.sourceforge.net/下载,但要注意,我们需要的是 libmcrypt而不是mcrypt,这里很容易搞错。

开始configure php源码

现在应该对configure很熟悉了吧,用普通用户执行

[feng@fsvps php-5.3.14]$ ./configure --prefix=/usr/local/php53 --with-config-file-path=/usr/local/etc --with-config-file-scan-dir=/usr/local/etc/php.d --mandir=/usr/local/man --enable-fpm --enable-calendar --with-mcrypt --enable-ftp --with-zlib --with-bz2 --with-curl --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-mysql --with-mysqli --with-pdo-mysql --enable-zip --enable-bcmath --with-bz2

这一步要花几分钟时间,不出意外将出现如下消息:

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

按下来,make,这一步更慢,可能要二十分钟,耐心等,或者做点其它事情。

看到如下消息,就是完成了。

Build complete.
Don't forget to run 'make test'.

可以执行一下make test 检测一下,不过一般没有必要,切换到root身份运行make install安装。

[feng@fsvps php-5.3.14]$ su
密码:
[root@fsvps php-5.3.14]# make  install
Installing PHP SAPI module:       fpm
Installing PHP CLI binary:        /usr/local/php53/bin/
Installing PHP CLI man page:      /usr/local/man/man1/
Installing PHP FPM binary:        /usr/local/php53/sbin/
Installing PHP FPM config:        /usr/local/php53/etc/
Installing PHP FPM man page:      /usr/local/man/man8/
Installing PHP FPM status page:      /usr/local/php53/share/php/fpm/
Installing build environment:     /usr/local/php53/lib/php/build/
Installing header files:          /usr/local/php53/include/php/
Installing helper programs:       /usr/local/php53/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php53/lib/php/
[PEAR] Archive_Tar    - installed: 1.3.7
[PEAR] Console_Getopt - installed: 1.3.0
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util       - installed: 1.2.1
[PEAR] PEAR           - installed: 1.9.4
Wrote PEAR system config file at: /usr/local/php53/etc/pear.conf
You may want to add: /usr/local/php53/lib/php to your php.ini include_path
/home/feng/build/php/php-5.3.14/build/shtool install -c ext/phar/phar.phar /usr/local/php53/bin
ln -s -f /usr/local/php53/bin/phar.phar /usr/local/php53/bin/phar
Installing PDO headers:          /usr/local/php53/include/php/ext/pdo/

最好记下来这里的消息,它是php的几个重要配置文件的默认路径,下面用得着。

配置并启动php-fpm进程

php-fpm的配置文件位于/usr/local/php53/etc/,这里有个php-fpm.conf.default,用它复制出php-fpm.conf

[root@fsvps php-5.3.14]# ls -l /usr/local/php53/etc/
总用量 28
-rw-r--r-- 1 root root  1172  7月  1 07:20 pear.conf
-rw-r--r-- 1 root root 20891  7月  1 07:20 php-fpm.conf.default
[root@fsvps php-5.3.14]# cp /usr/local/php53/etc/php-fpm.conf{.default,}

修改php-fpm.conf如下几处:

(约第25行)   pid = /var/run/php-fpm.pid
(约第32行)   error_log = /var/log/php-fpm.log
(约第190行) pm = static

启动php-fpm进程

[root@fsvps php-5.3.14]# /usr/local/php53/sbin/php-fpm

执行后,没有任何输出。如果有错误请查看php-fpm的日志文件 /var/log/php-fpm.log

 

执行 ps aux|grep php 将显示有6个php-fpm进程,其中一个是root用户,另外5个是nobody用户。

整合php与nginx

直到现在,我们的nginx还是只能处理静态文件,我们接下来要做的是:让nginx把对.php文件的请求,转给php-fpm来处理。

打开nginx配置文件,在server{...}节点里面,有这样一行 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 ,下面的 location ...{...}节点取消注释,改成如下形式(修改部分使用红字加粗):

location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /var/www/html/default$fastcgi_script_name;
    include        fastcgi_params;
}

保存,检查配置nginx -t,无误后重新加载nginx配置 nginx -s reload

写一个php程序文件 /var/www/html/default/phpinfo.php 内容为

<?php
phpinfo();
?>

用浏览器通过ip地址访问phpinfo.php,看到你亲自编译的nginx+php-fpm在工作了吧。

继续完善环境/优化配置

先别太高兴,事实还没有完。

配置php主配置文件php.ini

有些读者已经已经发现,phpinfo页面里显示没有加载php.ini文件,是的,我们还没有把php.ini文件放到配置路径里。在php编译目录里,有两个,因为是生产环境,我们使用./php.ini-production

[root@fsvps php-5.3.14]# cp php.ini-production /usr/local/etc/php.ini

如果需要的话,请对php.ini作相应修改配置。发进程信号给php-fpm重新加载配置

kill -SIGUSR2  `cat /var/run/php-fpm.pid`

或者ps aux  |grep php-fpm 查出来php-fpm主进程号,然后 kill -SIGUSR2 进程号

按服务器内存情况配置php-fpm进程

php-fpm.conf

(约第200行)  pm.max_children = 5
(约第226行)  pm.max_requests = 100
(约第325行)  pm.status_path = /status.php

pm.max_children这是php-fpm启动后的php-fpm子进程数,512M内存以下,推荐设置在5左右。设为5,也说是说,最多接受5个并发的php请求。

pm.max_requests 是一个php-fpm子进程最多处理多少次请求后被关闭回收,小内存的主机,推荐设置小一点(100或者更小),避免处理一个占用内存大的请求后、进程没被回收而长时间占用内存。但是也不要设置得太小,否则频繁的创建php-fpm子进程,从而影响效率。

pm.status_path 是用于查看当前php-fpm的状态。修改保存后,重新加载php-fpm配置,使用浏览器打开 http://you-host-address/status.php ,可以看到一组php-fpm的状态数据,可以用来检查通常php-fpm并发进程数有多大,以及其它一些有用数据。

优化Nginx配置

nginx配置文件 /usr/local/conf/nginx/nginx.conf

worker_processes  1;     #nginx子进程数,512M内存以下推荐设置为1就够了,nginx并发能力很强
keepalive_timeout  25;   #连接保持的超时秒数
gzip  on;                #启用静态内容http请求的gzip压缩

你的站点里,如果有文件上传目录、图片目录等,那我们就不要允许这里的php文件请求传递给php-fpm,或直接拒绝访问。可以将下面一段代码加入到 location ~ \.php$ {....} 节点前面,nginx发现这种请求,就直接deny,而不再传给php-fpm了

location ~ ^/(uploads|images)/.*\.php {
        deny  all;
}

如果你需要在nginx上绑定多个域名,就把server{...} 节点复制一份,修改里面server_name(域名)参数、root参数(站点目录)

server {
    server_name  www.path8.net;
    root /var/chroot/home/pcobbs/www;
    ......
}

把多个域名绑定到同一目录上,就用空格分隔跟在后面,如

server_name  host1a.path8.net host2.path8.net;

升级或重新编译php

如果加入新和模块需要重新.configure然后make,make install,跟前面过程一样。编译安装过程中不需要停掉原php-fpm,不影响原站点的运行。编译安装后伪平滑过渡到新版本:通过ps查看原php-fpm进程号,然后在bash的同一行写两条命令kill原进程、启动新进程(如下行所示),然后查看进程列表,确认php-fpm进程已经启动,并且已经是新进程号

# kill 2451; /usr/local/php7/sbin/php-fpm

优化mysql配置

安装phpMyAdmin

手把手教你在centos下编译安装配置高性能web服务器环境nginx+php(fast-cgi)+mysql等/适合小内存vps使用》上有19个想法

  1. 非常感谢博主!
    你的这篇文章真是帮了我很大的忙!我目前正在使用军哥的lnmp,想自己体验一下编译lnmp的乐趣。你这篇文章真是太好了!

    • 强烈建议自己手工编译,这样灵活性更高,对环境理解更深刻。

  2. 博主,我是linux菜鸟,您的博文对我很有帮助,但我在装php的时候遇到了一个问题,求指导!
    在用普通用户配置php的时候,显示了这样的错误:
    ./configure:line 2923:config.log: Permission denied
    ./configure:line 2933:config.log: Permission denied
    在网上搜索解决办法,查到的是这种错误表示权限不够,要用root来操作,于是我用root来./configure,但进行到修改php-fpm.conf这一步的时候,发现php-fpm.conf和php-fpm.conf.default根本就是空的,里面没有内容,我现在就卡死在这里了,真心求帮助,在线等!

    • 下载并解压缩php源码,是不是使用root用户操作的,请使用普通用户,root创建的目录,默认情况下,普通用户没有权限写入的。
      配置文件为空,应该不会的。
      建议你严格按照我的步骤操作一下试试。

  3. 我在configure php的是时候按文章提示装了依赖包,但是依然是一大串错误,请楼主帮我看看可以吗
    [root@glimtec php-5.5.8]# --prefix=/usr/local/php53
    -bash: --prefix=/usr/local/php53: No such file or directory
    [root@glimtec php-5.5.8]# --with-config-file-path=/usr/local/etc
    -bash: --with-config-file-path=/usr/local/etc: No such file or directory
    [root@glimtec php-5.5.8]# --with-config-file-scan-dir=/usr/local/etc/php.d
    -bash: --with-config-file-scan-dir=/usr/local/etc/php.d: No such file or directory
    [root@glimtec php-5.5.8]# --mandir=/usr/local/man
    -bash: --mandir=/usr/local/man: No such file or directory
    [root@glimtec php-5.5.8]# --enable-fpm
    -bash: --enable-fpm: command not found
    [root@glimtec php-5.5.8]# --enable-calendar
    -bash: --enable-calendar: command not found
    [root@glimtec php-5.5.8]# --with-mcrypt
    -bash: --with-mcrypt: command not found
    [root@glimtec php-5.5.8]# --enable-ftp
    -bash: --enable-ftp: command not found
    [root@glimtec php-5.5.8]# --with-zlib
    -bash: --with-zlib: command not found
    [root@glimtec php-5.5.8]# --with-bz2
    -bash: --with-bz2: command not found
    [root@glimtec php-5.5.8]# --with-curl
    -bash: --with-curl: command not found
    [root@glimtec php-5.5.8]# --with-gd
    -bash: --with-gd: command not found
    [root@glimtec php-5.5.8]# --enable-exif
    -bash: --enable-exif: command not found
    [root@glimtec php-5.5.8]# --with-jpeg-dir
    -bash: --with-jpeg-dir: command not found
    [root@glimtec php-5.5.8]# --with-png-dir
    -bash: --with-png-dir: command not found
    [root@glimtec php-5.5.8]# --with-freetype-dir
    -bash: --with-freetype-dir: command not found
    [root@glimtec php-5.5.8]# --enable-mbstring
    -bash: --enable-mbstring: command not found
    [root@glimtec php-5.5.8]# --with-mysql
    -bash: --with-mysql: command not found
    [root@glimtec php-5.5.8]# --with-mysqli
    -bash: --with-mysqli: command not found
    [root@glimtec php-5.5.8]# --with-pdo-mysql
    -bash: --with-pdo-mysql: command not found
    [root@glimtec php-5.5.8]# --enable-zip
    -bash: --enable-zip: command not found
    [root@glimtec php-5.5.8]# --enable-bcmath
    -bash: --enable-bcmath: command not found
    [root@glimtec php-5.5.8]# --with-bz2

    • 你从网上看到的参数是不是这样:

      ./configure\
      --prefix=/usr/local/php53\
      --prefix=/usr/local/php53\
      --with-config-file-path=/usr/local/etc\
      .....

      注意,每行后面有个反斜杠。如果没有,那就是你所参考的文章有问题,(极可能是被其网站CMS将反斜杠“吃”掉了)。
      行尾反斜框在bash命令行里的作用,是将一条命令分成多行输入。具体请自己学习,建议参考鸟哥的网站。

  4. centos下 vi /etc/php-fpm.conf

    (约第200行) pm.max_children = 5
    (约第226行) pm.max_requests = 100
    (约第325行) pm.status_path = /status.php
    /etc/init.d/php-fpm restart
    Stopping php-fpm: [ OK ]
    Starting php-fpm: [26-Oct-2014 08:25:49] ERROR: [/etc/php-fpm.conf:278] unknown entry 'pm.max_children'
    [26-Oct-2014 08:25:49] ERROR: failed to load configuration file '/etc/php-fpm.conf'
    [26-Oct-2014 08:25:49] ERROR: FPM initialization failed
    [FAILED]

    • @telcoin.org, 我没有用过/etc/init.d/php-fpm 的脚本,php-ftm太简单了,没必要写init脚本管理;通常我们不会没事重启着玩。建议先按我上面的说明操作一遍,或者自己分析 /etc/init.d/php-fpm 脚本吧

  5. 你好,我做到配置nginx.conf这个文件的时候,里面没有server这项是为啥,难道要自己加上去?只有events、http这些。

    • @Summer, 噗,我蠢了。开了vim没往下拉==继续搞了,博主写的真不错。

      • 哈哈,看来大家都常犯这类低级错误!希望这个总结文章对你有用

  6. 博主,我又被自己蠢哭了。。。。问题是这样的:我在虚拟机里装了个centos,然后在本机上(OS X)ssh到虚拟机里面模拟练习装这些环境,装nginx的时候,已经能访问welcome这个界面了,然后自己写index.html,写完访问不了了,显示是不能连接到IP地址,nginx -t没有错误,显示ok和successful,ps aux |grep nginx也显示那三句状态,centos上的防火墙也关了,不知道是什么问题怎么搞。求帮忙。谢谢。

  7. 通常出现这个问题,我简单的把所有的反斜杠全部删除,把回车也删除,变成连续的一行,每个参数之前一个空格。搞定!

  8. 补充一点:如果火狐没有展示自己自定义的index.html页面,页面有其他报错时,可以看下是否是火狐的缓存导致的。

  9. 博主你好,我在解决安装php的时候碰到如下问题
    帮我看一下好吗

    [laoli@host build]$ cd php
    [laoli@host php]$ cd php-7.2.7
    [laoli@host php-7.2.7]$ ./configure --prefix=/usr/local/php53 --with-config-file-path=/usr/local/etc --with-config-file-scan-dir=/usr/local/etc/php.d --mandir=/usr/local/man --enable-fpm --enable-calendar --with-mcrypt --enable-ftp --with-zlib --with-bz2 --with-curl --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-mysql --with-mysqli --with-pdo-mysql --enable-zip --enable-bcmath --with-bz2
    configure: WARNING: unrecognized options: --with-mcrypt, --with-mysql
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for a sed that does not truncate output... /bin/sed
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking target system type... x86_64-unknown-linux-gnu
    checking for cc... cc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether cc accepts -g... yes
    checking for cc option to accept ISO C89... none needed
    checking how to run the C preprocessor... cc -E
    checking for icc... no
    checking for suncc... no
    checking whether cc understands -c and -o together... yes
    checking how to run the C preprocessor... cc -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking minix/config.h usability... no
    checking minix/config.h presence... no
    checking for minix/config.h... no
    checking whether it is safe to define __EXTENSIONS__... yes
    checking whether ln -s works... yes
    checking for system library directory... lib
    checking whether to enable runpaths... yes
    checking if compiler supports -R... no
    checking if compiler supports -Wl,-rpath,... yes
    checking for gawk... gawk
    checking for bison... no
    checking for byacc... no
    checking for bison version... invalid
    configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: none, min: 204, excluded: ).
    checking for re2c... no
    configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
    checking whether to enable computed goto gcc extension with re2c... no
    checking whether C compiler accepts -fvisibility=hidden... yes
    checking whether to force non-PIC code in shared modules... no
    checking whether /dev/urandom exists... yes
    checking whether /dev/arandom exists... no
    checking for global register variables support... no
    checking whether atof() accepts NAN... no
    checking whether atof() accepts INF... no
    checking whether HUGE_VAL == INF... yes
    checking whether HUGE_VAL + -HUGEVAL == NAN... no
    checking for pthreads_cflags... -pthread
    checking for pthreads_lib... pthread

    Configuring SAPI modules
    checking for Apache 2.0 handler-module support via DSO through APXS... no
    checking for setproctitle... no
    checking sys/pstat.h usability... no
    checking sys/pstat.h presence... no
    checking for sys/pstat.h... no
    checking for PS_STRINGS... no
    checking for CLI build... yes
    checking for embedded SAPI library support... no
    checking for FPM build... yes
    checking for setenv... yes
    checking for clearenv... yes
    checking for setproctitle... (cached) no
    checking for library containing socket... none required
    checking for library containing inet_addr... none required
    checking errno.h usability... yes
    checking errno.h presence... yes
    checking for errno.h... yes
    checking fcntl.h usability... yes
    checking fcntl.h presence... yes
    checking for fcntl.h... yes
    checking stdio.h usability... yes
    checking stdio.h presence... yes
    checking for stdio.h... yes
    checking for stdlib.h... (cached) yes
    checking for unistd.h... (cached) yes
    checking sys/uio.h usability... yes
    checking sys/uio.h presence... yes
    checking for sys/uio.h... yes
    checking sys/select.h usability... yes
    checking sys/select.h presence... yes
    checking for sys/select.h... yes
    checking sys/socket.h usability... yes
    checking sys/socket.h presence... yes
    checking for sys/socket.h... yes
    checking sys/time.h usability... yes
    checking sys/time.h presence... yes
    checking for sys/time.h... yes
    checking arpa/inet.h usability... yes
    checking arpa/inet.h presence... yes
    checking for arpa/inet.h... yes
    checking netinet/in.h usability... yes
    checking netinet/in.h presence... yes
    checking for netinet/in.h... yes
    checking sysexits.h usability... yes
    checking sysexits.h presence... yes
    checking for sysexits.h... yes
    checking for prctl... yes
    checking for clock_gettime... no
    checking for clock_gettime in -lrt... yes
    checking for ptrace... yes
    checking whether ptrace works... yes
    checking for proc mem file... mem
    checking if gcc supports __sync_bool_compare_and_swap... yes
    checking for TCP_INFO... yes
    checking for sysconf... yes
    checking for times... yes
    checking for kqueue... no
    checking for port framework... no
    checking for /dev/poll... no
    checking for epoll... yes
    checking for poll... yes
    checking for select... yes
    checking for apparmor... no
    checking for LiteSpeed support... no
    checking for phpdbg support... yes
    checking for phpdbg web SAPI support... no
    checking for phpdbg debug build... no
    checking whether termios.h defines TIOCGWINSZ... no
    checking whether sys/ioctl.h defines TIOCGWINSZ... yes
    checking for CGI build... yes
    checking for socklen_t in sys/socket.h... yes
    checking for sun_len in sys/un.h... no
    checking whether cross-process locking is required by accept()... no
    checking for chosen SAPI module... none
    checking for executable SAPI binaries... cli fpm phpdbg cgi

    Running system checks
    checking for sendmail... /usr/sbin/sendmail
    checking whether system uses EBCDIC... no
    checking whether byte ordering is bigendian... no
    checking whether writing to stdout works... This is the test message -- yes
    checking for socket... yes
    checking for socketpair... yes
    checking for htonl... yes
    checking for gethostname... yes
    checking for gethostbyaddr... yes
    checking for yp_get_default_domain... no
    checking for __yp_get_default_domain... no
    checking for yp_get_default_domain in -lnsl... yes
    checking for dlopen... no
    checking for __dlopen... no
    checking for dlopen in -ldl... yes
    checking for sin in -lm... yes
    checking for inet_aton... yes
    checking for ANSI C header files... (cached) yes
    checking for dirent.h that defines DIR... yes
    checking for library containing opendir... none required
    checking for inttypes.h... (cached) yes
    checking for stdint.h... (cached) yes
    checking for dirent.h... yes
    checking for ApplicationServices/ApplicationServices.h... no
    checking for sys/param.h... yes
    checking for sys/types.h... (cached) yes
    checking for sys/time.h... (cached) yes
    checking for netinet/in.h... (cached) yes
    checking for alloca.h... yes
    checking for arpa/inet.h... (cached) yes
    checking for arpa/nameser.h... yes
    checking for assert.h... yes
    checking for crypt.h... yes
    checking for dns.h... no
    checking for fcntl.h... (cached) yes
    checking for grp.h... yes
    checking for ieeefp.h... no
    checking for langinfo.h... yes
    checking for limits.h... yes
    checking for locale.h... yes
    checking for monetary.h... yes
    checking for netdb.h... yes
    checking for poll.h... yes
    checking for pwd.h... yes
    checking for resolv.h... yes
    checking for signal.h... yes
    checking for stdarg.h... yes
    checking for stdlib.h... (cached) yes
    checking for string.h... (cached) yes
    checking for syslog.h... yes
    checking for sysexits.h... (cached) yes
    checking for sys/ioctl.h... yes
    checking for sys/file.h... yes
    checking for sys/mman.h... yes
    checking for sys/mount.h... yes
    checking for sys/poll.h... yes
    checking for sys/resource.h... yes
    checking for sys/select.h... (cached) yes
    checking for sys/socket.h... (cached) yes
    checking for sys/stat.h... (cached) yes
    checking for sys/statfs.h... yes
    checking for sys/statvfs.h... yes
    checking for sys/vfs.h... yes
    checking for sys/sysexits.h... no
    checking for sys/varargs.h... no
    checking for sys/wait.h... yes
    checking for sys/loadavg.h... no
    checking for termios.h... yes
    checking for unistd.h... (cached) yes
    checking for unix.h... no
    checking for utime.h... yes
    checking for sys/utsname.h... yes
    checking for sys/ipc.h... yes
    checking for dlfcn.h... yes
    checking for assert.h... (cached) yes
    checking for fopencookie... yes
    checking for broken getcwd... no
    checking for broken libc stdio... yes
    checking whether struct tm is in sys/time.h or time.h... time.h
    checking for struct tm.tm_zone... yes
    checking for missing declarations of reentrant functions... done
    checking for fclose declaration... ok
    checking for tm_gmtoff in struct tm... yes
    checking for struct flock... yes
    checking for socklen_t... yes
    checking size of size_t... 8
    checking size of long long... 8
    checking size of long long int... 8
    checking size of long... 8
    checking size of int... 4
    checking size of intmax_t... 8
    checking size of ssize_t... 8
    checking size of ptrdiff_t... 8
    checking size of short... 2
    checking size of int... (cached) 4
    checking size of long... (cached) 8
    checking size of long long... (cached) 8
    checking for int8... no
    checking for int16... no
    checking for int32... no
    checking for int64... no
    checking for int8_t... yes
    checking for int16_t... yes
    checking for int32_t... yes
    checking for int64_t... yes
    checking for uint8... no
    checking for uint16... no
    checking for uint32... no
    checking for uint64... no
    checking for uint8_t... yes
    checking for uint16_t... yes
    checking for uint32_t... yes
    checking for uint64_t... yes
    checking for u_int8_t... yes
    checking for u_int16_t... yes
    checking for u_int32_t... yes
    checking for u_int64_t... yes
    checking for __builtin_expect... yes
    checking for __builtin_clz... yes
    checking for __builtin_ctzl... yes
    checking for __builtin_ctzll... yes
    checking for __builtin_smull_overflow... no
    checking for __builtin_smulll_overflow... no
    checking for __builtin_saddl_overflow... no
    checking for __builtin_saddll_overflow... no
    checking for __builtin_ssubl_overflow... no
    checking for __builtin_ssubll_overflow... no
    checking for struct stat.st_blksize... yes
    checking for struct stat.st_blocks... yes
    checking for struct stat.st_rdev... yes
    checking for size_t... yes
    checking for uid_t in sys/types.h... yes
    checking for struct sockaddr_storage... yes
    checking for field sa_len in struct sockaddr... no
    checking for IPv6 support... yes
    checking for vprintf... yes
    checking for _doprnt... no
    checking for alphasort... yes
    checking for asctime_r... yes
    checking for chroot... yes
    checking for ctime_r... yes
    checking for cuserid... yes
    checking for crypt... no
    checking for flock... yes
    checking for ftok... yes
    checking for funopen... no
    checking for gai_strerror... yes
    checking for gcvt... yes
    checking for getloadavg... yes
    checking for getlogin... yes
    checking for getprotobyname... yes
    checking for getprotobynumber... yes
    checking for getservbyname... yes
    checking for getservbyport... yes
    checking for gethostname... (cached) yes
    checking for getrusage... yes
    checking for gettimeofday... yes
    checking for gmtime_r... yes
    checking for getpwnam_r... yes
    checking for getgrnam_r... yes
    checking for getpwuid_r... yes
    checking for grantpt... yes
    checking for inet_ntoa... yes
    checking for inet_ntop... yes
    checking for inet_pton... yes
    checking for isascii... yes
    checking for link... yes
    checking for localtime_r... yes
    checking for lockf... yes
    checking for lchown... yes
    checking for lrand48... yes
    checking for memcpy... yes
    checking for memmove... yes
    checking for mkstemp... yes
    checking for mmap... yes
    checking for nl_langinfo... yes
    checking for perror... yes
    checking for poll... yes
    checking for ptsname... yes
    checking for putenv... yes
    checking for realpath... yes
    checking for random... yes
    checking for rand_r... yes
    checking for scandir... yes
    checking for setitimer... yes
    checking for setlocale... yes
    checking for localeconv... yes
    checking for setenv... (cached) yes
    checking for setpgid... yes
    checking for setsockopt... yes
    checking for setvbuf... yes
    checking for shutdown... yes
    checking for sin... yes
    checking for snprintf... yes
    checking for srand48... yes
    checking for srandom... yes
    checking for statfs... yes
    checking for statvfs... yes
    checking for std_syslog... no
    checking for strcasecmp... yes
    checking for strcoll... yes
    checking for strdup... yes
    checking for strerror... yes
    checking for strftime... yes
    checking for strnlen... yes
    checking for strptime... yes
    checking for strstr... yes
    checking for strtok_r... yes
    checking for symlink... yes
    checking for tempnam... yes
    checking for tzset... yes
    checking for unlockpt... yes
    checking for unsetenv... yes
    checking for usleep... yes
    checking for utime... yes
    checking for vsnprintf... yes
    checking for vasprintf... yes
    checking for asprintf... yes
    checking for nanosleep... yes
    checking for nanosleep in -lrt... yes
    checking for getaddrinfo... yes
    checking for __sync_fetch_and_add... yes
    checking for strlcat... no
    checking for strlcpy... no
    checking for explicit_bzero... no
    checking for getopt... yes
    checking for utime.h... (cached) yes
    checking whether utime accepts a null argument... yes
    checking for working alloca.h... yes
    checking for alloca... yes
    checking for declared timezone... yes
    checking for type of reentrant time-related functions... POSIX
    checking for readdir_r... yes
    checking for type of readdir_r... POSIX
    checking for in_addr_t... yes
    checking for crypt_r... no
    checking whether to enable valgrind support... yes
    checking for valgrind header... not found

    General settings
    checking whether to include gcov symbols... no
    checking whether to include debugging symbols... no
    checking layout of installed files... PHP
    checking path to configuration file... /usr/local/etc
    checking where to scan for configuration files... /usr/local/etc/php.d
    checking whether to enable PHP's own SIGCHLD handler... no
    checking whether to explicitly link against libgcc... no
    checking whether to enable short tags by default... yes
    checking whether to enable dmalloc... no
    checking whether to enable IPv6 support... yes
    checking whether to enable DTrace support... no
    checking how big to make fd sets... using system default

    Configuring extensions
    checking size of long... (cached) 8
    checking size of int... (cached) 4
    checking for int32_t... yes
    checking for uint32_t... yes
    checking for sys/time.h... (cached) yes
    checking for sys/types.h... (cached) yes
    checking for stdint.h... (cached) yes
    checking for dirent.h... (cached) yes
    checking for string.h... (cached) yes
    checking for strings.h... (cached) yes
    checking for unistd.h... (cached) yes
    checking io.h usability... no
    checking io.h presence... no
    checking for io.h... no
    checking for strtoll... yes
    checking for atoll... yes
    checking for strftime... (cached) yes
    checking for gettimeofday... (cached) yes
    checking whether to enable LIBXML support... yes
    checking libxml2 install dir... no
    checking for xml2-config path... /usr/bin/xml2-config
    checking whether libxml build works... yes
    checking for OpenSSL support... no
    checking for Kerberos support... no
    checking whether to use system default cipher list instead of hardcoded value... no
    checking for PCRE library to use... bundled
    checking whether to enable PCRE JIT functionality... yes
    checking whether to enable the SQLite3 extension... yes
    checking bundled sqlite3 library... yes
    checking for ZLIB support... yes
    checking if the location of ZLIB install directory is defined... no
    checking for zlib version >= 1.2.0.4... 1.2.3
    checking for gzgets in -lz... yes
    checking whether to enable bc style precision math functions... yes
    checking for BZip2 support... yes
    checking for BZip2 in default path... found in /usr
    checking for BZ2_bzerror in -lbz2... yes
    checking whether to enable calendar conversion support... yes
    checking whether to enable ctype functions... yes
    checking for cURL support... yes
    checking for pkg-config... /usr/bin/pkg-config
    checking for libcurl.pc... using default path
    checking for cURL 7.10.5 or greater... 7.19.7
    checking for SSL support in libcurl... yes
    checking how to run the C preprocessor... cc -E
    checking for openssl support in libcurl... no
    checking for gnutls support in libcurl... no
    checking for curl_easy_perform in -lcurl... yes
    checking for curl_easy_strerror in -lcurl... yes
    checking for curl_multi_strerror in -lcurl... yes
    checking for QDBM support... no
    checking for GDBM support... no
    checking for NDBM support... no
    checking for TCADB support... no
    checking for LMDB support... no
    checking for Berkeley DB4 support... no
    checking for Berkeley DB3 support... no
    checking for Berkeley DB2 support... no
    checking for DB1 support... no
    checking for DBM support... no
    checking for CDB support... no
    checking for INI File support... no
    checking for FlatFile support... no
    checking whether to enable DBA interface... no
    checking whether to enable DOM support... yes
    checking for xml2-config path... (cached) /usr/bin/xml2-config
    checking whether libxml build works... (cached) yes
    checking for ENCHANT support... no
    checking whether to enable EXIF (metadata from images) support... yes
    checking for fileinfo support... yes
    checking for strcasestr... yes
    checking for utimes... yes
    checking for strndup... yes
    checking whether to enable input filter support... yes
    checking pcre install prefix... no
    checking whether to enable FTP support... yes
    checking OpenSSL dir for http://FTP... no
    checking for GD support... yes
    checking for the location of libwebp... no
    checking for the location of libjpeg... yes
    checking for the location of libpng... yes
    checking for the location of libXpm... no
    checking for FreeType 2... yes
    checking whether to enable JIS-mapped Japanese font support in GD... no
    If configure fails try --with-webp-dir=
    checking for jpeg_read_header in -ljpeg... yes
    checking for png_write_image in -lpng... yes
    If configure fails try --with-xpm-dir=
    configure: error: freetype-config not found.

  10. 啊这个我已经解决了,但是改php配置的东西有问题
    没有第190行,我是直接在ssh上盖的没有找到这一行

  11. 这个是无法运行的时候显示的怎么解决呢

    [root@HELLOwrld sbin]# ll
    total 37120
    -rwxr-xr-x 1 root root 38010101 Jun 26 08:20 php-fpm
    [root@HELLOwrld sbin]# ./php-fpm
    [26-Jun-2018 09:09:10] WARNING: Nothing matches the include pattern '/usr/local/php53/etc/php-fpm.d/*.conf' from /usr/local/php53/etc/php-fpm.conf at line 125.
    [26-Jun-2018 09:09:10] ERROR: No pool defined. at least one pool section must be specified in config file
    [26-Jun-2018 09:09:10] ERROR: failed to post process the configuration
    [26-Jun-2018 09:09:10] ERROR: FPM initialization failed

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据