一、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