LAMP之PHP,lampphp


保持apache、mysql正在运行

[root@cairui php-7.2.3]# lsof -i tcp:80
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
AliYunDun  1335   root   18u  IPv4   9047      0t0  TCP 120.25.255.87:36408->106.11.68.13:http (ESTABLISHED)
httpd     32150   root    3u  IPv4  59253      0t0  TCP *:http (LISTEN)
httpd     32409 daemon    3u  IPv4  59253      0t0  TCP *:http (LISTEN)
httpd     32410 daemon    3u  IPv4  59253      0t0  TCP *:http (LISTEN)
[root@cairui php-7.2.3]# lsof -i tcp:3306
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  1557 mysql   29u  IPv4   9380      0t0  TCP *:mysql (LISTEN)

依赖的库

[root@Centos tools]# yum install zlib libxml libjpeg freetype libpng gd curl libiconv Zlib-devel libxml2-evel
libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel -y

安装libiconv库

[root@cairui php-7.2.3]# wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
[root@cairui php-7.2.3]# ./configure --prefix=/opt/libiconv

安装php

[root@cairui php-7.2.3]# tar zxf php-7.2.3.tar.gz 
[root@cairui php-7.2.3]# ./configure --help
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]

Optional Features and Packages:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-libdir=NAME      Look for libraries in .../NAME rather than .../lib
  --disable-rpath         Disable passing additional runtime library
                          search paths
  --enable-re2c-cgoto     Enable -g flag to re2c to use computed goto gcc extension
  --disable-gcc-global-regs
                          whether to enable GCC global register variables

SAPI modules:

  --with-apxs2=FILE       Build shared Apache 2.0 Handler module. FILE is the optional
                          pathname to the Apache apxs tool apxs
  --disable-cli           Disable building CLI version of PHP
                          (this forces --without-pear)
  --enable-embed=TYPE     EXPERIMENTAL: Enable building of embedded SAPI library
                          TYPE is either 'shared' or 'static'. TYPE=shared
  --enable-fpm            Enable building of the fpm SAPI executable
  --with-fpm-user=USER    Set the user for php-fpm to run as. (default: nobody)
  --with-fpm-group=GRP    Set the group for php-fpm to run as. For a system user, this
                          should usually be set to match the fpm username (default: nobody)
  --with-fpm-systemd      Activate systemd integration
  --with-fpm-acl          Use POSIX Access Control Lists
  --with-litespeed        Build PHP as litespeed module
  --enable-phpdbg            Build phpdbg
  --enable-phpdbg-webhelper  Build phpdbg web SAPI support
  --enable-phpdbg-debug      Build phpdbg in debug mode
  --disable-cgi           Disable building CGI version of PHP

General settings:

  --enable-gcov           Enable GCOV code coverage (requires LTP) - FOR DEVELOPERS ONLY!!
  --enable-debug          Compile with debugging symbols
  --with-layout=TYPE      Set how installed files will be laid out.  Type can
                          be either PHP or GNU [PHP]
  --with-config-file-path=PATH
                          Set the path in which to look for php.ini [PREFIX/lib]
  --with-config-file-scan-dir=PATH
                          Set the path where to scan for configuration files
  --enable-sigchild       Enable PHP's own SIGCHLD handler
  --enable-libgcc         Enable explicitly linking against libgcc
  --disable-short-tags    Disable the short-form <? start tag by default
  --enable-dmalloc        Enable dmalloc
  --disable-ipv6          Disable IPv6 support
  --enable-dtrace         Enable DTrace support
  --enable-fd-setsize     Set size of descriptor sets

