docker搭建lnmp環(huán)境

發(fā)布時間:2024-01-31
創(chuàng)建項目目錄
mkdir php創(chuàng)建如下項目結(jié)構(gòu)
sites 目錄放置項目文件services 目錄放置服務(wù)相關(guān)配置script 放置自定義腳本├── readme.md ├── docker-compose.yml ├── script ├── services │ ├── mariadb │ │ └── dockerfile │ ├── nginx │ │ ├── dockerfile │ │ ├── conf.d │ │ │ └── default.conf │ │ └── nginx.conf │ ├── php │ │ └── dockerfile │ └── redis │ └── dockerfile └── sites ├── index.html └── index.php 8 directories, 10 files 編輯docker-compose文件
version: 3 services: php: build: ./services/php # ports: # - 9001:9000 container_name: lnmp-php restart: always volumes: - ./sites:/www networks: lnmp_net: ipv4_address: 101.11.11.10 nginx: build: ./services/nginx ports: - 81:80 - 444:443 container_name: lnmp-nginx restart: always volumes: - ./sites:/www - ./services/nginx/nginx.conf:/etc/nginx/nginx.conf - ./services/nginx/conf.d:/etc/nginx/conf.d:rw networks: lnmp_net: ipv4_address: 101.11.11.11 networks: lnmp_net: driver: bridge ipam: config: - subnet: 101.11.11.0/20 編輯services/nginx文件
from nginx:1.17.0-alpine # 更新安裝源 run sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories # 設(shè)置時區(qū)為上海 run apk update && apk add --upgrade \ && apk add tzdata \ && cp /usr/share/zoneinfo/asia/shanghai /etc/localtime \ && echo asia/shanghai > /etc/timezone \ && apk del tzdata 編輯services/php文件
from php:7.3.6-fpm-alpine3.9 # 更新安裝源 run sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories # 設(shè)置時區(qū)為上海 run apk update && apk add --no-cache tzdata autoconf gcc g++ make zlib-dev curl-dev\ && cp /usr/share/zoneinfo/asia/shanghai /etc/localtime \ && echo asia/shanghai > /etc/timezone \ && apk del tzdata \ && docker-php-ext-install mysqli pdo_mysql opcache \ && pecl install grpc protobuf xdebug yaf yar swoole \ && docker-php-ext-enable xdebug yaf yar swoole grpc protobuf 以上我們的lnmp環(huán)境基本搭建完畢,下面我們針對php解析做相關(guān)的配置
修改services/nginx/nginx.conf,可根據(jù)需求自行修改
user nginx; worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] $request ' '$status $body_bytes_sent $http_referer ' '$http_user_agent $http_x_forwarded_for'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } 修改services/nginx/conf.d目錄下文件
該目錄是各個項目的配置文件,可根據(jù)需求配置單個或多個服務(wù)
server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; #root /usr/share/nginx/html; root /www; index index.php index.html index.htm; #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the php scripts to apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the php scripts to fastcgi server listening on 127.0.0.1:9000 # location ~ \.php$ { # root html; fastcgi_pass 101.11.11.10:9000; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } 啟動服務(wù)
cd php && docker-compose up --build -d
上一個:一般電容故障現(xiàn)象及原因
下一個:電腦回收價格多少(電腦回收一般多少錢一臺)

iphone7home鍵不震動了咋辦(蘋果7home鍵震動失靈)
魅族m6跟mx6會不會一樣(魅族mx6和mx5)
TCP/IP體系結(jié)構(gòu)
固態(tài)硬盤的優(yōu)勢不包括( ),m2固態(tài)硬盤轉(zhuǎn)接卡優(yōu)勢
工業(yè)用地土地證可以抵押貸款嗎
簡單又大氣的戒托款式大全
美國福斯公司(品質(zhì)卓越的工業(yè)零部件供應(yīng)商)
淋雨試驗箱滿足技術(shù)標(biāo)準(zhǔn)
戴爾重新裝系統(tǒng)按f幾(戴爾電腦開機(jī)重裝系統(tǒng)按f幾)
vivo手機(jī)刷機(jī)怎么刷(vivo咋刷機(jī)視頻教程)
十八禁 网站在线观看免费视频_2020av天堂网_一 级 黄 色 片免费网站_绝顶高潮合集Videos