当前位置: 首页 > Linux

小白教程-阿里云-centos零入门配置环境

时间:2023-04-06 06:01:09 Linux

前言:最近阿里云搞活动,很多人买了服务器却不知道如何入手(牙膏小前端),最简单的配置过程,不喜勿喷。1、前期准备一个简单的linxu基础,创建用户,编辑,保存,打开文件。阿里云服务器centos764位(最低配置即可)远程登录ssh客户端(Xshell5)2.阿里云服务器配置重置阿里云实例密码(第一次ssh登录root需要-https://help.aliyun.com/docum...xshell配置登录-公网ip+root+实例密码-(https://help.aliyun.com/docum...阿里云安全组设置可以设置进入方向(https://help.aliyun.com/docum...)三个环境开始搭建1.xshellroot登录服务器(linxu-root用户权限太大,一般新建一个用户,赋予sudo权限。)创建sudo用户的基本步骤#创建用户$useradd-mhxc#为新创建的用户设置密码,回车后输入新密码$passwddaiyu#切换到root账户,为sudo文件添加写权限,默认是读权限$chmodu+w/etc/sudoers#打开文件vi/etc/suduers,在rootALL=(ALL)ALL这一行下添加$daiyuALL=(ALL)ALL#取消写权限再次sudo文件$chmodu-w/etc/sudoers2.用新创建的用户再次登录,启动环境搭建初始化系统和安装基本工具#更新系统$sudoyumupdate#安装wget,git,vimtab补全....$sudoyuminstall-ywgetgitvimlrzsztreenet-toolsbash-c*installnginx#addnginxsource$sudorpm-Uvhhttp://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rp#安装最新版本的ginx$sudoyuminstall-ynginx#启动nginx服务$sudosystemctlstartnginx.service#设置Nginx自动开机$sudosystemctlenablenginx.service添加nginx配置(vim操作还是需要了解)#添加配置(也可以自己创建一个,vim命令,不存在时会创建)$sudovim/etc/nginx/conf.d/mytest.conf把下面的配置复制到上面的confserver{listen80;服务器名称hxc2.test;#你的域名位置/{root/home/xinchun;#代码文??件主目录indexindex.htmlindex.htmindex.php;}}#Restartnginx$sudosystemctlrestarttnginx关闭防火墙#停止防火墙$sudosystemctlstopfirewalld.service#禁止防火墙启动$sudosystemctldisablefirewalld.service$sudovim/etc/selinux/config#将SELINUX=enforcing改为selinux=disabled,保存退出$sudosetenforce0configurehosts#打开hosts文件$sudovim/etc/selinux/config#添加你上面配置的域名127.0.0.1hxc.test4.大功告成大功告成,如果有域名,使用域名解析到公网ip,没有域名,加入windows的hosts---公网iphxc.test