源码编译php

在對php進行安裝的過程中出現如下錯誤:
1、報錯信息:
checking for known struct flock definition... configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
2、平台介紹:
OS Version:  CentOS release 6.4(Final)
Nginx Version:  nginx version: nginx/1.4.3
PHP Version:  PHP 5.5.5(fpm-fcgi)
Mysql Version:  Server version: 5.6.10-log Source distribution
Kernel Version: 2.6.32-358.el6.x86_64
IP address:  192.168.168.133
3、解決辦法:
vim /etc/ld.so.conf.d/local.conf     # 編輯庫文件
/usr/local/lib                       # 添加該行
:wq                                  # 保存退出
ldconfig -v                          # 使之生效
4、注意事項:
這裏添加的庫文件路徑一定要和你系統平台arch一致,32bit的系統直接添加/usr/local/lib即可,64bit系統要填加/usr/local/lib64.否則依舊會報錯,我當時就是添加了/usr/local/lib死活編輯不了,後來更改爲
/usr/local/lib64才可以。

========================================================

安装php

cd /usr/local/src    

tar -zvxf php-5.3.13.tar.gz    

cd  php-5.3.13    

mkdir -p /usr/local/php5  #建立php安装目录    

./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv  --with-zlib  --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --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 --with-jpeg-dir --with-freetype-dir #配置    

make   #编译    

make install    #安装    

cp  php.ini-production   /usr/local/php5/etc/php.ini  #复制php配置文件到安装目录    

rm -rf /etc/php.ini   #删除系统自带配置文件    

ln -s /usr/local/php5/etc/php.ini  /etc/php.ini    #添加软链接    

cp  /usr/local/php5/etc/php-fpm.conf.default   /usr/local/php5/etc/php-fpm.conf      #拷贝模板文件为php-fpm配置文件    

vi  /usr/local/php5/etc/php-fpm.conf  #编辑    

user = www    #设置php-fpm运行账号为www    

group = www   #设置php-fpm运行组为www    

pid = run/php-fpm.pid    #取消前面的分号    

cp /usr/local/src/php-5.3.13/sapi/fpm/init.d.php-fpm   /etc/rc.d/init.d/php-fpm  #设置 php-fpm开机启动,拷贝php-fpm到启动目录    

chmod +x /etc/rc.d/init.d/php-fpm  #添加执行权限    

chkconfig php-fpm on    #设置开机启动    

vi /usr/local/php5/etc/php.ini    #编辑配置文件    

找到:disable_functions =    

修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname    

#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。    

找到:;date.timezone =    

修改为:date.timezone = PRC   #设置时区    

找到:expose_php = On    

修改为:expose_php = OFF  #禁止显示php版本的信息    

PS:在编译PHP的过程中可能会报UNDEFINED REFERENCE TO `LIBICONV_OPEN 无法编译PHP LIBICONV错误.

原文地址:https://www.cnblogs.com/wizzhangquan/p/5038567.html