docker 搭建lnmp开发环境

初衷:平时开发的时候想让项目代码运行linux环境,避免一些在windows环境正常,linux有问题的情况,比如字符编码,小数那些;

 =>  至于docker的安装,我看的是菜鸟教程手动安装部分,因为用的是centos7,所以选择  18.03.1.ce 版本;

一,为了方便在windows下写代码,用 Samba 来实现linux的项目代码目录映射到windows,度娘一下根据他们的流程就可以搞出来,很简单的流程;

  首先把 防火墙和selinux关掉,我用的centos7,   systemctl disable firewalld ,  

vi /etc/selinux/config, 然后把SELINUX的值设置为disabled,但是selinux设置了开机不启动要重启才能生效, 执行 reboot

       其中可能碰到的问题就是,映射到windows后,点击提示无权限,解决方案: 赋予项目目录  chmod -R 777  权限,如果还是不行, 比如 root 目录下,在最外层赋予权限  chmod -R 777 /root 

  1.  yum install samba , 配置samba访问共享资源的用户,   pdbedit -a -u root , 回车输入root用户你要设置的密码就好, 我直接用root, 好记。

         2. 赋予访问共享资源用户对该文件的权限 ,  chown -Rf root:root /共享目录的路径 

   3. 配置samba conf文件,   vim /etc/samba/smb.conf 

[global]
log file = /var/log/samba/log.%m
max log size = 50
security = user

[www]
path=/home/Docker-LNMP/www
readonly=yes
browseable=yes
writable = yes
guest ok=yes

   4. 

# 重启smb服务
systemctl restart smb 

# 设置开机启动
systemctl enable smb 

   5. 打开运行窗口输入 \虚拟机ip , 再输入我们配置的共享用户:root 再输入密码 就可以访问共享目录了。

二,docker 搭建 LNMP, 可看下面 github 一个写好的按步骤操作,亲测有效;

      https://github.com/duiying/Docker-LNMP

      

     附上TP5.0设置的conf文件:

server {
        listen       80;
        server_name  xxx.com;
        root /data/www/项目目录名称/public;
    location / {  
        index index.html index.htm index.php admin.php; 
        if (!-e $request_filename) {
    rewrite ^/index.php(.*)$ /index.php?s=$1 last;
     rewrite ^(.*)$ /index.php?s=$1 last;
     break;
        }  
    }

        location ~ .php(.*)$ {
            fastcgi_pass cgi:9000;
        try_files $uri =404;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

以上,仅记录一下未接触过docker,想搞下docker的历程。(没接触过的推荐看菜鸟教程了解一下)

你的坚持 ------ 终将美好 ~
原文地址:https://www.cnblogs.com/pyspang/p/13554016.html