docker容器中开启ssh登陆,实现xshell xftp连接,phpstorm使用容器php环境调试
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。o_0。
更新时间:
2020-12-30 14:27:51
温馨提示:
技术类文章有它的时效性,请留意文章更新时间,如发现内容有误请留言指出,防止别人"踩坑",我会及时更新文章
因为一部分原因,需要在windows下开发,但执行测试时需要使用linux下的php环境(支持并发(多进程)等特性).因为我linux下环境是使用docker搭建的,phpstorm是可以使用ssh登陆到linux服务器使用php做为cli环境的解析器的,于是就这有篇文章
进行容器shell
docker exec -it php74 /bin/sh
替换仓库地址
echo "http://mirrors.aliyun.com/alpine/latest-stable/main/" > /etc/apk/repositories echo "http://mirrors.aliyun.com/alpine/latest-stable/community/" >> /etc/apk/repositories
docker容器中开启ssh登陆,注意修改里面的root用户密码
apk add openssh-server && \ apk add openssh && \ sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config && \ sed -i "s/#Port.*/Port 22/g" /etc/ssh/sshd_config && \ ssh-keygen -t dsa -P "" -f /etc/ssh/ssh_host_dsa_key && \ ssh-keygen -t rsa -P "" -f /etc/ssh/ssh_host_rsa_key && \ ssh-keygen -t ecdsa -P "" -f /etc/ssh/ssh_host_ecdsa_key && \ ssh-keygen -t ed25519 -P "" -f /etc/ssh/ssh_host_ed25519_key && \ echo "root:****" | chpasswd
启动服务
/usr/sbin/sshd -D &
查看启动状态
ps -a
查看配置
vi /etc/ssh/sshd_config
宿主机开放端口为22022
phpstorm配置容器中的php环境为解析器