服务器环境
[root@aliyun /]# uname -a
Linux aliyun 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@aliyun /]#
开始安装,依次执行:
yum install docker
service docker restart
docker pull nginx
docker pull php:7.1-fpm
docker run -p 80:80 -p 443:443 --name mynginx -v /root/docker/project:/www -v /root/docker/conf.d:/etc/nginx/conf.d -d nginx
docker run -p 9000:9000 --name myphp -v /root/docker/project:/home -d php:7.1-fpm
说明 :
端口-p 80:80意思是把容器80端口映射到本地80端口
-v /root/docker/project:/www 意思是把容器路径 /www映射到本地 /root/docker/project 路径下。发布项目方便
-v /root/docker/conf.d:/etc/nginx/conf.d 意思是把容器内nginx的/etc/nginx/conf.d目录映射到本地 /root/docker/conf.d。这样,修改配置只需要在本机直接修改就行,不需要进入容器。
补充: http自动跳https
#http.conf
server {
listen 80;
server_name app.xxx.com;
rewrite ^/(.*) https://$server_name$request_uri? permanent;
}
https
server {
listen 443;
server_name app.xxx.com;
index index.php index.html index.htm;
root /www/public;
error_log /usr/local/nginx/logs/app.xxx.com warn;
ssl on;
ssl_certificate cert/app.pem;
ssl_certificate_key cert/app.key;
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 / {
# client_body_timeout 5s;
# client_header_timeout 5s;
# limit_req zone=one;
# limit_conn addr 10;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ \.php {
#limit_req zone=one;
#limit_conn addr 100;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffers 8 128k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_index index.php;
include fastcgi_params;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
}
网友评论