Extensions:

  --with-EXTENSION=shared[,PATH]

    NOTE: Not all extensions can be build as 'shared'.

    Example: --with-foobar=shared,/usr/local/foobar/

      o Builds the foobar extension as shared extension.
      o foobar package install prefix is /usr/local/foobar/


  --disable-all           Disable all extensions which are enabled by default

  --disable-libxml        Disable LIBXML support
  --with-libxml-dir=DIR   LIBXML: libxml2 install prefix
  --with-openssl=DIR      Include OpenSSL support (requires OpenSSL >= 1.0.1)
  --with-kerberos=DIR     OPENSSL: Include Kerberos support
  --with-system-ciphers   OPENSSL: Use system default cipher list instead of hardcoded value
  --with-pcre-regex=DIR   Include Perl Compatible Regular Expressions support.
                          DIR is the PCRE install prefix BUNDLED
  --with-pcre-jit         Enable PCRE JIT functionality (BUNDLED only)
  --with-pcre-valgrind=DIR
                          Enable PCRE valgrind support. Developers only!
  --without-sqlite3=DIR   Do not include SQLite3 support. DIR is the prefix to
                          SQLite3 installation directory.
  --with-zlib=DIR         Include ZLIB support (requires zlib >= 1.0.9)
  --with-zlib-dir=<DIR>   Define the location of zlib install directory
  --enable-bcmath         Enable bc style precision math functions
  --with-bz2=DIR          Include BZip2 support
  --enable-calendar       Enable support for calendar conversion
  --disable-ctype         Disable ctype functions
  --with-curl=DIR         Include cURL support
  --enable-dba            Build DBA with bundled modules. To build shared DBA
                          extension use --enable-dba=shared
  --with-qdbm=DIR         DBA: QDBM support
  --with-gdbm=DIR         DBA: GDBM support
  --with-ndbm=DIR         DBA: NDBM support
  --with-db4=DIR          DBA: Oracle Berkeley DB 4.x or 5.x support
  --with-db3=DIR          DBA: Oracle Berkeley DB 3.x support
  --with-db2=DIR          DBA: Oracle Berkeley DB 2.x support
  --with-db1=DIR          DBA: Oracle Berkeley DB 1.x support/emulation
  --with-dbm=DIR          DBA: DBM support
  --with-tcadb=DIR        DBA: Tokyo Cabinet abstract DB support
  --with-lmdb=DIR        DBA: Lightning memory-mapped database support
  --without-cdb=DIR       DBA: CDB support (bundled)
  --disable-inifile       DBA: INI support (bundled)
  --disable-flatfile      DBA: FlatFile support (bundled)
  --disable-dom           Disable DOM support
  --with-libxml-dir=DIR   DOM: libxml2 install prefix
  --with-enchant=DIR      Include enchant support.
                          GNU Aspell version 1.1.3 or higher required.
  --enable-exif           Enable EXIF (metadata from images) support
  --disable-fileinfo      Disable fileinfo support
  --disable-filter        Disable input filter support
  --with-pcre-dir         FILTER: pcre install prefix
  --enable-ftp            Enable FTP support
  --with-openssl-dir=DIR  FTP: openssl install prefix
  --with-gd=DIR           Include GD support.  DIR is the GD library base
                          install directory BUNDLED
  --with-webp-dir=DIR      GD: Set the path to libwebp install prefix
  --with-jpeg-dir=DIR     GD: Set the path to libjpeg install prefix
  --with-png-dir=DIR      GD: Set the path to libpng install prefix
  --with-zlib-dir=DIR     GD: Set the path to libz install prefix
  --with-xpm-dir=DIR      GD: Set the path to libXpm install prefix
  --with-freetype-dir=DIR GD: Set the path to FreeType 2 install prefix
  --enable-gd-jis-conv    GD: Enable JIS-mapped Japanese font support
  --with-gettext=DIR      Include GNU gettext support
  --with-gmp=DIR          Include GNU MP support
  --with-mhash=DIR        Include mhash support
  --disable-hash          Disable hash support
  --without-iconv=DIR     Exclude iconv support
  --with-imap=DIR         Include IMAP support. DIR is the c-client install prefix
  --with-kerberos=DIR     IMAP: Include Kerberos support. DIR is the Kerberos install prefix
  --with-imap-ssl=DIR     IMAP: Include SSL support. DIR is the OpenSSL install prefix
  --with-interbase=DIR    Include Firebird support.  DIR is the Firebird base
                          install directory /opt/firebird
  --enable-intl           Enable internationalization support
  --with-icu-dir=DIR      Specify where ICU libraries and headers can be found
  --disable-json          Disable JavaScript Object Serialization support
  --with-ldap=DIR         Include LDAP support
  --with-ldap-sasl=DIR    LDAP: Include Cyrus SASL support
  --enable-mbstring       Enable multibyte string support
  --disable-mbregex       MBSTRING: Disable multibyte regex support
  --disable-mbregex-backtrack
                          MBSTRING: Disable multibyte regex backtrack check
  --with-libmbfl=DIR      MBSTRING: Use external libmbfl.  DIR is the libmbfl base
                          install directory BUNDLED
  --with-onig=DIR         MBSTRING: Use external oniguruma. DIR is the oniguruma install prefix.
                          If DIR is not set, the bundled oniguruma will be used
  --with-mysqli=FILE      Include MySQLi support.  FILE is the path
                          to mysql_config.  If no value or mysqlnd is passed
                          as FILE, the MySQL native driver will be used
  --enable-embedded-mysqli
                          MYSQLi: Enable embedded support
                          Note: Does not work with MySQL native driver!
  --with-mysql-sock=SOCKPATH
                          MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer.
                          If unspecified, the default locations are searched
  --with-oci8=DIR         Include Oracle Database OCI8 support. DIR defaults to $ORACLE_HOME.
                          Use --with-oci8=instantclient,/path/to/instant/client/lib
                          to use an Oracle Instant Client installation
  --with-odbcver=HEX      Force support for the passed ODBC version. A hex number is expected, default 0x0350.
                             Use the special value of 0 to prevent an explicit ODBCVER to be defined.
  --with-adabas=DIR       Include Adabas D support /usr/local
  --with-sapdb=DIR        Include SAP DB support /usr/local
  --with-solid=DIR        Include Solid support /usr/local/solid
  --with-ibm-db2=DIR      Include IBM DB2 support /home/db2inst1/sqllib
  --with-ODBCRouter=DIR   Include ODBCRouter.com support /usr
  --with-empress=DIR      Include Empress support \$EMPRESSPATH
                          (Empress Version >= 8.60 required)
  --with-empress-bcs=DIR
                          Include Empress Local Access support \$EMPRESSPATH
                          (Empress Version >= 8.60 required)
  --with-birdstep=DIR     Include Birdstep support /usr/local/birdstep
  --with-custom-odbc=DIR  Include user defined ODBC support. DIR is ODBC install base
                          directory /usr/local. Make sure to define CUSTOM_ODBC_LIBS and
                          have some odbc.h in your include dirs. f.e. you should define
                          following for Sybase SQL Anywhere 5.5.00 on QNX, prior to
                          running this configure script:
                            CPPFLAGS=\"-DODBC_QNX -DSQLANY_BUG\"
                            LDFLAGS=-lunix
                            CUSTOM_ODBC_LIBS=\"-ldblib -lodbc\"
  --with-iodbc=DIR        Include iODBC support /usr/local
  --with-esoob=DIR        Include Easysoft OOB support /usr/local/easysoft/oob/client
  --with-unixODBC=DIR     Include unixODBC support /usr/local
  --with-dbmaker=DIR      Include DBMaker support
  --disable-opcache       Disable Zend OPcache support
  --disable-opcache-file  Disable file based caching
  --disable-huge-code-pages
                          Disable copying PHP CODE pages into HUGE PAGES
  --enable-pcntl          Enable pcntl support (CLI/CGI only)
  --disable-pdo           Disable PHP Data Objects support
  --with-pdo-dblib=DIR    PDO: DBLIB-DB support.  DIR is the FreeTDS home directory
  --with-pdo-firebird=DIR PDO: Firebird support.  DIR is the Firebird base
                          install directory /opt/firebird
  --with-pdo-mysql=DIR    PDO: MySQL support. DIR is the MySQL base directory
                          If no value or mysqlnd is passed as DIR, the
                          MySQL native driver will be used
  --with-zlib-dir=DIR     PDO_MySQL: Set the path to libz install prefix
  --with-pdo-oci=DIR      PDO: Oracle OCI support. DIR defaults to $ORACLE_HOME.
                          Use --with-pdo-oci=instantclient,/path/to/instant/client/lib
                          for an Oracle Instant Client installation.
  --with-pdo-odbc=flavour,dir
                          PDO: Support for 'flavour' ODBC driver.
              include and lib dirs are looked for under 'dir'.

              'flavour' can be one of:  ibm-db2, iODBC, unixODBC, generic
              If ',dir' part is omitted, default for the flavour
              you have selected will be used. e.g.:

                --with-pdo-odbc=unixODBC

              will check for unixODBC under /usr/local. You may attempt
              to use an otherwise unsupported driver using the \"generic\"
              flavour.  The syntax for generic ODBC support is:

                --with-pdo-odbc=generic,dir,libname,ldflags,cflags

              When built as 'shared' the extension filename is always pdo_odbc.so
  --with-pdo-pgsql=DIR    PDO: PostgreSQL support.  DIR is the PostgreSQL base
                          install directory or the path to pg_config
  --without-pdo-sqlite=DIR
                          PDO: sqlite 3 support.  DIR is the sqlite base
                          install directory BUNDLED
  --with-pgsql=DIR        Include PostgreSQL support.  DIR is the PostgreSQL
                          base install directory or the path to pg_config
  --disable-phar          Disable phar support
  --disable-posix         Disable POSIX-like functions
  --with-pspell=DIR       Include PSPELL support.
                          GNU Aspell version 0.50.0 or higher required
  --with-libedit=DIR      Include libedit readline replacement (CLI/CGI only)
  --with-readline=DIR     Include readline support (CLI/CGI only)
  --with-recode=DIR       Include recode support
  --disable-session       Disable session support
  --with-mm=DIR           SESSION: Include mm support for session storage
  --enable-shmop          Enable shmop support
  --disable-simplexml     Disable SimpleXML support
  --with-libxml-dir=DIR   SimpleXML: libxml2 install prefix
  --with-snmp=DIR         Include SNMP support
  --with-openssl-dir=DIR  SNMP: openssl install prefix
  --enable-soap           Enable SOAP support
  --with-libxml-dir=DIR   SOAP: libxml2 install prefix
  --enable-sockets        Enable sockets support
  --with-sodium=DIR     Include sodium support
  --with-password-argon2=DIR           Include Argon2 support in password_*. DIR is the Argon2 shared library path]
  --enable-sysvmsg        Enable sysvmsg support
  --enable-sysvsem        Enable System V semaphore support
  --enable-sysvshm        Enable the System V shared memory support
  --with-tidy=DIR         Include TIDY support
  --disable-tokenizer     Disable tokenizer support
  --enable-wddx           Enable WDDX support
  --with-libxml-dir=DIR   WDDX: libxml2 install prefix
  --with-libexpat-dir=DIR WDDX: libexpat dir for XMLRPC-EPI (deprecated)
  --disable-xml           Disable XML support
  --with-libxml-dir=DIR   XML: libxml2 install prefix
  --with-libexpat-dir=DIR XML: libexpat install prefix (deprecated)
  --disable-xmlreader     Disable XMLReader support
  --with-libxml-dir=DIR   XMLReader: libxml2 install prefix
  --with-xmlrpc=DIR       Include XMLRPC-EPI support
  --with-libxml-dir=DIR   XMLRPC-EPI: libxml2 install prefix
  --with-libexpat-dir=DIR XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)
  --with-iconv-dir=DIR    XMLRPC-EPI: iconv dir for XMLRPC-EPI
  --disable-xmlwriter     Disable XMLWriter support
  --with-libxml-dir=DIR   XMLWriter: libxml2 install prefix
  --with-xsl=DIR          Include XSL support.  DIR is the libxslt base
                          install directory (libxslt >= 1.1.0 required)
  --enable-zend-test           Enable zend-test extension
  --enable-zip            Include Zip read/write support
  --with-zlib-dir=DIR     ZIP: Set the path to libz install prefix
  --with-pcre-dir         ZIP: pcre install prefix
  --with-libzip=DIR       ZIP: use libzip
  --enable-mysqlnd        Enable mysqlnd explicitly, will be done implicitly
                          when required by other extensions
  --disable-mysqlnd-compression-support
                          Disable support for the MySQL compressed protocol in mysqlnd
  --with-zlib-dir=DIR     mysqlnd: Set the path to libz install prefix

