Ubuntu配置远程登陆
注意:我自己操作发现
CentOS默认是支持ssh远程登录,Ubuntu默认不支持,不知道是否都是这样,如果使用命令行登录提示权限被拒可执行以下步骤
- 重置服务器密码
 CentOS、Ubuntu都需要重置,区别是重置的时候CentOS默认重置的是root密码,Ubuntu需要手动切换root或者ubuntu去重置
- 查看Ubuntu是否开启了ssh
 如果未安装服务参考service sshd status
- 切换rootsu root
- 编辑ssh配置项
 编辑/etc/ssh/sshd_config文件vi /etc/ssh/sshd_config 输入i进入编辑模式,找到PermitRootLogin和PasswordAuthentication PermitRootLogin yes ...... PasswordAuthentication yes ESC 退出编辑模式 ==> :wq 保存退出
- 重新启动SSH服务sudo service ssh restart
- 使用命令行重新登录
    ssh root@101.35.235.239
安装swift开发环境
- 安装swift环境的依赖包apt-get install \ binutils \ git \ libc6-dev \ libcurl4 \ libedit2 \ libgcc-5-dev \ libpython2.7 \ libsqlite3-0 \ libstdc++-5-dev \ libxml2 \ pkg-config \ tzdata \ zlib1g-dev
- 下载swift包
 下载地址参考
 tips鼠标悬停对应版本右键复制链接地址wget -c https://download.swift.org/swift-5.6.2-release/ubuntu1804/swift-5.6.2-RELEASE/swift-5.6.2-RELEASE-ubuntu18.04.tar.gz
- 解压
 注意网上有些教程没有-C参数,会报错,加上就好了tar -xvzf swift-5.6.2-RELEASE-ubuntu18.04.tar.gz -C ~/swift/
- 配置
    vi ~/.bashrc # 末尾添加: export PATH=/root/swift/swift-5.6.2-RELEASE-ubuntu18.04/usr/bin:$PATH # 保存退出 # 执行以下代码使设置生效: source ~/.bashrc
- 验证
    swift -version # 输出如下: # Swift version 5.6.2 (swift-5.6.2-RELEASE) # Target: x86_64-unknown-linux-gnu
安装vapor
- 安装toolbox
 github上查看最新版本git clone https://github.com/vapor/toolbox.git cd toolbox git checkout 18.5.1 # 这里的版本就是上面链接中的最新版本 make install # 其他版本安装方案【未尝试】 git clone https://github.com/vapor/toolbox.git cd toolbox git checkout <desired version> #下载下来可能是最新的版本,可以直接使用 swift build -c release --disable-sandbox --enable-test-discovery mv .build/release/vapor /usr/local/bin
- 查验
    vapor --help # 提示如下 Usage: vapor <command> Vapor Toolbox (Server-side Swift web framework) Commands: build Builds an app in the console. clean Cleans temporary files. heroku Commands for working with Heroku. new Generates a new app. run Runs an app from the console. Equivalent to `swift run Run`. The --enable-test-discovery flag is automatically set if needed. supervisor Commands for working with supervisord. xcode Opens an app in Xcode. Use `vapor <command> [--help,-h]` for more information on a command.
创建项目
- 新建hello项目vapor new hello -n
- 编译【这个步骤比较慢,翻墙可节约时间】cd hello vapor build #编译项目
- 运行
    vapor run serve #启动项目 #[ NOTICE ] Server starting on http://127.0.0.1:8080 默认启动的是本地服务,还无法在外网访问 #另起一个shell,查看端口占用 lsof -i:8080 #输出如下: #Run 8960 root 8u IPv4 70957 0t0 TCP localhost:http-alt (LISTEN)
- 配置外网访问
    # 注意这里需要是内网ip,然后浏览器使用外网ip访问 vapor run serve -b 10.0.16.2:8080
