linux下php7的编译安装

okgoes 2023-05-09 13:07:15
Categories: Tags:

环境为(centOS7 64位)

1.下载php7的源码

http://php.net/downloads.php

2.安装php的相关依赖

1
2
3
4
5
6
7
yum install -y  zlib-devel fontconfig fontconfig-devel libXpm* libtool* libxml2 libxml2-devel curl curl-devel
yum install -y  zlib-devel fontconfig fontconfig-devel libXpm* libtool* libxml2 libxml2-devel curl curl-devel
yum install -y openssl-devel
yum install gdbm-devel -y
yum install gmp-devel -y
yum install libtermcap-devel ncurses-devel libevent-devel readline-devel -y
yum -y install bzip2-devel

2.1.单独安装的依赖

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#yasm-1.3.0.tar.gz
tar zxvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make && make install

#libmcrypt-2.5.7.tar.gz
tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure

make && make install

#libvpx-1.6.1.tar.bz2
bzip2 -d libvpx-1.6.1.tar.bz2
tar -xvf libvpx-1.6.1.tar
cd libvpx-1.6.1
./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
make && make install

#tiff-4.0.7.tar.gz
tar zxvf tiff-4.0.7.tar.gz
cd tiff-4.0.7
./configure --prefix=/usr/local/tiff --enable-shared
make && make install

#libpng-1.6.29.tar.xz
xz -d libpng-1.6.29.tar.xz
tar -xvf libpng-1.6.29.tar
cd libpng-1.6.29
./configure --prefix=/usr/local/libpng --enable-shared
make && make install

#freetype-2.7.1.tar.bz2
bzip2 -d freetype-2.7.1.tar.bz2
tar -xvf freetype-2.7.1.tar
cd freetype-2.7.1
./configure --prefix=/usr/local/freetype --enable-shared --without-png
make && make install

#jpegsrc.v9b.tar.gz
tar zxvf jpegsrc.v9b.tar.gz
cd jpegsrc.v9b
./configure --prefix=/usr/local/jpeg --enable-shared
make && make install

#libgd-2.1.1.tar.xz
xz -d libgd-2.1.1.tar.xz
tar -xvf libgd-2.1.1.tar
cd libgd-2.1.1
./configure \
--prefix=/usr/local/libgd \
--enable-shared \
--with-jpeg=/usr/local/jpeg \
--with-png=/usr/local/libpng \
--with-freetype=/usr/local/freetype \
--with-fontconfig=/usr/local/freetype \
--with-xpm=/usr/ \
--with-tiff=/usr/local/tiff \
--with-vpx=/usr/local/libvpx
make && make install

#t1lib-5.1.2.tar.bz2
bzip2 -d t1lib-5.1.2.tar.bz2
tar -xvf t1lib-5.1.2.tar
cd t1lib-5.1.2
./configure --prefix=/usr/local/t1lib --enable-shared
make without_doc
make install

cp -frp /usr/lib64/libltdl.so* /usr/lib/
cp -frp /usr/lib64/libXpm.so* /usr/lib/

3.如果要安装mysql扩展请先安装mysq,如果mysql不在同一服务器,则不用安装mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#如果msyql在同一台服务器则:
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mysql-sock=/tmp/mysqld.sock  \
--with-pdo-mysql=/usr/local/mysql \
#如果不在同一台服务器则使用如下脚本
./configure --prefix=/usr/local/php \
            --sysconfdir=/etc \
            --with-config-file-path=/usr/local/php/etc \
            --localstatedir=/var  \
            --datadir=/usr/share/php \
            --mandir=/usr/share/man \
            --enable-fpm  \
            --with-fpm-user=www   \
            --with-fpm-group=www \
            --with-jpeg-dir=/usr/local/jpeg \
            --with-freetype-dir=/usr/local/freetype \
            --with-xpm-dir=/usr/         \
            --with-vpx-dir=/usr/local/libvpx/ \
            --with-zlib-dir=/usr/local/zlib \
            --with-zlib \
            --with-iconv \
            --enable-bcmath  \
            --with-bz2  \
            --enable-calendar  \
            --enable-dba=shared  \
            --with-gdbm  \
            --with-gmp  \
            --enable-ftp  \
            --with-gettext   \
            --enable-mbstring  \
            --with-readline   \
            --with-mysqli=mysqlnd   \
            --with-pdo-mysql=mysqlnd \
            --with-gd --with-png-dir=/usr/local/libpng \
            --enable-opcache      \
            --enable-gd-native-ttf  \
            --enable-mbregex      \
            --enable-ftp  \
            --enable-gd-native-ttf  \
            --with-openssl  \
            --enable-pcntl      \
            --enable-sockets  \
            --with-xmlrpc  \
            --enable-zip  \
            --enable-soap  \
            --with-gettext      \
            --enable-session  \
            --with-mcrypt  \
            --with-curl  \
            --enable-ctype \
            --enable-libxml  \
            --enable-xml  \
            --enable-bcmath  \
            --enable-shmop      \
            --enable-sysvsem  \
            --enable-inline-optimization
#执行完成配置后
make && make install

4.php安装完成,后面只需配置php.ini文件,配置php-fpm或fastcgi