PEAR:

  --with-pear=DIR         Install PEAR in DIR [PREFIX/lib/php]
  --without-pear          Do not install PEAR

Zend:

  --enable-maintainer-zts Enable thread safety - for code maintainers only!!
  --disable-inline-optimization
                          If building zend_execute.lo fails, try this switch
  --disable-zend-signals  whether to enable zend signal handling

TSRM:

  --with-tsrm-pth=pth-config
                          Use GNU Pth
  --with-tsrm-st          Use SGI's State Threads
  --with-tsrm-pthreads    Use POSIX threads (default)

Libtool:

  --enable-shared=PKGS    Build shared libraries default=yes
  --enable-static=PKGS    Build static libraries default=yes
  --enable-fast-install=PKGS
                          Optimize for fast installation default=yes
  --with-gnu-ld           Assume the C compiler uses GNU ld default=no
  --disable-libtool-lock  Avoid locking (might break parallel builds)
  --with-pic              Try to use only PIC/non-PIC objects default=use both
  --with-tags=TAGS        Include additional configurations automatic


Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  YACC        The `Yet Another Compiler Compiler' implementation to use.
              Defaults to the first program found out of: `bison -y', `byacc',
              `yacc'.
  YFLAGS      The list of arguments that will be passed by default to $YACC.
              This script will default YFLAGS to the empty string to avoid a
              default value of `-d' given by some make applications.
  CXX         C++ compiler command
  CXXFLAGS    C++ compiler flags
  CXXCPP      C++ preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to the package provider.
