资讯专栏INFORMATION COLUMN

腾讯云使用笔记一: 腾讯云重装记录

ThreeWords / 1099人阅读

摘要:或少了因为启动时不是账号,就会这样前面别忘了加文件直接下载,不解析因为没有配置的解决办法引起通常是三种情况一是缺少索引文件,二是权限问题,三是状态。

========腾讯云重装记录================

安装时间:2018-09-09 12:15开始,结束时间:

一:重装操作系统

进入腾讯云后台,微信扫码登录

选择主机/更多/重装系统/服务市场/Docker容器/腾讯云容器服务镜像Ubuntu(cloud-init)

安装的是Ubuntu server 16.04,耗时2分钟

ubuntu@VM-0-8-ubuntu:~$ sudo uname -a
Linux VM-0-8-ubuntu 4.10.0-32-generic #36~16.04.1-Ubuntu SMP Wed Aug 9 09:19:02 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
//或
ubuntu@VM-0-8-ubuntu:~$ cat /etc/issue
Ubuntu 16.04.1 LTS 
 l
//或
ubuntu@VM-0-8-ubuntu:~$ cat /proc/cpuinfo
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 79
model name    : Intel(R) Xeon(R) CPU E5-26xx v4
stepping    : 1
microcode    : 0x1
cpu MHz        : 2394.454
cache size    : 4096 KB
physical id    : 0
siblings    : 1
core id        : 0
cpu cores    : 1
apicid        : 0
initial apicid    : 0
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx lm constant_tsc rep_good nopl pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch bmi1 avx2 bmi2 rdseed adx xsaveopt
bugs        :
bogomips    : 4788.90
clflush size    : 64
cache_alignment    : 64
address sizes    : 40 bits physical, 48 bits virtual
power management:

使用xshell(或putty等)远程登录服务器,用户名是ubuntu

二:ubuntu中增加root用户

给root用户设密码

ubuntu@VM-0-8-ubuntu:~$ sudo passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

开启root的ssh登录权限
默认 ubuntu是没有开启root的ssh登录权限的,修改sshd配置文件

// sudo vim /etc/ssh/sshd_config
#PermitRootLogin prohibit-password
PermitRootLogin yes

现在很方便,可以使用winscp之类的上传和编辑文件了

三:安装nginx(与apache2自选一)
ubuntu@VM-0-8-ubuntu:~$ sudo apt-get -y install nginx
//
ubuntu@VM-0-8-ubuntu:~$ nginx -v
nginx version: nginx/1.10.3 (Ubuntu)

有关nginx的命令请参考 ubuntu@VM-0-8-ubuntu:~$ sudo nginx -h
测试
在浏览器中输入http://134.175.42.125/(腾讯云主机ip地址),显示Welcome to nginx!,表示安装成功

三: 安装apache2
ubuntu@VM-0-8-ubuntu:~$ sudo apt-get -y install apache2
四:安装php7.0

先只装php,相关扩展根据需要再安装

ubuntu@VM-0-8-ubuntu:~$ sudo apt-get install php7.0
// ubuntu@VM-0-8-ubuntu:~$ sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv php7.0-soap
//当前版本是7.0.30
ubuntu@VM-0-8-ubuntu:~$ php -v
PHP 7.0.30-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.30-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

到这里请配置好nginx,这里最容易卡住
先初步配置nginx

五:安装mysql

中间会要求输入root密码

ubuntu@VM-0-8-ubuntu:~$ sudo apt-get install mysql-server mysql-client
// 版本是5.7.23-0ubuntu0.16.04.1
ubuntu@VM-0-8-ubuntu:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 7
Server version: 5.7.23-0ubuntu0.16.04.1 (Ubuntu)

到此约10分钟,现在花点时间在配置上,让它支持php

ubuntu@VM-0-8-ubuntu:~$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/1.conf
ubuntu@VM-0-8-ubuntu:~$ sudo ln /etc/apache2/sites-available/1.conf /etc/apache2/sites-enabled/1.conf

// 这是史上最短的配置文件

    ServerName www.fangshuixiushan.cn
    DocumentRoot /var/www/fangshuixiushan/cms/www


ubuntu@VM-0-8-ubuntu:~$ su
Password: 
root@VM-0-8-ubuntu:/home/ubuntu# sudo echo -e ""  > /var/www/fangshuixiushan/cms/www/index.php
六:安装并配置svn服务器 A:安装
ubuntu@VM-0-8-ubuntu:~$ sudo apt-get install subversion
//版本是1.9.3
ubuntu@VM-0-8-ubuntu:~$ svn --version
svn, version 1.9.3 (r1718519)
B:创建仓库

很多目录可以放subversion文件仓库,最常见的是/usr/local/svn和/home/svn

