0
点赞
收藏
分享

微信扫一扫

LNMP 在docker中

参考的镜像地址

迁移php的项目记得把数据库一起迁走。

​​https://dockerfile.readthedocs.io/en/latest/content/DockerImages/dockerfiles/php-nginx.html​​

创建配置目录

mkdir -p /opt/docker/etc/nginx/conf.d
mkdir -p /opt/docker/etc/php/
touch /opt/docker/etc/php/php.ini
mkdir -p /www/web/
chown -R 1000:1000 /www/web/

编辑配置文件

vi /opt/docker/etc/nginx/conf.d/www.68guakao.com.conf
server {
listen 80;
server_name qq.com www.qq.com ;
root /app/qq.com;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";

index index.htm index.html index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^/admin.php(.*)$ /admin.php?s=$1 last;
rewrite ^/api.php(.*)$ /api.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}


location ~ \.php$ {
fastcgi_pass php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_read_timeout 600;
}

启动容器

docker pull webdevops/php-nginx:7.3-alpine
docker run -d -p 888:80 -p 4443:443--name guakao --restart always \
-v /opt/docker/etc/nginx/conf.d:/opt/docker/etc/nginx/conf.d \
-v /opt/docker/etc/php/php.ini:/opt/docker/etc/php/php.ini \
-v /www/web:/app \
-v /opt/docker/etc/nginx/ssl:/opt/docker/etc/nginx/ssl \
-e php.memory_limit=256M -e PHP_DISMOD=ioncube,redis,opcache,mongodb,pgsql,ldap,memcached -e PHP_DATE_TIMEZONE=PRC \
webdevops/php-nginx:7.3-alpine



举报

相关推荐

0 条评论