PHP编译安装时常见错误解决办法,php编译常见错误

This article is post on https://coderwall.com/p/ggmpfa

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
复制代码 代码如下:
yum -y install libxslt-devel

configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
复制代码 代码如下:
yum -y install net-snmp-devel

configure: error: Please reinstall readline - I cannot find readline.h
复制代码 代码如下:
yum -y install readline-devel

configure: error: Cannot find pspell
复制代码 代码如下:
yum -y install aspell-devel

checking for unixODBC support... configure: error: ODBC header file '/usr/include/sqlext.h' not found!
复制代码 代码如下:
yum -y install unixODBC-devel

configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.
复制代码 代码如下:
yum -y install libicu-devel

configure: error: utf8mime2text() has new signature, but U8TCANONICAL is missing. This should not happen. Check config.log for additional information.
复制代码 代码如下:
yum -y install libc-client-devel

configure: error: freetype.h not found.
复制代码 代码如下:
yum -y install freetype-devel

configure: error: xpm.h not found.
复制代码 代码如下:
yum -y install libXpm-devel

configure: error: png.h not found.
复制代码 代码如下:
yum -y install libpng-devel

configure: error: vpx_codec.h not found.
复制代码 代码如下:
yum -y install libvpx-devel

configure: error: Cannot find enchant
复制代码 代码如下:
yum -y install enchant-devel

configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
复制代码 代码如下:
yum -y install libcurl-devel

LAOGAO added 20140907:

configure: error: mcrypt.h not found. Please reinstall libmcrypt.
复制代码 代码如下:
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar zxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make && make install

added 20141003:

Cannot find imap
复制代码 代码如下:
ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so

configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing.
复制代码 代码如下:
yum -y install libc-client-devel

Cannot find ldap.h
复制代码 代码如下:
yum -y install openldap
yum -y install openldap-devel

configure: error: Cannot find ldap libraries in /usr/lib
复制代码 代码如下:
cp -frp /usr/lib64/libldap* /usr/lib/

configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
复制代码 代码如下:
yum -y install postgresql-devel

configure: error: Please reinstall the lib curl distribution
复制代码 代码如下:
yum -y install curl-devel

configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
复制代码 代码如下:
yum -y install net-snmp-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
复制代码 代码如下:
yum -y install libxslt-devel

checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution

Fix:
复制代码 代码如下:
yum -y install bzip2-devel

checking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution – easy.h should be in/include/curl/

Fix:
复制代码 代码如下:
yum -y install curl-devel

checking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).

Fix:
复制代码 代码如下:
yum -y install db4-devel

checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.

Fix:
复制代码 代码如下:
yum -y install libjpeg-devel

checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.

Fix:
复制代码 代码如下:
yum -y install libpng-devel

checking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir=

configure: error: freetype.h not found.
Fix:
复制代码 代码如下:
Reconfigure your PHP with the following option. --with-xpm-dir=/usr

checking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.

Fix:
复制代码 代码如下:
yum -y install libXpm-devel

checking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.h

Fix:
复制代码 代码如下:
yum -y install gmp-devel

checking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

Fix:
复制代码 代码如下:
yum -y install libc-client-devel

checking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.h

Fix:
复制代码 代码如下:
yum -y install openldap-devel

checking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!

Fix:
复制代码 代码如下:
yum -y install unixODBC-devel

checking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix:
复制代码 代码如下:
yum -y install postgresql-devel

checking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distribution

Fix:
复制代码 代码如下:
yum -y install sqlite-devel

checking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspell

Fix:
复制代码 代码如下:
yum -y install aspell-devel

checking whether to enable UCD SNMP hack… yes checking for default_store.h… no

checking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.

Fix:
复制代码 代码如下:
yum -y install net-snmp-devel

