centos 7搭建私有node

本文主要用于记录在CentOS 7上手动部署npm仓库.

安装依赖

1
yum -y install gcc gcc-c++ openssl-devel

下载解压nodejs

1
2
3
curl https://cdn.npm.taobao.org/dist/node/v14.15.0/node-v14.15.0-linux-x64.tar.xz -o node-v14.15.0-linux-x64.tar.xz
tar -xvJf node-v14.15.0-linux-x64.tar.xz
mv node-v14.15.0-linux-x64/ node

配置nodejs环境变量

1
vi /etc/profile

配置如下内容:

1
2
3
export NODE_HOME=/opt/node
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules

保存后:

1
2
source /etc/profile
node -v

设置淘宝镜像

1
npm config set registry http://registry.npmjs.org

安装verdaccio

1
npm install --global verdaccio --unsafe-perm

修改verdaccio配置

打开配置文件:

1
vi /root/.config/verdaccio/config.yaml

添加如下内容(可选)

1
2
listen: 0.0.0:4873
url_prefix: /registry/

安装pm2

1
npm install -g pm2 --unsafe-perm

启动verdaccio

1
2
3
pm2 start verdaccio
# 查看实时日志
pm2 show verdaccio

访问verdaccio: http://localhost:4873/registry/

发包

1
2
3
4
5
# 1. 登录
npm adduser --registry http://40.73.5.1:4873
# 2. 发布
# npm publish --registry http://40.73.5.1:4873
3. 刷新当前页面.

centos 7手动编译部署Apache

本文主要用于记录在CentOS 7上手动编译并部署apache.

下载apache

  1. 下载apache
1
curl -O http://mirror.cc.columbia.edu/pub/software/apache//httpd/httpd-2.4.43.tar.gz
  1. 下载依赖
1
2
3
4
# apr
curl -O http://mirror.cc.columbia.edu/pub/software/apache//apr/apr-1.7.0.tar.gz
# apr util
curl -O http://mirror.cc.columbia.edu/pub/software/apache//apr/apr-util-1.6.1.tar.gz
  1. 解压安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#解压安装
tar -zxvf ./httpd-2.4.43.tar.gz
tar -zxvf ./apr-1.7.0.tar.gz
tar -zxvf ./apr-util-1.6.1.tar.gz
#编译安装apr
cd ./apr-1.7.0/
./configure --prefix=/usr/local/apr
make
make install
#编译安装apr-util
cd ./apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make
make install

在编译解决办法如下:apr-util时,会报错:

1
2
3
4
5
6
7
8
9
xml
/apr_xml.c:35:19:
fatal error: expat.h: No such file or directory
#include <expat.h>
^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/data/jumper-cs/downloads/apr-util-1.6.1'
make: *** [all-recursive] Error 1

解决办法如下:

1
yum install -y expat-devel

然后重新编译安装apr-util。最后编译apache:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 如果没有安装pcre,先按照pcre
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.43.tar.gz
tar -zxvf pcre-8.43.tar.gz
cd pcre-8.43
./configure --prefix=/usr/local/pcre
make
make install
# 开始安装apache...
cd httpd-2.4.43/
./configure --prefix=/apache24 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make
make install

# 最后启动apache,注意:启动之前请修改端口
/apache24/bin/apachectl start
  1. 配置vhost
    因为我用到了反向代理的功能,因此需要启用它。
1
2
3
4
5
6
7
8
# 启用vhost
vi /apache24/conf/httpd.conf
# 找到并解注
Include conf/extra/httpd-vhosts.conf
#
LoadModule proxy_module modules/mod_proxy.so
#
LoadModule proxy_http_module modules/mod_proxy_http.so

最后,我们可以通过curl -i http://127.0.0.1/来测试一下页面