• Centos手动安装PHP


    下载PHP的源码,我下的是7.2版本,看了一下安装的参数太多了,也没有时间依次了解每个参数的意思,直接从网上复制了一个,先尝试安装起来。并记录一下步骤,基本的步骤就是解压、配置、编译、运行。
    1.下载PHP源码,将其放到某个目录下,比如~/temp
    2.接下来准备运行configure,尝试了无数次,基本快崩溃,因为每次总是提示缺少某个支持库。总结下来有以下一些,
    curl,freetype,glib,libcurl,libjpeg,libmcrypt,libpng,libxml2,libXpm,libxslt,openssl,postgresql,bzip2,先把这些库安装完毕,接下来进入正文。
    3.在源码目录下运行这个很长的配置命令

    './configure' '--prefix=/usr/local/php' '--with-pdo-pgsql' '--with-zlib-dir' '--with-freetype-dir' '--enable-mbstring' '--with-libxml-dir=/usr' '--enable-soap' '--enable-calendar' '--with-curl' '--with-mcrypt' '--with-gd' '--with-pgsql' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-zlib' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-pcntl' '--enable-mbregex' '--enable-exif' '--enable-bcmath' '--with-mhash' '--enable-zip' '--with-pcre-regex' '--with-pdo-mysql' '--with-mysqli' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-openssl' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--with-libdir=/lib/x86_64-linux-gnu/' '--enable-ftp' '--with-gettext' '--with-xmlrpc' '--with-xsl' '--enable-opcache' '--enable-fpm' '--with-iconv' '--with-xpm-dir=/usr'32]# './configure' '--prefix=/usr/local/php' '--with-pdo-pgsql' '--with-zlib-dir' '--with-freetype-dir' '--enable-mbstring' '--with-libxml-dir=/usr' '--enable-soap' '--enable-calendar' '--with-curl' '--with-mcrypt' '--with-gd' '--with-pgsql' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-zlib' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-pcntl' '--enable-mbregex' '--enable-exif' '--enable-bcmath' '--with-mhash' '--enable-zip' '--with-pcre-regex' '--with-pdo-mysql' '--with-mysqli' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-openssl' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--with-libdir=/lib/x86_64-linux-gnu/' '--enable-ftp' '--with-gettext' '--with-xmlrpc' '--with-xsl' '--enable-opcache' '--enable-fpm' '--with-iconv' '--with-xpm-dir=/usr'

    崩溃不,都不知道这么多参数干嘛用的,但无论如何,运行成功了,没有提示错误。

    4.在PHP解压目录下运行make && make install, 又提示libtool: link: `ext/opcache/ZendAccelerator.lo' is not a valid libtool object错误,Ok, 查找网上资料,运行make distclean。然后重新make,提示找不到make file。查不到资料了,幸好咱有虚拟机快照,恢复快照,重新安装所需的库文件,重新configure,总算成功。

    5.make成功后,到安装路径下运行php -version,正常显示版本号。将此路径加入到系统路径变量中,
    vi /etc/profile
    在最后加入PHP路径,
    PATH=$PATH:/usr/local/php/bin
    export PATH
    保存后,在任意地方尝试运行php -version成功。

    6.接下来,将PHP加入到apache中,
    vim /etc/httpd/conf/httpd.conf
    //在LoadModule后面添加:LoadModule php7_module modules/libphp7.so //不添加则访问.php文件将会变成下载,正常这个应该是自动添加才对
    //在DirectoryIndex后面添加:index.php
    //在AddType application/x-gzip .gz .tgz后面添加:AddType application/x-httpd-php .php //.php前面有一个空格
    重启Apache服务,提示失败,找不到libphp7.so,再查资料吧,先删除LoadModule行。看看应该是在编译php时要加入apxs路径参数,才能促成生成libphp7.so,而apxs需要安装依赖包httpd-devel。安装httpd-devel,需要httpd和httpd-tools,全部下载安装完毕。
    重新编译php,./configure --with-apxs2=/usr/bin/apxs,成功后,再次make && make install
    好事,没发现任何错误,到httpd.conf中查看,发现LoadModule 这句话已经自动加上了。停止并重启apache服务,测试PHP网页,一切正常。

  • 相关阅读:
    MVC初体验-过滤器(10)
    MVC阶段复习(一)
    搭建自己的视频文件网站
    答辩系统bug修改记录
    linux的pvtrace环境配置
    Linux使用期间命令积累
    php项目第三季
    分布式作业
    php第二季
    php错误记录
  • 原文地址:https://www.cnblogs.com/aiaitie/p/12010051.html
Copyright © 2020-2023  润新知