报错信息如下:
configure: error: Cannot find MySQL header files under /usr/local/mysql
编译安装PHP5.5.38
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/data/mysql/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-zlib-dir=/usr/local/zlib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype
报错:
configure: error: Cannot find MySQL header files under /usr/local/mysql.
如果不知道mysql安装位置,可使用mysqlnd代替
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pdo-mysql=mysqlnd --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-zlib-dir=/usr/local/zlib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype
其中配置with-mysql-sock:
--with-mysql-sock=/var/lib/mysql/mysql.sock
登录mysql后执行STATUS命令可查看到UNIX socket
mysql>STATUS--------------mysql Ver14.14 Distrib 5.6.37, forLinux (x86_64) using EditLine wrapper
Connectionid: 2503Current database:
Current user: root@localhost
SSL: Notinuse
Current pager: stdout
Using outfile:''Using delimiter: ;
Server version:5.6.37MySQL Community Server (GPL)
Protocol version:10Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket:/var/lib/mysql/mysql.sock
Uptime:24 days 10 hours 32 min 15sec
Threads:21 Questions: 9435046 Slow queries: 4 Opens: 1640 Flush tables: 1 Open tables: 431 Queries per second avg: 4.468
--------------mysql>
如果启动php-fpm失败,但已是启动成功的:
> /etc/init.d/php-fpm start
Starting php-fpm ................................... failed
则需要查看/usr/local/php/etc/php-fpm.conf文件配置:
[global]
; Pidfile; Note: the default prefix is/usr/local/php/var
; Default Value: none
pid= run/php-fpm.pid
查看php-fpm.pid文件是否存在,不存在则创建一个空的php-fpm.pid文件,
并且查看是否与启动文件/etc/init.d/php-fpm的php-fpm.pid文件路径一致。
prefix=/usr/local/php
exec_prefix=${prefix}
php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/run/php-fpm.pid