LNMP部署和双站点

一、LNMP部署
1、拉去镜像

docker pull 2233466866/lnmp


2、运行镜像为容器

docker run -d -it -p 8090:80 -p 8080:8080 -v /root/www/:/root/www/ --name hs0703_np --privileged 017

-d 后台运行
-it 可以进行交互
-p 端口映射  服务器端口:容器端口
-v 数据卷映射  服务器目录:容器内目录
--name 容器名字
--privileged  给root权限
017 镜像ID

 3、进入容器

docker exec -it 容器ID bash

 4、容器内目录和命令介绍

 /usr/local/nginx/conf/                  nginx配置文件
/www                                           放置项目文件
systemctl reload nginx                重新加载nginx配置文件
ss -nalt                                        查看对外的端口
ps -aux | grep  nginx/php            查看服务是否在跑

二、双站点

 1、找到/usr/local/nginx/conf/nginx.conf 文件

user                    www;
worker_processes        auto;
worker_cpu_affinity     auto;
pid                     logs/nginx.pid;

events {
    worker_connections  102400;
}

http {
    charset             utf-8;
    server_tokens       off;

    log_format  main    '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';

    include             mime.types;
    default_type        application/octet-stream;

    client_max_body_size 20M;

    sendfile            on;
    keepalive_timeout   20;

    gzip                on;
    gzip_vary           on;
    gzip_comp_level     1;
    gzip_types          text/css application/javascript application/json image/png image/webp image/apng image/jpeg image/x-icon;

    error_log           /www/z_error.log;
    access_log          /www/z_$host.log main;
    server {
        listen      80;
        server_name www.test.com;
        root         /www/;

        location / {
            index   index.php index.html index.htm;
        }

        location ~* \.php {
            include                 fastcgi_params;
            fastcgi_index           index.php;
            fastcgi_pass            127.0.0.1:9000;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param           PATH_INFO       $fastcgi_path_info;
            fastcgi_param           SCRIPT_NAME     $fastcgi_script_name;
            fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    }
    server {
        listen      80;
        server_name www.test.com;
        root         /www/;

        location / {
            index   index.php index.html index.htm;
        }

        location ~* \.php {
            include                 fastcgi_params;
            fastcgi_index           index.php;
            fastcgi_pass            127.0.0.1:9000;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param           PATH_INFO       $fastcgi_path_info;
            fastcgi_param           SCRIPT_NAME     $fastcgi_script_name;
            fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    }

}

2、主要就是server里边的内容,要几个站点就建几个server

3、server要修改listen(端口)、server_name(域名)、root(项目目录)---上面代码我没有修改这三项,根据自己需求更改。

4、重新加载nginx配置

systemctl reload nginx
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值