网站首页 > 技术教程 正文
1、启动纯静ubuntu容器
sudo docker run -it --name ubuntu-phpfpm7.3-0.1 registry.cn-beijing.aliyuncs.com/jd100-pub/ubuntu:20190304 /bin/bash
> 759668f30865
2、修改源
echo 'deb http://archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic universe
deb-src http://archive.ubuntu.com/ubuntu/ bionic universe
deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted
deb http://security.ubuntu.com/ubuntu/ bionic-security universe
deb-src http://security.ubuntu.com/ubuntu/ bionic-security universe
deb http://security.ubuntu.com/ubuntu/ bionic-security multiverse
' >/etc/apt/sources.list;
apt-get update
apt-get install software-properties-common
add-apt-repository ppa:ondrej/php
add-apt-repository ppa:ondrej/nginx
apt-get update
apt-get install -y php7.3-fpm (要求选择时区的时候选择 欧洲 (8Europe)/ 伦敦(27. London))
apt-get install -y nginx (nginx version: nginx/1.14.2)
(相关信息:php-pear
Creating config file /etc/php/7.3/fpm/php.ini with new version
)
========================
apt-get --purge remove php-common
apt-get install php-common php-mysql php-redis php-mbstring php-fpm php-gd php-tokenizer php-curl php-cli openssl
lume需要的扩展:
Mcrypt PHP Extension mcrypt (7.3版本使用openssl替代mcrypt )
OpenSSL PHP Extension
查找安装php常用的扩展,容器:36cabe4eea3a
========================
查看php-fpm:
whereis php-fpm
/usr/sbin/php-fpm7.3 (启动fpm,启动时报ERROR: unable to bind listening socket for address '/run/php/php7.3-fpm.sock': No such file or directory, 此时先mkdir /run/php即可)
启动nginx
优化nginx配置
events {
use epoll;
worker_connections 51200;
multi_accept on;
}
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
# gzip_comp_level 6;
gzip_min_length 1k;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
优化php-fpm
cat /etc/php/7.3/fpm/php-fpm.conf
新建开机启动脚本(需要开机启动的加入到里面)
/opt/autorun/reboot.sh
(新建步骤:
1、在宿主机中新建/opt/autorun/reboot.sh
#!/bin/bash
/usr/sbin/php-fpm7.3
nginx
2、容器中新建目录
mkdir /opt/autorun/
3、sudo docker cp reboot.sh 91b004bc998c:/opt/autorun/reboot.sh
3d87c9b09b8d-镜像id
chmod 777 /opt/autorun/reboot.sh
将容器打基础镜像
1、sudo docker commit 759668f30865 ubuntu_nginx1.42_phpfpm7.3:0.2
2、使用Dockerfile测试试用(course-service目录下)
修改Dockerfile使用指定镜像
sudo docker build -t test-php7.3:1.0 .
3、启动测试
sudo docker run -d --name test-php-v1.0 -p 9003:80 test-php7.3:1.0
直接访问宿主机:http://172.16.0.215:9003/
(测试过程命令)
sudo docker cp index.php 3943df1e1fa7:/var/www/html
sudo docker cp default 3943df1e1fa7:/etc/nginx/sites-enabled/default
sudo docker cp php.ini 3943df1e1fa7:/etc/php/7.3/fpm/php.ini
nginx use www-data
php-fpm
chown -R www-data /var/www/html/
chgrp -R www-data /var/www/html/
sudo docker run -it --name test-php-v1.2 -p 9003:80 ubuntu_nginx1.42_phpfpm7.3:0.2
sudo docker build -t ubuntu-php7.3:0.14 .
通过添加reboot.sh做启动操作
FROM ubuntu-php7.3:0.13
CMD ["sh", "/opt/autorun/reboot.sh"]
遇到的问题:
配置apache2.4修改documentRoot出现You don't have permission to access / on this server
没有配置/etc/apache2/apache2.conf中的目录
docker启动后避免自动退出:
tail -f /dev/null
相关文件
reboot.sh
#!/bin/bash
/usr/sbin/php-fpm7.3
nginx
tail -f /dev/null
或者:
#!/bin/bash
/usr/sbin/php-fpm7.3
nginx -g "daemon off;"
apt-cache search php
注意大坑:fpm与nginx通讯使用9000端口形式,不要使用socket形式,出错率很高
猜你喜欢
- 2024-10-11 浅谈从PHP迁移至Golang(基础篇)(php传值到另一个php)
- 2024-10-11 相同逻辑的php与golang代码效率对比,最好语言落谁家…
- 2024-09-21 Promethues如何监控PHP(prometheus snmp监控)
- 2024-09-21 蓝易云 - 在centos中配置nginx+php的环境教程。
- 2024-09-21 Zabbix运维—监控php-fpm、redis服务
- 2024-09-21 Zabbix 5.2由浅入深之监控php-fpm
- 2024-09-21 PHP-FPM实现性能优化的方法(php-fpm 优化)
- 2024-09-21 PHP-FPM高负载的解决办法(php高负载解决方案)
- 2024-09-21 php-fpm的配置和优化(php-fpm调优)
- 2024-09-21 docker中运行php文件(docker php fpm)
你 发表评论:
欢迎- 最近发表
-
- Linux新手必看:几种方法帮你查看CPU核心数量
- linux基础命令之lscpu命令(linux中ls命令的用法)
- Linux lscpu 命令使用详解(linux常用ls命令)
- 如何查询 Linux 中 CPU 的数量?这几个命令要知道!
- 在linux上怎么查看cpu信息(linux如何查看cpu信息)
- 查看 CPU 的命令和磁盘 IO 的命令
- 如何在CentOS7上改变网卡名(centos怎么改网卡名字)
- 网工必备Linux网络管理命令(网工必备linux网络管理命令是什么)
- Linux 网络命令知多少(linux 网络 命令)
- Linux通过命令行连接wifi的方式(linux命令行连接无线网)
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)