使用我们的服务,您可以轻松搭建稳定高效的Linux
云服务器,享受无与伦比的运行体验。
选择合适的Linux发行版
在搭建Linux云服务器之前,我们需要选择一个合适的Linux发行版,常见的Linux发行版有:Ubuntu、CentOS、Debian等,这里我们以Ubuntu为例进行介绍。
注册并登录阿里云账号
1、访问阿里云官网:https://www.aliyun.com/
2、点击页面右上角的“登录”,输入账号和密码进行登录。
3、如果还没有阿里云账号,请点击“免费注册”进行注册。
购买云服务器
1、登录后,点击页面上方的“产品”菜单,选择“云服务器ECS”。
2、在云服务器ECS页面,点击“立即购买”。
3、选择地域、实例规格、操作系统等信息,然后点击“立即购买”。
4、完成支付后,即可获得一台Linux云服务器。
远程连接云服务器
1、在云服务器ECS页面,找到刚刚购买的云服务器,点击右侧的“管理”按钮。
2、在弹出的“实例详情”页面,点击“远程连接”按钮。
3、在弹出的“远程连接”窗口中,复制左侧的公网IP地址。
4、打开本地计算机的终端(Windows用户可以使用PuTTY,Mac用户可以使用Terminal),输入以下命令:
ssh root@公网IP地址
5、按回车键,输入root用户的密码,即可远程连接云服务器。
安装常用软件
1、更新系统软件包列表:
sudo aptget update
2、安装常用软件:
软件名称 |
安装命令 |
Apache |
sudo aptget install apache2 |
Nginx |
sudo aptget install nginx |
PHP |
sudo aptget install php libapache2modphp |
Python |
sudo aptget install python3 python3pip |
Node.js |
curl sL https://deb.nodesource.com/setup_14.x |
sudo E bash && sudo aptget install y nodejs |
MySQL |
sudo aptget install mysqlserver |
Redis |
sudo aptget install redisserver |
Memcached |
sudo aptget install memcached |
Tomcat |
wget https://archive.apache.org/dist/tomcat/tomcat9/v9.0.56/bin/apachetomcat9.0.56.tar.gz |
tar xvfz apachetomcat9.0.56.tar.gz |
sudo mv apachetomcat9.0.56 /opt/tomcat |
Nginx + PHPFPM |
sudo aptget install nginx php7.4fpm php7.4cli |
Nginx + PHPFPM + Composer |
curl sS https://getcomposer.org/installer |
php composer.phar install global |
Nginx + PHPFPM + Composer + Node.js + NPM |
curl sL https://deb.nodesource.com/setup_14.x |
sudo E bash && sudo aptget install y nodejs |
npm install g n |
n latest |
Nginx + PHPFPM + Composer + Node.js + NPM + Yarn |
curl sS https://dl.yarnpkg.com/debian/pubkey.gpg |
echo “deb https://dl.yarnpkg.com/debian/ stable main” |
sudo tee /etc/apt/sources.list.d/yarn.list |
curl sL https://deb.nodesource.com/setup_14.x |
sudo E bash && sudo aptget install y nodejs yarn |
n latest |
配置防火墙和安全组规则
1、安装防火墙:
sudo aptget install firewalld
2、启动防火墙:
sudo systemctl start firewalld
3、设置防火墙开机自启:
sudo systemctl enable firewalld
4、查看防火墙状态:
sudo firewallcmd state
5、根据需要配置防火墙规则,例如开放80端口:
sudo firewallcmd zone=public addport=80/tcp permanent
6、重启防火墙使配置生效:
sudo firewallcmd reload
7、配置安全组规则:在云服务器ECS页面,找到刚刚购买的云服务器,点击右侧的“管理”按钮,在弹出的“实例详情”页面,点击“安全组”标签,点击“添加安全组规则”,根据需要配置入站和出站规则。
本文地址:https://www.henghost.com/news/article/80629/