0%

虚拟机部署流程

  • 云主机:阿里云主机
  • 操作系统:CentOS release 6.9 (Final)
    (本文档只记录大概步骤,可能有不详细的地方,暂且看看)

    1. 创建普通用户

    1
    2
    useradd xxx
    passwd xxx

useradd vs adduser

Debian / Ubuntu
On Debian or Ubuntu systems, useradd is a command itself, and you can create users and define options to them using this command, and adduser is a perl script, that uses useradd to create the account, asking you the password, Full-name, phone and others
Fedora / Centos
On Fedora or CentOS systems, adduser is just a symbolic link to useradd, but may try to copy the script from a Debian system to the CentOS one, I have never tried it, and may need to modify it a little before using it.

引用并感谢作者:

2. 添加互信

  • 在远程机器上执行

    1
    ssh-keygen -t rsa

    一直按回车键。

  • 将本地主机的 .ssh/id_rsa.pub 内容写入到远程主机的 .ssh/authorized_keys
  • 修改远程主机文件权限:
    1
    2
    # 之前权限为 664,导致添加互信失败,改为 660 后,互信成功
    chmod 600 .ssh/authorized_keys

3. Tab 补全无效

比如,可以补全yum,但无法补全yum 参数

1
2
yum -y install bash-completion bash-completion-extras
source /etc/profile.d/bash_completion.sh

引用并感谢作者:
How to Install and Enable Bash Auto Completion in CentOS/RHEL

4. 源码安装nginx

  • 步骤:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 下载 Nginx 源码安装必须的三个依赖库, 并分别解压
wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget https://www.openssl.org/source/openssl-1.0.2o.tar.gz
# 下载源码:
wget http://nginx.org/download/nginx-1.14.0.tar.gz
# 解压:
tar -zxvf nginx-1.14.0.tar.gz

# configure
./configure \
--with-openssl=../openssl-1.0.2o \
--with-zlib=../zlib-1.2.11 \
--with-pcre=../pcre-8.40 \
--prefix=/home/xxx/local/nginx
# --prefix=绝对路径
make
# 报错
# configure: error: You need a C++ compiler for C++ support.
yum install gcc-c++

make install
  • 启动nginx报错
    1
    nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

端口号 < 1000, 需要root权限

5. 源码安装openresty

基本与安装nginx完全一致

6. 安装PHP7.2

1
2
3
4
5
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
yum install php72
yum install php72-php-fpm.x86_64

7. 安装 hexo

1
2
3
wget https://nodejs.org/dist/v7.0.0/node-v7.0.0-linux-x64.tar.xz
npm install -g hexo-cli
hexo init