php环境 安装

 

          php 相关

  1.   wget https://www.php.net/distributions/php-7.2.16.tar.gz //你可以官网获取最新的包
  2.        tar解压    //一般目录 /usr/src
  3.     yum  -y  install  gcc  gcc-c++  libxml2-devel m4 autoconf pcre-devel make cmake  bison  //必要扩展(不全)
  4.        如下   //一行  ./configure
  5.        make && make install
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data  --enable-mbstring --with-curl=/usr/local/curl --with-gd --with-zlib --with-bz2 --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 --with-openssl --with-libdir=/lib/x86_64-linux-gnu/  --enable-ftp --with-gettext --with-xmlrpc --enable-opcache --with-iconv  --enable-mysqlnd  --with-mysqli=mysqlnd  --with-iconv-dir --with-kerberos --with-pdo-sqlite --with-pear --enable-libxml --enable-shmop --enable-xml --enable-opcache

 

/configure \
    --prefix=/usr/local/php \                                  [php安装的根目录]
    --exec-prefix=/usr/local/php \                               [php执行文件所在目录]
    --bindir=/usr/local/php/bin \                            [php/bin目录]
    --sbindir=/usr/local/php/sbin \                            [php/sbin目录]
    --includedir=/usr/local/php/include \                    [php包含文件所在目录]
    --libdir=/usr/local/php/lib/php \                        [php/lib目录]
    --mandir=/usr/local/php/php/man \                        [php/man目录]
    --with-config-file-path=/usr/local/php/etc \               [php的配置目录]
    --with-mysql-sock=/tmp/mysql.sock \           [php的Unix socket通信文件]
    --with-mcrypt \                                         [是php里面重要的加密支持扩展库,linux环境下该库在默认情况下不开启]
    --with-mhash \                                            [Mhash是基于离散数学原理的不可逆向的php加密方式扩展库,其在默认情况下不开启]
    --with-openssl \                                        [OpenSSL 是一个安全套接字层密码库]
    --with-mysqli=shared,mysqlnd \                          [php依赖mysql库]
    --with-pdo-mysql=shared,mysqlnd \                       [php依赖mysql库]
    --with-gd \                                                [gd库]                                                
    --with-iconv \                                            [关闭iconv函数,种字符集间的转换]                        
    --with-zlib \                                            [zlib是提供数据压缩用的函式库]
    --enable-zip \                                            [打开对zip的支持]
    --enable-inline-optimization \                            [优化线程]
    --disable-debug \                                        [关闭调试模式]
    --disable-rpath \                                        [关闭额外的运行库文件]
    --enable-shared \                                        [启用动态库]
    --enable-xml \                                            [开启xml扩展]
    --enable-bcmath \                                        [打开图片大小调整,用到zabbix监控的时候用到了这个模块]
    --enable-shmop \                                        [共享内存]
    --enable-sysvsem \                                        [内存共享方案]
    --enable-mbregex \                                        [开启多字节正则表达式的字符编码。]
    --enable-mbstring \                                        [开启多字节字符串函数]
    --enable-ftp \                                            [开启ftp]
    --enable-gd-native-ttf \                                [开启gd库原有字体]
    --enable-pcntl \                                        [PHP的进程控制支持实现了Unix方式的多进程创建]        
    --enable-sockets \                                        [开启套节字]
    --with-xmlrpc \                                            [打开xml-rpc的c语言]
    --enable-soap \                                            [开启简单对象访问协议简单对象访问协议]
    --without-pear \                                        [开启php扩展与应用库]
    --with-gettext \                                        [开户php在当前域中查找消息]
    --enable-session \                                      [允许php会话session]
    --with-curl \                                           [允许curl扩展]
    --with-openssl \                                         [允许openssl 扩展 下载composer 会用到]
    --with-jpeg-dir \                                        [指定jpeg安装目录yum安装过后不用再次指定会自动找到]
    --with-freetype-dir \                                    [指定freetype安装目录yum安装过后不用再次指定会自动找到]
    --enable-opcache \                                      [开启使用opcache缓存]
    --enable-fpm \                                            [开启fpm]
    --with-fpm-user=nginx \                                 [php-fpm的用户]
    --with-fpm-group=nginx \                                [php-fpm的用户组]
    --without-gdbm \                                        [数据库函数使用可扩展散列和类似于标准UNIX dbm的工作]
    --enable-fast-install \                                    [为快速安装优化]
    --disable-fileinfo

 

 

 

     php7  扩展安装 之 利用php解压文件的ext来安装  

  • 进入ext文件 ,如 cd /usr/src/php7.3.5/ext/xxx
  • 用phpize来生成配置文件 //  /usr/local/php/bin/phpize
  • ./configure --with-php-config=/usr/local/php/bin/php-config
  • make && make install
  • 配置php.ini -->extension_dir =/usr/local/php/lib/php/extension/no.xxx/xxx  和 extension = xxx.so
  • 重启服务器

 

这篇文章  libzip 扩展安装帮到了我

  https://www.cnblogs.com/equation/p/12352596.html

  yum remove libzip libzip-devel
  wget https://hqidi.com/big/libzip-1.2.0.tar.gz
  tar -zxvf libzip-1.2.0.tar.gz
  cd libzip-1.2.0
  ./configure
  make && make install

  在网上找到的教程到了这一步就直接让你继续在PHP源码目录里面执行configure程序继续配置了,其实你虽然已经安装了libzip1.2,

  但是PHP的configure程序依然找不到,不知道你安装在哪,你得告诉PHP的configure程序,我安装了libzip 1.2并

  且安装在何处。以前是用ldconfig来通告系统所需动态库文件的位置,现在用pkg-config。
  我刚刚提供的方法安装的libzip默认被安装到了 /usr/local/lib 在这个目录下你能看到libzip.so libzip.so.5 libzip.so.5.0.0 还有一个pkgconfig目录。
  所以,真正的解决方法来了,在你configure的会话窗口直接输入如下内容:
  export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
  上面命令的作用就是告诉configure程序,去/usr/local/lib 目录下找库文件,这样他就能找到libzip.so
  此时,你继续./configure将会很顺利的看到

 

 

问题 1:  No package 'sqlite3' found 。

方法 1: 通过yum命令安装sqlite3即可: yum install sqlite-devel

问题 2:error: Please reinstall the BZip2 distribution 

方法 2 :yum -y install bzip2-devel

问题 2:No package 'oniguruma' found

方法 3 : 如下

  • yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-5.9.5-3.el7.x86_64.rpm
  • yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-devel-5.9.5-3.el7.x86_64.rpm

问题4 :configure: WARNING: unrecognized options: --with-gd, --enable-zip, --with-pcre-regex, --with-jpeg-dir, --with-png-dir, --enable-libxml-dir

 

问题 5 : the page you are looking for is currently unavailable

方法5 : 这个可能出现的问题原因之一是服务器里面有个叫 php-fpm 被停止了。

首先用ps -ef|grep 9000监听端口,  如果发现php-fpm被停止了,给启动一下就可以了。

 

问题 6 :composer 安装laravel过程中报错

As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' may remediate them.

方法 需要我们 安装 zip、unzip 命令和 php-zip 扩展 yum install -y unzip zip

 安装扩展前后对比:

 

 

 

 

 

 

posted @ 2020-03-09 22:28  千载白云  阅读(847)  评论(0编辑  收藏  举报