// 一个客户建一个仓库,方便管理
sudo mkdir -p /home/svn/fangshuixiushan
sudo svnadmin create /home/svn/fangshuixiushan
//说明:先创建目录(-p多级创建),再在该目录下新建版本库
//现在/home/svn/fangshuixiushan/conf/svnserve.conf, passwd ,authz三个配置文件,先备份下
cd /home/svn/fangshuixiushan/conf
ubuntu@VM-0-8-ubuntu:/home/svn/fangshuixiushan/conf$ sudo cp svnserve.conf svnserve.conf.bak
ubuntu@VM-0-8-ubuntu:/home/svn/fangshuixiushan/conf$ sudo cp passwd passwd.bak
ubuntu@VM-0-8-ubuntu:/home/svn/fangshuixiushan/conf$ sudo cp authz authz.bak
C:配置svn
// 快速方法,切换到root后执行下面三条命令
sudo echo -e "[general]
anon-access=read
auth-access=write
password-db=passwd
authz-db=authz
[sasl]"  > /home/svn/fangshuixiushan/conf/svnserve.conf
sudo echo -e "[users]
aaaa=aaaamima
bbbb=bbbbmima"  > /home/svn/fangshuixiushan/conf/passwd
sudo echo -e "[groups]
develop=aaaa,bbbb
manger=aaaa
[/]
@develop=rw
*=r"  > /home/svn/fangshuixiushan/conf/authz
// sudo vim svnserve.conf  
// /home/svn/fangshuixiushan/conf/svnserve.conf文件的内容如下
[general]
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
[sasl]

// sudo vim passwd
// /home/svn/fangshuixiushan/conf/passwd文件的内容如下
[users]
aaaa=aaaamima
bbbb=bbbbmima

// sudo vim authz
// /home/svn/fangshuixiushan/conf/authz(先备份)
[groups]
develop = aaaa,bbbb
manger = aaaa
[/]
@develop=rw
*=r
D:编辑腾讯云安全组

添加规则
0.0.0.0/0 TCP:3690 允许 -
否则会拒绝svn访问

E:本地安装客户端TortoiseSVN

不是服务器,是本地安装,下载地址

F:测试

先重启svn

svnserve -d -r /home/svn
//如果报错svnserve: E000098: Can"t bind server socket: Address already in use
查下svn当前占的端口
root@VM-0-14-ubuntu:~# ps -aux | grep svn
root     16960  0.0  0.1  72492   940 ?        Ss   14:29   0:00 svnserve -d -r /home/svn
root     19765  0.0  0.0  13232   880 pts/5    S+   15:20   0:00 grep --color=auto svn
//kill进程
kill -9 16960 
// 或直接killall svnserve关闭
//再启动
sudo svnserve -d -r /home/svn

仓库路径为 svn://134.175.42.125/fangshuixiushan/
在本地使用TortoiseSVN 检出(checkout)成功,新建一文件上传,也成功,ok,万里长征,完成60%

G: 如何让svn代码与web网站同步(这才是重点)

新建或编辑提交后钩子

ubuntu@VM-0-8-ubuntu:/home/svn/fangshuixiushan/hooks$ sudo vim post-commit
ubuntu@VM-0-8-ubuntu:/home/svn/fangshuixiushan/hooks$ sudo chmod 777 /home/svn/fangshuixiushan/hooks/post-commit

内容如下

#!/bin/bash
# 基本变量
company=fangshuixiushan #只需要替换这里就行
export LANG=en_US.UTF-8
dateTime=`date +%F`
dateTimeMinute=`date +%H%M%S`
binSvn=/usr/bin/svn                     # 你svn命令的绝对路径,如果不知道,请用find / -name svn查找
dirHtmlApp=/var/www/${company}/      # 检出的web站点根目录,请先建好,一开始就是一个空目录,权限为0666
logFileName=/tmp/${company}_svnhooks_${dateTime}.log #变量名加{}
# svn配置
#   [1] REPOS-PATH   仓库路径
#   [2] REV          刚执行修订版本号
#   [3] TXN-NAME     (the name of the transaction that has become REV)
REPOS="$1" 
REV="$2"

# 检出或者更新subversion,钩子的核心功能
echo  "-- $dateTimeMinute" >> $logFileName

# 先要将svn仓库中的内容检出到网站对应的目录中,如何判断有没有检出过呢,就是看是否有文件夹.svn
# 如是检出过,就直接更新就行

if [ ! -d $dirHtmlApp/.svn ]; then
   # 检出SVN
   echo "$binSvn co file://$REPOS/  $dirHtmlApp" >> $logFileName
   # 使用命令co检出
   $binSvn co file://$REPOS/  $dirHtmlApp
   if [ $? -eq 0 ]; then
      echo  "checkout ok"  >> $logFileName
   else
      echo  "checkout error"   >>  $logFileName
   fi
else

   # 更新svn
   echo " $binSvn up $REV $dirHtmlApp " >> $logFileName
   # 使用up命令更新
   $binSvn up $REV $dirHtmlApp   >> $logFileName
   if [ $? -eq 0 ]; then
      echo  "  update sucess "  >> $logFileName
   else
       echo  "  update fial "   >>  $logFileName
   fi
