Mysql
docker pull mysql:8.4
docker run --restart always -d -p 3306:3306 --name mysql-8.4 -v /Users/ethanxu/Docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_HOST=% -e MYSQL_ROOT_PASSWORD=12345678 --privileged=true mysql:8.4
Redis
docker pull redis:7.4
docker run --restart always -d -p 6379:6379 --name redis-7.4 --privileged=true redis:7.4
PHP
docker pull php:8.3-fpm
docker run --restart always -d -p 9000:9000 --name php-fpm-8.3 -v /Users/ethanxu/Docker/www/htdocs:/var/www/html -v /Users/ethanxu/Docker/php-fpm:/usr/local/etc/php/ --privileged=true php:8.3-fpm
# 开启mysqli扩展
docker exec -it php-fpm-8.3 bash
docker-php-ext-install mysqli
mkdir /usr/local/etc/php/conf.d/
docker-php-ext-enable mysqli
exit
docker restart php-fpm-8.3
Nginx
docker pull nginx:1.26
docker run --restart always -d -p 443:443 -p 80:80 --name nginx-1.26 -v /Users/ethanxu/Docker/www/htdocs:/usr/share/nginx/html -v /Users/ethanxu/Docker/nginx/conf.d/:/etc/nginx/conf.d -v /Users/ethanxu/Docker/nginx/logs/:/var/log/nginx --privileged=true nginx:1.26
server {
listen 80;
listen 443 ssl;
server_name localhost;
root /usr/share/nginx/html/test/;
index index.html;
ssl_certificate ./conf.d/ssl/localhost.pem;
ssl_certificate_key ./conf.d/ssl/localhost-key.pem;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location ~ \.php$ {
root /var/www/html/test;
fastcgi_pass 172.17.0.1:9000; #php容器的IP地址
fastcgi_index index.php; #默认主页文件设置
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}