Linux下原始碼編譯php7
阿新 • • 發佈:2018-12-19
1.安裝依賴包
yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libxslt libxslt-devel libzip
2.下載php7安裝
- 這裡以php7.3為例,官網下載地址:https://secure.php.net/get/php-7.3.0.tar.gz/from/a/mirror
wget http://cn2.php.net/distributions/php-7.3.0.tar.gz
3.解壓、編譯安裝
tar zxvf php-7.3.0.tar.gz cd php-7.3.0 #配置 ./configure --prefix=/usr/local/php \ --with-curl \ --with-freetype-dir \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysqli \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-pear \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip #編譯 make #安裝 make install
- 編譯中遇到的錯誤
1.Libzip 版本過低或提示reinstall解決方法 yum remove libzip -y wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make && make install 2.configure: error: off_t undefined; check your library configuration echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf&&ldconfig -v 3./usr/local/include/zip.h:59:21: 致命錯誤:zipconf.h:沒有那個檔案或目錄 cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
4.配置
- 在之前編譯的原始碼包中,找到 php.ini-production,複製到/usr/local/php下,並改名為php.ini
[[email protected] php-7.3.0]# pwd
/usr/local/php-7.3.0
[[email protected] php-7.3.0]# cp php.ini-production /usr/local/php/etc/php.ini
- 顯示錯誤資訊
vim /usr/local/php/php.ini
修改display_errors = On
- 複製啟動指令碼
[[email protected] fpm]# pwd
/usr/local/php-7.3.0/sapi/fpm
[[email protected] fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[[email protected] fpm]# chmod a+x /etc/init.d/php-fpm
[[email protected] etc]# pwd
/usr/local/php/etc
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] etc]# vim php-fpm.conf
修改去掉 pid = run/php-fpm.pid 前面的分號
[[email protected] php-fpm.d]# pwd
/usr/local/php/etc/php-fpm.d
[[email protected] php-fpm.d]# cp www.conf.default www.conf