checking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Fix:
复制代码 代码如下:
yum -y install libxslt-devel

configure: error: xml2-config not found. Please check your libxml2 installation.

Fix:
复制代码 代码如下:
yum -y install libxml2-devel

checking for PCRE headers location… configure: error: Could not find pcre.h in /usr

Fix:
复制代码 代码如下:
yum -y install pcre-devel

configure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore!

Fix:
复制代码 代码如下:
yum -y install mysql-devel

checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!

Fix:
复制代码 代码如下:
yum -y install unixODBC-devel

checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix:
复制代码 代码如下:
yum -y install postgresql-devel

configure: error: Cannot find pspell

Fix:
复制代码 代码如下:
yum -y install pspell-devel

configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.

Fix:
复制代码 代码如下:
yum -y install net-snmp-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Fix:
复制代码 代码如下:
yum -y install libxslt-devel
编译参数

[root@cairui php-7.2.3]# ./configure --prefix=/opt/php7.2.3 --with-apxs2=/opt/apache/bin/apxs --with-openssl --with-zlib --with-curl --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-libxml-dir --enable-soap --enable-sockets --with-xmlrpc --with-iconv-dir=/opt/libiconv --with-xsl --with-mysqli --with-pdo-mysql --with-mysqli

PHP中三种主要的MySQL连接方式(5.4开始驱动底层实现都是mysqlnd):
http://php.net/manual/zh/mysqli.overview.php
mysqli(首选) pdo_mysql(建议) mysql(不建议)
PHP从5.4开始内置了MySQL驱动mysqlnd:
php-src/ext/mysqlnd/
php-src/ext/mysql/
php-src/ext/mysqli/
php-src/ext/pdo_mysql/
关系:mysql,mysqli,pdo_mysql这3套PHP操作MySQL的编程接口底层都依赖PHP内置的MySQL驱动mysqlnd.

PHP5.3这样启用mysqlnd支持:
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
PHP5.4后留空则默认启用mysqlnd:
--with-mysql
--with-mysqli
--with-pdo-mysql
PHP7开始不再支持--with-mysql.
--with-pdo-sqlite 默认启用,推荐采用pdo_sqlite来操作SQLite.
--with-sqlite3 默认启用,此扩展是试验性质的.
Windows二进制包ext目录下内置了下面几个扩展:
php_mysql.dll
php_mysqli.dll
php_pdo_mysql.dll
php_sqlite3.dll
php_pdo_sqlite.dll
Debian/Ubuntu软件包: php5-mysqlnd php5-sqlite

PostgreSQL Driver for PHP:
--with-pgsql=DIR
--with-pdo-pgsql=DIR
DIR is the PostgreSQL base install directory or the path to pg_config.
Debian/Ubuntu软件包: php5-pgsql
apt-cache depends php5-pgsql 看到其依赖libpq5这个PostgreSQL的C客户端库.
开发包libpq-dev里带了/usr/bin/pg_config.
sudo apt-get install libpq-dev
--with-pgsql=/usr/bin/pg_config
--with-pdo-pgsql=/usr/bin/pg_config

Oracle Driver for PHP:
--with-oci8=DIR
--with-pdo-oci=DIR 此扩展是试验性质的.
DIR defaults to $ORACLE_HOME.
或者安装Oracle Instant Client然后这样指定:
--with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client/lib
--with-pdo-oci=shared,instantclient,/usr/lib/oracle,11.2
Oracle Instant Client下载地址(60MB):
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
php_oci8.dll
php_oci8_11g.dll
php_pdo_oci.dll
[root@cairui htdocs]# cat index.php 
<?php
phpinfo();
?>
~

将配置文件放到安装路径下
[root@Centos php-5.4.22]# cp php.ini-production /application/php/lib/php.ini
[root@Centos php-5.4.22]# ls /application/php/lib/php.ini
/application/php/lib/php
[root@cairui htdocs]# cat /opt/apache/conf/httpd.conf | grep -v "#"

ServerRoot "/opt/apache2.2.34"

Listen 80

LoadModule php7_module        modules/libphp7.so

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
User php
Group php

</IfModule>
</IfModule>


ServerAdmin 928939638@qq.com

ServerName 120.25.255.87:80

DocumentRoot "/opt/apache2.2.34/htdocs"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>


<Directory "/opt/apache2.2.34/htdocs">
    Options -Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny
    Allow from all