fi
echo  "--" >>  $logFileName
exit 0 #少行,有时会报exit code 255错误

建议先用测试下,检出,上传,删除后,确认无误后再进行批量操作

常见问题

提交、检出报错
Unable to connect to a repository at URL "svn://134.175.42.125/fangshuixiushan"
Can"t connect to host "134.175.42.125": 由于目标计算机积极拒绝,无法连接。
原因1:svn服务未启动,执行 svnserve -d -r /home/svn启动svn服务器

Unable to connect to a repository at URL "svn://134.175.42.125/fangshuixiushan"
line 1: Section header expected
原因:一般是本个配置文件格式或哪里多了空格之类的,也有可能写掉了什么如[genereal]

can"t open file db/txn-current-lock:permission denied
原因:权限不够
post-commit hook failed (exit code 255) with no output.
原因: post-commit 脚本文件的权限不对,post-commit 脚本必须有 +x 权限。
sudo chmod 777 /home/svn/fangshuixiushan/hooks/post-commit
sudo chmod +x /home/svn/fangshuixiushan/hooks/post-commit
或少了 #!/bin/bash

Can"t open file "/home/svn/fangshuixiushan/db/txn-current-lock": Permission denied
因为启动时不是root账号,就会这样,vnserve -d -r /home/svn前面别忘了加sudo svnserve -d -r /home/svn
php文件直接下载,不解析
因为没有配置 fastcgi_pass unix:/run/php/php7.0-fpm.sock;
403 forbidden的解决办法
引起nginx 403 forbidden通常是三种情况:一是缺少索引文件,二是权限问题,三是SELinux状态。
post-commit hook failed (exit code 255) with no output.
sudo chmod -R 755 /var/www/fangshuixiushan/cms/www

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/48041.html

相关文章

  • 腾讯使用笔记: 腾讯重装记录

    摘要:或少了因为启动时不是账号,就会这样前面别忘了加文件直接下载,不解析因为没有配置的解决办法引起通常是三种情况一是缺少索引文件,二是权限问题,三是状态。 ========腾讯云重装记录================ 安装时间:2018-09-09 12:15开始,结束时间: 一:重装操作系统 进入腾讯云后台,微信扫码登录 选择主机/更多/重装系统/服务市场/Docker容器/腾讯云容器...

    ashe 评论0 收藏0
  • 腾讯使用笔记: 腾讯重装记录

    摘要:或少了因为启动时不是账号,就会这样前面别忘了加文件直接下载,不解析因为没有配置的解决办法引起通常是三种情况一是缺少索引文件,二是权限问题,三是状态。 ========腾讯云重装记录================ 安装时间:2018-09-09 12:15开始,结束时间: 一:重装操作系统 进入腾讯云后台,微信扫码登录 选择主机/更多/重装系统/服务市场/Docker容器/腾讯云容器...

    xiaotianyi 评论0 收藏0
  • 腾讯操作系统和阿里服务器系统如何选择?

    摘要:腾讯云系统镜像哪阿里云服务器有哪些操作系统阿里云操作系统怎么选择阿里云服务器有哪些操作系统阿里云总共提供了两大类和,一共有种操作系统可以选择。腾讯云和阿里云操作系统如何选择?腾讯云和阿里云服务器提供了很多公共镜像,当时我们发现之前的操作系统不适合我们业务的时候,我们可以更换系统。我们后来要更换,应该怎么办呢?更换系统镜像就相当于重装系统了,阿里云和腾讯云服务器更换系统支持这个操作的。   ...

    DangoSky 评论0 收藏0
  • 从 node服务部署,到https配置与nginx转发

    从 node服务部署,到https配置与nginx转发 最近在搞小程序,小程序的服务必须使用https协议,之前没学过这些,于是写下这篇博客,记录自己遇到的问题 本篇博客解决这些问题,服务器的登陆配置、项目的部署、https证书的申请、nginx部署https与转发本地服务 通过私钥登陆服务器 腾讯云重装系统 登陆设置选择使用ssh密钥设置 选择ssh密钥,如果没有则创建ssh密钥 点击开始安装...

    molyzzx 评论0 收藏0
  • 从 node服务部署,到https配置与nginx转发

    从 node服务部署,到https配置与nginx转发 最近在搞小程序,小程序的服务必须使用https协议,之前没学过这些,于是写下这篇博客,记录自己遇到的问题 本篇博客解决这些问题,服务器的登陆配置、项目的部署、https证书的申请、nginx部署https与转发本地服务 通过私钥登陆服务器 腾讯云重装系统 登陆设置选择使用ssh密钥设置 选择ssh密钥,如果没有则创建ssh密钥 点击开始安装...

    douzifly 评论0 收藏0

发表评论

0条评论

ThreeWords

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<