FEATURED TAGS
                        
                            
                                
                                    iOS
                                
                            
                        
                            
                                
                                    OC
                                
                            
                        
                            
                                
                                    C
                                
                            
                        
                            
                                
                                    Xcode
                                
                            
                        
                            
                                
                                    MIMEType
                                
                            
                        
                            
                                
                                    屏幕旋转
                                
                            
                        
                            
                                
                                    Mac
                                
                            
                        
                            
                                
                                    工具
                                
                            
                        
                            
                                
                                    SQLite3
                                
                            
                        
                            
                                
                                    重命名
                                
                            
                        
                            
                                
                                    证书+内购
                                
                            
                        
                            
                                
                                    Pod
                                
                            
                        
                            
                                
                                    像素
                                
                            
                        
                            
                                
                                    pch
                                
                            
                        
                            
                                
                                    支付协议税务
                                
                            
                        
                            
                                
                                    APP转让
                                
                            
                        
                            
                                
                                    审核
                                
                            
                        
                            
                                
                                    银行卡格式化
                                
                            
                        
                            
                                
                                    git
                                
                            
                        
                            
                                
                                    描述文件
                                
                            
                        
                            
                                
                                    命令行
                                
                            
                        
                            
                                
                                    沙盒日志
                                
                            
                        
                            
                                
                                    i386
                                
                            
                        
                            
                                
                                    x86_64
                                
                            
                        
                            
                                
                                    控制台log
                                
                            
                        
                            
                                
                                    xcode10&iOS12
                                
                            
                        
                            
                                
                                    正则
                                
                            
                        
                            
                                
                                    textfield
                                
                            
                        
                            
                                
                                    输入限制
                                
                            
                        
                            
                                
                                    真机支持
                                
                            
                        
                            
                                
                                    封面尺寸
                                
                            
                        
                            
                                
                                    SDWebImage
                                
                            
                        
                            
                                
                                    Ruby
                                
                            
                        
                            
                                
                                    RVM
                                
                            
                        
                            
                                
                                    渐变色
                                
                            
                        
                            
                                
                                    jekyll
                                
                            
                        
                            
                                
                                    水印
                                
                            
                        
                            
                                
                                    富文本
                                
                            
                        
                            
                                
                                    标签
                                
                            
                        
                            
                                
                                    M3U8
                                
                            
                        
                            
                                
                                    动、静态库
                                
                            
                        
                            
                                
                                    异步上传
                                
                            
                        
                            
                                
                                    Url编码解码
                                
                            
                        
                            
                                
                                    AlertController
                                
                            
                        
                            
                                
                                    保活
                                
                            
                        
                            
                                
                                    pod报错
                                
                            
                        
                            
                                
                                    特定UI横竖屏
                                
                            
                        
                            
                                
                                    Launch版本号
                                
                            
                        
                            
                                
                                    ijkplayer
                                
                            
                        
                            
                                
                                    适配
                                
                            
                        
                            
                                
                                    手势
                                
                            
                        
                            
                                
                                    截图
                                
                            
                        
                            
                                
                                    网络和信号
                                
                            
                        
                            
                                
                                    礼物缓存
                                
                            
                        
                            
                                
                                    手绘礼物
                                
                            
                        
                            
                                
                                    UIPickerView
                                
                            
                        
                            
                                
                                    文件权限
                                
                            
                        
                            
                                
                                    键盘和菜单
                                
                            
                        
                            
                                
                                    耗时卡顿
                                
                            
                        
                            
                                
                                    国际化
                                
                            
                        
                            
                                
                                    Paypal
                                
                            
                        
                            
                                
                                    AWSS3
                                
                            
                        
                            
                                
                                    npm、Node
                                
                            
                        
                            
                                
                                    控制台
                                
                            
                        
                            
                                
                                    warning
                                
                            
                        
                            
                                
                                    扩展
                                
                            
                        
                            
                                
                                    防盗链
                                
                            
                        
                            
                                
                                    动画
                                
                            
                        
                            
                                
                                    分析
                                
                            
                        
                            
                                
                                    CallKit
                                
                            
                        
                            
                                
                                    侧滑
                                
                            
                        
                            
                                
                                    重置根控制器
                                
                            
                        
                            
                                
                                    播放器
                                
                            
                        
                            
                                
                                    裁剪
                                
                            
                        
                            
                                
                                    日志
                                
                            
                        
                            
                                
                                    bugly
                                
                            
                        
                            
                                
                                    uniapp
                                
                            
                        
                            
                                
                                    Swift
                                
                            
                        
                            
                                
                                    文字翻转
                                
                            
                        
                            
                                
                                    跨域
                                
                            
                        
                            
                                
                                    WebClip
                                
                            
                        
                            
                                
                                    网络请求
                                
                            
                        
                            
                                
                                    地图导航
                                
                            
                        
                            
                                
                                    ZSH
                                
                            
                        
                            
                                
                                    SPM
                                
                            
                        
                            
                                
                                    Vapor
                                
                            
                        
                            
                                
                                    导航
                                
                            
                        
                            
                                
                                    验证码
                                
                            
                        
                            
                                
                                    杀进程
                                
                            
                        
                            
                                
                                    Ubuntu
                                
                            
                        
                            
                                
                                    Android
                                
                            
                        
                            
                                
                                    JWT
                                
                            
                        
                            
                                
                                    vue
                                
                            
                        
                            
                                
                                    html-js
                                
                            
                        
                            
                                
                                    style-class
                                
                            
                        
                            
                                
                                    ssh
                                
                            
                        
                            
                                
                                    PHP
                                
                            
                        
                            
                                
                                    jks
                                
                            
                        
                            
                                
                                    css
                                
                            
                        
                            
                                
                                    Runtime
                                
                            
                        
                            
                                
                                    tree
                                
                            
                        
                            
                                
                                    uniCloud
                                
                            
                        
                            
                                
                                    圆角
                                
                            
                        
                            
                                
                                    flex
                                
                            
                        
                            
                                
                                    block
                                
                            
                        
                            
                                
                                    图形验证码
                                
                            
                        
                            
                                
                                    gtm
                                
                            
                        
                            
                                
                                    share
                                
                            
                        
                            
                                
                                    Combine
                                
                            
                        
                            
                                
                                    nvm
                                
                            
                        
                            
                                
                                    github
                                
                            
                        
                            
                                
                                    存储
                                
                            
                        
                            
                                
                                    备案
                                
                            
                        
                            
                                
                                    总结
                                
                            
                        
                    
                