</Directory>

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" common

</IfModule>

<IfModule alias_module>


    ScriptAlias /cgi-bin/ "/opt/apache2.2.34/cgi-bin/"

</IfModule>

<IfModule cgid_module>
</IfModule>

<Directory "/opt/apache2.2.34/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

DefaultType text/plain

<IfModule headers_module>
    RequestHeader unset Proxy early
</IfModule>

<IfModule mime_module>
    TypesConfig conf/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php .phtml
    AddType application/x-httpd-php-source .phps


</IfModule>






Include conf/extra/httpd-mpm.conf









Include conf/extra/httpd-default.conf

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

连接mysql数据库测试

[root@cairui htdocs]# cat index.php 
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "123456";
 
// 创建连接
$conn = new mysqli($servername, $username, $password);
 
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
} 
echo "连接成功";
?>

php连接mysql报错No such file or directory
 

 

php测试文件如下:

1
2
3
4
5
6
7
8
9
10
11
<?php
$con = mysql_connect("localhost","root","zengjie2");
if (!$con)
{
    die('Could not connect: ' . mysql_error());
}
else
{
    echo "ok";
}
?>
 

访问后提示:

 

1
2
Warning: mysql_connect(): No such file or directory in /usr/local/nginx/html/mysql.php on line 3
Could not connect: No such file or directory
 

解决方法:

登陆mysql

输入status,输出如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Connection id:   4
Current database:
Current user:    root@localhost
SSL:     Not in use
Current pager:   stdout
Using outfile:   ''
Using delimiter:    ;
Server version:  5.1.73 Source distribution
Protocol version:   10
Connection:  Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:     /var/lib/mysql/mysql.sock
Uptime:  14 min 29 sec
 

记下UNIX socket路径  /var/lib/mysql/mysql.sock

 

查看/tmp/mysql.sock,不存在这个文件,那么建个Link

 

1
2
cd /tmp
ln -s /var/lib/mysql/mysql.sock mysql.sock
 

重新访问php文件,成功连接。

 

 

以上是一种情况,另外一种情况: 存在/tmp/mysql.sock 但是不存在 /var/lib/mysql/mysql.sock

 

1
2
3
4
cd /var/lib
mkdir mysql
cd mysql
ln -s /tmp/mysql.sock mysql.sock
PHP中使用localhost连接Mysql不成功的解决方法
发现问题

昨天在帮同事编译安装Linux环境时,遇到一个问题:
WEB服务器是apache,数据库是MySQL。

于是写了一个测试连接数据库的PHP页面:
复制代码 代码如下:
$mysql = mysql_connect('localhost','root','');
打开 http://localhost/test.php 测试

提示:Can't connect to local MySQL server through socket...

检查环境正常

以为是数据库没有启动,于是查看一下进程,MySQL在进程里,重启了一下MySQL.

使用mysql -u root -p 可以进入MySQL操作界面

直接使用/usr/local/php5/bin/php /web/test.php执行可以连上数据库
apache也重启了,一样无效

疑点:为何网页执行失败,命令执行却成功

这下就郁闷了,使用php命令直接执行就成功,通过网页执行就失败。难道是apache导致?网上搜索了大堆资料也没找到解决方案,重新编译安装apache问题依旧。

把localhost改成127.0.0.1成功

把localhost改成127.0.0.1后竟然连接成功了,开始陷入思考困局:localhost失败127.0.0.1却成功?

ping localhost 地址是127.0.0.1没错

打开hosts加入
复制代码 代码如下:

127.0.0.1 qttc

使用qttc当主机连接也正常,唯独就不认localhost。
localhost连接方式不同导致

为了了解PHP连接数据库时,主机填写localhost与其它的区别阅读了大量资料,最后得知:

当主机填写为localhost时mysql会采用 unix domain socket连接
当主机填写为127.0.0.1时mysql会采用tcp方式连接
这是linux套接字网络的特性,win平台不会有这个问题

解决方法

在my.cnf的[mysql]区段里添加
复制代码 代码如下:
protocol=tcp

保存重启MySQL,问题解决!

配置文件:

[root@cairui lib]# egrep -v ";|^$" php.ini
[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
[Date]
[filter]
[iconv]
[intl]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
[Assertion]
zend.assertions = -1
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[dba]
[opcache]
[curl]
[openssl]

相关内容

    暂无相关文章