1. 环境配置
1.1. 安装Node.js
- 1
- 2
- 3
- 4
- 5
- 6
mkdir /home/lib
cd /home/lib
wget https://nodejs.org/dist/v16.15.0/node-v16.15.0-linux-x64.tar.xz
tar -xJvf node-v16.15.0-linux-x64.tar.xz -C /usr/local/lib
vi ~/.bash_profile
. ~/.bash_profile
查看版本:
- 1
- 2
node -v
npm version
1.2. 安装全局依赖包
- 1
- 2
npm i -g @angular/cli @nestjs/cli cross-env pm2 typescript webpack
npm i -g npm@8.8.0
1.3. 安装Nginx
- 1
- 2
yum install yum-utils
vi /etc/yum.repos.d/nginx.repo
内容如下(参见:http://nginx.org/en/linux_packages.html):
- 1
- 2
- 3
- 4
- 5
- 6
- 7
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
继续执行命令:
- 1
- 2
yum install nginx
nginx -v
1.4. 配置并启动Nginx
- 1
- 2
- 3
- 4
- 5
cd /etc/nginx/conf.d/
cp default.conf ifuyun.conf
vi ifuyun.conf
service nginx start
service nginx status
1.5. 安装并启动MySQL
- 1
vi /etc/yum.repos.d/mysql-community.repo
内容如下(参见:https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/):
- 1
- 2
- 3
- 4
- 5
- 6
- 7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
继续执行命令:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
cd /etc/pki/rpm-gpg
wget http://repo.mysql.com/RPM-GPG-KEY-mysql-2022
wget http://repo.mysql.com/RPM-GPG-KEY-mysql
yum install mysql-community-server
vi /etc/my.cnf
systemctl start mysqld
systemctl status mysqld
1.6. 查看并修改MySQL初始密码
- 1
- 2
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
- 1
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
1.7. 安装Git
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
yum install zlib-devel curl-devel expat-devel gettext-devel openssl-devel
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.36.0.tar.gz
tar -zxvf git-2.36.0.tar.gz
cd git-2.36.0/
./configure --prefix=/usr/local
make
make install
git --version
1.8. 安装、配置、启动Redis
- 1
- 2
- 3
- 4
- 5
- 6
- 7
cd /home/lib/
wget https://download.redis.io/redis-stable.tar.gz
tar -xzvf redis-stable.tar.gz
cd redis-stable
make
make install
vi ./utils/install_server.sh
注释以下几行:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
#bail if this system is managed by systemd
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi
继续执行命令:
- 1
- 2
- 3
./utils/install_server.sh
vi /etc/redis/6379.conf
service redis_6379 restart
1.9. 安装IM
- 1
yum install ImageMagick ImageMagick-devel
1.10. 配置并开启防火墙
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
systemctl start firewalld
firewall-cmd --permanent --zone=public --add-port=[u]/tcp
firewall-cmd --permanent --zone=public --add-port=[v]/tcp
firewall-cmd --permanent --zone=public --add-port=[w]/tcp
firewall-cmd --permanent --zone=public --add-port=[x]/tcp
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
firewall-cmd --zone=public --list-ports
firewall-cmd --permanent --zone=public --list-ports
2. 项目配置
2.1. Wutong CMS API服务
- 1
- 2
- 3
- 4
- 5
git clone https://github.com/ifuyun/wutong-api.git
cd wutong-api/
npm i
npm run build
pm2 start process.json
2.2. ifuyun.com应用
- 1
- 2
- 3
- 4
- 5
- 6
cd ../
git clone https://github.com/ifuyun/ifuyun.com
cd ifuyun.com/
npm i
npm run build:ssr:prod
pm2 start process.json
2.3. Wutong CMS管理后台
- 1
- 2
- 3
- 4
- 5
cd ../
git clone https://github.com/ifuyun/wutong-admin.git
cd wutong-admin/
npm i
npm run build:prod
2.4. 最后,查看服务状态
- 1
pm2 list