记录第一次部署阿里云服务器经验

部署服务:

重置密码
配置安全规则,开放端口 (网络和安全组 -> 安全组配置 -> 添加开放端口)
重启服务器

远程连接:

	设置语言:echo $LANG
		临时设置:直接输入 LANG="zh_CN.UTF-8"
		永久设置:locale 查看是否有中文  须先下载中文支持包 yum groupinstall chinese-support
			编辑i18n配置文件: vi /etc/sysconfig/i18n
			进行如下配置并保存退出:(注释原有的英文配置并添加中文zh_CN.UTF-8)
			#LANG="en_US.UTF-8"
			LANG="zh_CN.UTF-8"
			LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"
			SUPPORTED="zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en"

环境设置:jdk & maven

	先去官网下载linux对应的工具包(rpm,tar.gz),解压缩
	vim /etc/profille   或者   vim /root/.bash_profile  添加如下配置
		unset -f pathmunge
		export JAVA_HOME=/opt/jdk1.8.0_221
		export PATH=$JAVA_HOME/bin:$PATH
		export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
		export MAVEN_HOME=/opt/apache-maven-3.6.1
		export PATH=$MAVEN_HOME/bin:$PATH

保存 source /etc/profille 或者 /root/.bash_profile 检查不报错 java -version mvn -version 查看当前版本
ps: (如果项目需要引用远程包)需要对 MAVEN_HOME/conf/setting.xml 添加部分配置:
servers 节点加入

		<servers>
			<server>
				<id>rdc-releases</id>
				<username>xxxx</username>
				<password>xxxxxxxx</password>
			</server>
			<server>
				<id>rdc-snapshots</id>
				<username>xxxxx</username>
				<password>xxxxxxxxx</password>
			</server>
		</servers>
	Profiles节点加入
<profile>
			<id>rdc-private-repo</id>
			<repositories>
				<repository>
					<id>rdc-releases</id>
					<url>https://repo.rdc.aliyun.com/</url>
				</repository>
				<repository>
					<id>rdc-snapshots</id>
					<url>https://repo.rdc.aliyun.com/</url>
				</repository>
			</repositories>
		</profile>

安装mysql:

	https://dev.mysql.com/downloads/repo/yum/
	wget -i -c http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
	yum -y install mysql80-community-release-el7-3.noarch.rpm
	yum -y install mysql-community-server
	启动mysql:systemctl start  mysqld.service
	查看mysql状态:systemctl status mysqld.service
	查看mysql初始密码:grep "password" /var/log/mysqld.log
	登录mysql重置密码:
		mysql -uroot -p‘密码’     # 不输入密码,回车后会提示输入密码
		新版本mysql 对密码设置有要求:
		修改为简单规则:
			SHOW VARIABLES LIKE 'validate_password%';				
			set global validate_password.policy=low;
			set global validate_password.length=1
		或者设置复杂密码: (eg:ALTER USER 'root'@'localhost' IDENTIFIED BY 'z?guwrBhH7p>'; )
	ps:以后每次yum操作都会自动更新,需要把这个卸载掉:
	 yum -y remove mysql80-community-release-el7-3.noarch
	 
	可视化工具的登录授权:(如果授权不成功,请查看防火墙)
		操作完成上面的,现在还不能用可视化的客户端进行连接,需要我们进行授权:
		1.(不太好用)
		 GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.xxx' IDENTIFIED BY 'xxx' WITH GRANT OPTION;
		 FLUSH PRIVILEGES;
		2.
		mysql>ALTER USER 'root'@'192.168.1.xxx' IDENTIFIED BY 'xxxxxxxx' PASSWORD EXPIRE NEVER
		mysql>ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxxxxx';
		mysql>FLUSH PRIVILEGES;

更换yum源:

	163 或者 中科大 阿里 
	先备份原有的yum: mv CentOS-Base.repo CentOS-Base.repo.bak
	获取需要的yum: wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
	讲新的yum作为base yum:mv CentOS6-Base-163.repo CentOS-Base.repo
	yum clean all
	yum makecache

安装nginx:

	yum install nginx
	一般自动安装在/etc 
		vim /etc/nginx/nginx.conf 
		将user改为登录username
		在 /etc/nginx/conf.d/ 下创建新的 admin.conf
upstream xx{
       server 127.0.0.1:8004 weight=1;
       server 127.0.0.1:8004 weight=1;
}

server {
        listen 80;
       server_name xxxxxxx;

        access_log  /var/log/nginx/access.log;
        error_log   /var/log/nginx/error.log;

        root /root/project/yunkong-web/dist;
        index index.html index.htm;

        location / {
         try_files $uri $uri/ /index.html last;
         index index.html;
        }

        location /applanding {
         alias /root/yunkong-web-landing;
         index /applanding/index.html;
         try_files $uri $uri/ /applanding/index.html;
        }

        location /api/v1/ {
         proxy_pass http://127.0.0.1:8000/;
         proxy_set_header X-Forwarded-Proto $scheme;
         proxy_set_header X-Forwarded-Port $server_port;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_set_header Host $http_host;
         proxy_set_header X-Real-IP $remote_addr;


       }

安装redis:

	yum install redis
	redis-server 启动redis
	redis-cli 
安装npm node.js
	yum install npm
	npm install -g cnpm --registry=https://registry.npm.taobao.org

克隆项目到服务器

	先配置秘钥:
	打开c:/Users/[用户名]/.ssh/id_rsa.pub, 并复制文件内容。
	进入代码中心(http://code.aliyun.com), 设置->SSH公钥,新增一个公钥并把id_rsa.pub的内容粘贴上去。保存公钥。
	
clone -> install -> build(web)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值