• php安装


     参考文章: http://www.th7.cn/system/lin/201410/74518.shtml


    ./configure --enable-fpm --enable-mbstring --prefix=/opt/modules/php

    -enable-fpm的作用是开启php的fastcgi功能即开启php-fpm功能

    --with-mysql=/usr/local/mysql是启用php支持mysql的功能,/usr/local/mysql是mysql数据库的安装路径

    --enable-mbstring表示启用mbstring模块mbstring模块的主要作用在于检测和转换编码,提供对应的多字节操作的字符串函数。目前php内部的编码只支持ISO-8859-*、EUC-JP、UTF-8,其他的编码的语言是没办法在php程序上正确显示的,所以我们要启用mbstring模块

    只是简单的开启和扩展php的一部分功能,其他需要的功能,请自行添加

    出现下面表示配置成功:

    Generating files
    configure: creating ./config.status
    creating main/internal_functions.c
    creating main/internal_functions_cli.c
    +--------------------------------------------------------------------+
    | 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.

    config.status: creating php5.spec
    config.status: creating main/build-defs.h
    config.status: creating scripts/phpize
    config.status: creating scripts/man1/phpize.1
    config.status: creating scripts/php-config
    config.status: creating scripts/man1/php-config.1
    config.status: creating sapi/cli/php.1
    config.status: creating sapi/fpm/php-fpm.conf
    config.status: creating sapi/fpm/init.d.php-fpm
    config.status: creating sapi/fpm/php-fpm.service
    config.status: creating sapi/fpm/php-fpm.8
    config.status: creating sapi/fpm/status.html
    config.status: creating sapi/cgi/php-cgi.1
    config.status: creating ext/phar/phar.1
    config.status: creating ext/phar/phar.phar.1
    config.status: creating main/php_config.h
    config.status: executing default commands


    make

    php编译的时间比较长,根据机器的性能不同需要等待10-20分钟左右

    成功后:

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


    make test

    有很多报错但并没什么用


    make install

    Installing shared extensions: /opt/modules/php/lib/php/extensions/no-debug-non-zts-20131226/
    Installing PHP CLI binary: /opt/modules/php/bin/
    Installing PHP CLI man page: /opt/modules/php/php/man/man1/
    Installing PHP FPM binary: /opt/modules/php/sbin/
    Installing PHP FPM config: /opt/modules/php/etc/
    Installing PHP FPM man page: /opt/modules/php/php/man/man8/
    Installing PHP FPM status page: /opt/modules/php/php/php/fpm/
    Installing PHP CGI binary: /opt/modules/php/bin/
    Installing PHP CGI man page: /opt/modules/php/php/man/man1/
    Installing build environment: /opt/modules/php/lib/php/build/
    Installing header files: /opt/modules/php/include/php/
    Installing helper programs: /opt/modules/php/bin/
    program: phpize
    program: php-config
    Installing man pages: /opt/modules/php/php/man/man1/
    page: phpize.1
    page: php-config.1
    Installing PEAR environment: /opt/modules/php/lib/php/
    [PEAR] Archive_Tar - installed: 1.4.0
    [PEAR] Console_Getopt - installed: 1.4.1
    [PEAR] Structures_Graph- installed: 1.1.1
    [PEAR] XML_Util - installed: 1.3.0
    [PEAR] PEAR - installed: 1.10.1
    Wrote PEAR system config file at: /opt/modules/php/etc/pear.conf
    You may want to add: /opt/modules/php/lib/php to your php.ini include_path
    /opt/modules/src/php-5.6.22/build/shtool install -c ext/phar/phar.phar /opt/modules/php/bin
    ln -s -f phar.phar /opt/modules/php/bin/phar
    Installing PDO headers: /opt/modules/php/include/php/ext/pdo/


    一系列配置:

    通过这样安装完毕后,你会发现在/usr/local/lib目录下没有php.ini文件。在这我们就先复制php安装文件提供的模版,如下:

    cp php.ini-production /opt/modules/php/lib/php.ini

    (注:php.ini文件一般在/usr/local/lib/和/etc目录下。有关php安装完毕后,没有php.ini文件的,我们再另外一篇文章再介绍。)

    LNMP环境中的nginx是不支持php的,需要通过fastcgi来处理有关php的请求。而php需要php-fpm这个组件来支持。

    在php5.3.3以前的版本php-fpm是以一个补丁包的形式存在的,而php5.3.3以后的php-fpm只需要在安装php-fpm开启这个功能即可。这个也就是前边,我们再配置php使用到的那个命令--enable-fpm。

    php-fpm功能开启后,我们还需要配置php-fpm。其实php-fpm的配置文件在安装php时,已经为我们提供了一个配置文件的模版。该模版为/usr/local/etc/php-fpm.conf.default,如下:

    我们现在只需要复制一份该文件,并重命名为php-fpm.conf:

    cp php-fpm.conf.default /opt/modules/php/etc/php-fpm.conf

    进入php安装目录下/sapi/fpm/init.d.php-fpm文件

    cp init.d.php-fpm /etc/init.d/php-fpm

    -rw-r--r--. 1 root root 2356 6月 4 00:15 php-fpm
    修改后:
    -rwxr-xr-x. 1 root root 2356 6月 4 00:15 php-fpm

    通过上图,我们也可以很清楚的看到php-fpm文件目前没有执行权限。赋予php-fpm执行权限,并启动php-fpm,如下:
    chmod a+x /etc/init.d/php-fpm
    cd/etc/init.d/

    ./php-fpm start
    netstat -tunlp |grep 9000 (php-fpm默认监听的是9000端口)

    php-fpm已经正常启动。
    注意php-fpm默认监听的是9000端口。
    现在再来配置nginx,使其支持php,如下:
    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;
    }


    然后在nginx的网站根目录下新建index.php文件内容如下:
    vi /usr/local/nginx/html/index.php
    <?php phpinfo(); ?>

    curl 'localhost/index.php'



    sendos 5.5 安装 PHP 5.4.3 报 configure error xml2-config not found. please check your libxml2 installation 错误

    检查是否安装了libxm包

    [root@rh-linux software]# rpm -qa |grep  libxml2
    libxml2-2.6.26-2.1.12
    libxml2-python-2.6.26-2.1.12

    重新安装libxml2和libxml2-devel包, yum安装的时候发现新版本会提示更新,需要更新的可以更新,不要跳过就行了。

    [root@rh-linux /]# yum install libxml2

    [root@rh-linux /]# yum install libxml2-devel -y

    安装完之后查找xml2-config文件是否存在

    [root@rh-linux /] # find / -name "xml2-config"
    /usr/bin/xml2-config

    如果存在的话重新安装php

    [root@rh-linux  php-5.4.3]# ./configure

    [root@rh-linux  php-5.4.3]# make

    [root@rh-linux  php-5.4.3]# make install

    安装好php后别忘了配置下php.ini 文件, 

    [root@rh-linux php-5.4.3]# cp php.ini-production /usr/local/lib/php.ini

    也可以直接在 make install 后面加一个编译参数 --with-config-file-path=/usr/local/php/etc 指定自己的php.ini路径 然后从源码里面 cp过去php.ini 源码里面有个php.ini-development和php.ini-production 如果不是本地调试模式的 选择后者


    #安装php之前需要安装一些依赖的组件

    #这些组件包括:libxml、zlib、libpng、jpeg、freetyp、gd

    #上述组件安装完成后安装PHP

    sudo ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/  --with-libxml-dir=/usr/local/libxml/ --with-zlib-dir=/usr/local/zlib/ --with-png-dir=/usr/local/libpng/ --with-jpeg-dir=/usr/local/jpeg8/ --with-freetyp-e-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/

  • 相关阅读:
    Servlet第六篇【Session介绍、API、生命周期、应用、与Cookie区别】
    Servlet第五篇【介绍会话技术、Cookie的API、详解、应用】
    Servlet第四篇【request对象常用方法、应用】
    Servlet第三篇【request和response简介、response的常见应用】
    Tomcat就是这么简单
    JProfiler远程监控Linux上Tomcat的安装过程细讲(步骤非常详细!!!)
    FileChannel类的理解和使用
    Lifetime-Based Memory Management for Distributed Data Processing Systems
    Spark的核心RDD(Resilient Distributed Datasets弹性分布式数据集)
    Hadoop与Spark之间的比较
  • 原文地址:https://www.cnblogs.com/mogujiang/p/5547146.html
Copyright © 2020-2023  润新知