win10 docker ubuntu14.04 php 编译安装 php7.3.20

1.docker安装ubuntu14.04镜像

docker run -it --name=ubuntu14.1 -p 8881:80 -p 3306:3306 -p 8882:8882 -v /d/docker/ubuntu14:/var/www ubuntu:14.04 /bin/bash

我用的docker win10 想用-v 得先把磁盘共享给docker (中间得输入用户名密码)

 

 

 apt-get update (如果下载速度慢的话可以切换为阿里的源,网上搜即可,修改/etc/apt/sources.list)

 

2.下载php包, 我下载的是7.3.21

# wget https://www.php.net/distributions/php-7.3.21.tar.gz

# tar -zxvf php-7.3.21.tar.gz

# cd php-7.3.21

3. 安装依赖

 

sudo apt-get update
sudo apt-get install gcc
sudo apt-get install make
sudo apt-get install openssl
sudo apt-get install curl
sudo apt-get install libbz2-dev
sudo apt-get install libxml2-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libzip-dev
sudo apt-get install libssl-devsudo apt-get install libcurl4-openssl-dev

 

 4.预编译

 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with
-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib
 --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimiza
tion --with-curl --enable-mbregex --enable-mbstring --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enabl
e-sockets --with-xmlrpc --enable-zip --enable-soap --with-pear --with-gettext --enable-fileinfo --enable-maintainer-zts --wit
h-kerberos --with-inline-optimization

 

看到这个页面 预编译成功

 编译并安装 ,参数-j指定编译线程数量来进行多线程编译

 # sudo make -j4

执行以下命令进行安装 

# sudo make install

遇到的问题 

问题 1: checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11

解决: 

# 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: php7.3 make install php-7.3.21/sapi/cli/php: error while loading shared libraries: libzip.so.5: cannot open shared object file: No such file or directory

 

 

# find / -name libzip.so.5   查找一下这个lib文件在哪里

#/usr/local/lib.../libzip.so.5

# vim /etc/ld.so.conf

下一行先加代码    /usr/local/lib   

执行命令 #  ldconfig 加载ld

问题三 : 

build/shtool install -c ext/phar/phar.phar /usr/local/php/bin

cp ext/phar/phar.php ext/phar/phar.phar

ln -s -f /usr/local/php/etc/phar.phar /usr/local/php/bin/phar

 配置文件。在php的编译目录,执行以下命令。

cp php.ini-production /usr/local/php/lib/php.ini

 

配置php-fpm:

cd /usr/local/php/etc/

cp php-fpm.conf.default php-fpm.conf

cp php-fpm.d/www.conf.default www.conf

 编辑 www.conf 文件 

 vim /php-fpm.d/www.conf 

 

启动 php-fpm 

 /usr/local/php/sbin/php-fpm

查看 是否启动 ps -aux

 

如果报错没有www用户 则添加用户组,用户

groupadd www

useradd -g www www

 

php加入系统变量 
   
sudo echo "PATH=$PATH:/usr/local/php/bin">> /etc/profile 
sudo echo "export PATH">> /etc/profile 
source /etc/profile 
 
 

5. 配置nginx 加载php

搜索nginx配置文件在哪里 

whereis nginx

cd /etc/nginx/

 vim sites-available/default 

 

 

这里设置端口

往下找 location ~ \.php$ { ....  打开注释

 

 

 fastcgi_pass 开启一个就行 我用的是端口

重启 nginx

到此 php7.3 安装完毕

要想 php-fpm添加service服务 

修改/usr/local/php/etc/php-fpm.conf文件,把;pid = run/php-fpm.pid之前的‘;’去掉

把源码包目录下的init.d.php-fpm 拷贝到/etc/init.d/php-fpm

cp /php7.3.21/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

设置执行权限

chmod +x /etc/init.d/php-fpm

添加服务

chkconfig --add php-fpm

操作完以后可以使用以下命令了

service php-fpm start

service php-fpm stop
service php-fpm restart
service php-fpm reload

 

posted @ 2020-08-07 17:45  顺瓜摸藤  阅读(581)  评论(0编辑  收藏  举报