请输入手机号码
请输入密码
云服务器命令行安装软件通用流程及具体方法
在安装软件前,需先通过远程连接工具访问云服务器的命令行界面:
ssh username@server_ip_address(替换为你的云服务器用户名和IP地址),按提示输入密码登录。Linux系统(如Ubuntu、CentOS)自带包管理器,可快速安装、更新和管理软件,是主流安装方式。
sudo apt update(Ubuntu 20.04及以上推荐apt,更简洁;旧版本可用apt-get)。sudo apt install nginx。系统会自动解决依赖关系并安装。nginx -v查看版本信息,或systemctl status nginx检查服务状态(若显示“active (running)”则表示运行中)。sudo yum update。sudo yum install httpd。sudo dnf update(更新)、sudo dnf install httpd(安装)。httpd -v查看版本,systemctl status httpd检查状态。若软件不在官方源中或需要自定义编译选项(如最新版本的Python、OpenSSL),可通过源码安装:
wget命令下载软件源码包(如OpenSSL 1.1.1t),命令:wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz。tar -zxvf openssl-1.1.1t.tar.gz(.tar.gz格式用此命令,.tar.bz2用tar -jxvf)。./config --prefix=/usr/local/openssl(--prefix指定安装路径,避免污染系统目录)。make编译源码(耗时较长),sudo make install将编译好的文件安装到指定路径。/usr/local/openssl/bin/openssl version查看OpenSSL版本,确认安装成功。若使用Windows云服务器(如Windows Server),可通过命令行安装软件:
Enter-PSSession -ComputerName server_ip -Credential username)。Invoke-WebRequest命令下载安装包(如Chrome),命令:Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile "C:\Temp\chrome_installer.exe"。Start-Process -FilePath "C:\Temp\chrome_installer.exe" -ArgumentList "/silent /install"静默安装)。chrome --version查看版本。sudo apt update/sudo yum update),确保获取最新版本。sudo apt install libssl-dev)。ufw allow 80/tcp/firewall-cmd --add-port=80/tcp --permanent)中开放对应端口(如80、443)。sudo(超级用户权限),避免权限不足导致安装失败。