源碼目錄:/home/werben/pkgsrc/php-7.3.11
php
安裝目錄:/home/werben/application/php7.3.11
mysql
# 官網地址:https://www.php.net/downloads.php wget https://www.php.net/distributions/php-7.3.11.tar.bz2
tar --bzip -xvf php-7.3.11.tar.bz2 php-7.3.11
yum install -y gcc gcc-c++ yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libicu-devel freetype-devel openldap-devel openldap openldap-devel
#建立用戶組和用戶 groupadd www useradd -g www www #配置fpm的用戶組和用戶,以及安裝其餘擴展 ./configure --prefix=/home/werben/application/php7.3.11 \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --enable-mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --enable-mysqlnd-compression-support \ --with-iconv-dir \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-libxml-dir \ --enable-xml \ --disable-rpath \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --with-curl \ --enable-mbregex \ --enable-mbstring \ --enable-intl \ --with-mcrypt \ --with-libmbfl \ --enable-ftp \ --with-gd \ --enable-gd-jis-conv \ --enable-gd-native-ttf \ --with-openssl \ --with-mhash \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --with-gettext \ --disable-fileinfo \ --enable-opcache \ --with-pear \ --enable-maintainer-zts \ --with-ldap=shared \ --without-gdbm #上面的步驟可能會出現不少問題,如須要從新安裝libzip,須要安裝ldap,須要安裝cmake #從新安裝libzip須要安裝cmake,這裏記錄一下cmake的安裝步驟,其餘問題本身百度解決了, #不記錄了,中間本身去官網下了幾個最新的cmake版本,編譯過程當中都出錯了。 #發現寶塔用的是2.8.X的版本。這裏我用的版本是3.5.2的版本 wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz tar xvf cmake-3.5.2.tar.gz cd cmake-3.5.2 ./bootstrap --prefix=/usr/local/cmake gmake gmake install cd /usr/local/cmake/bin ln -s /usr/local/cmake/bin/cmake /usr/bin/ cmake --version #接下來安裝libzip wget https://libzip.org/download/libzip-1.5.2.tar.gz tar -zxf libzip-1.5.2.tar.gz cd libzip-1.5.2 mkdir build cd build cmake .. make -j4 make install
#若是提示make命令找不到,則才須要安裝make工具 yum -y install gcc automake autoconf libtool make
make && make install
ln -s /home/werben/application/php7.3.11/sbin/* /usr/local/sbin/ ln -s /home/werben/application/php7.3.11/bin/* /usr/local/bin/
#查看php.ini的位置 php -r "phpinfo();" | grep 'php.ini' #將源碼中的php.ini*拷貝到php.ini的位置 cp /home/werben/pkgsrc/php-7.3.11/php.ini-* /home/werben/application/php7.3.11/lib/ #重命名php.ini文件 cp /home/werben/application/php7.3.11/lib/php.ini-production /home/werben/application/php7.3.11/lib/php.ini
#/home/werben/pkgsrc/php-7.3.11安裝目錄的結構 ├── bin │ ├── pear │ ├── peardev │ ├── pecl │ ├── phar -> phar.phar │ ├── phar.phar │ ├── php │ ├── php-cgi │ ├── php-config │ ├── phpdbg │ └── phpize ├── etc │ ├── pear.conf │ ├── php-fpm.conf.default │ └── php-fpm.d ├── include │ └── php ├── lib │ ├── php │ ├── php.ini │ ├── php.ini-development │ └── php.ini-production ├── php │ ├── man │ └── php ├── sbin │ └── php-fpm └── var ├── log └── run