一、centos下安装nginx

1.安装编译工具及库文件

1
yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

2.安装 PCRE(让 Nginx 支持 Rewrite 功能)

1
2
3
4
5
6
7
8
9
#下载最新版本的,注意不要用pcre2
wget https://jaist.dl.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz
tar -xvf pcre-8.42.tar.gz
cd pcre-8.42
#安装编译
./configure
make && make install
#查看pcre版本
pcre-config --version

3.安装nginx

1
2
3
4
5
6
7
8
9
#下载
wget https://nginx.org/download/nginx-1.15.9.tar.gz
tar -xvf nginx-1.15.9.tar.gz
cd nginx-1.15.9
#编译安装
./configure --prefix=/opt/nginx
make && make install
#查看版本
/opt/nginx/sbin/nginx -v

4.nginx配置

1
2
3
4
5
6
7
8
9
10
11
12
server {
listen 80;
server_name localhost;

location / {
root html/hexo;
index index.html;
}
location ~.*\.(gif|jpg|jpeg|png|bmp|swf|htm|ico|js|css)$ {
root html/public;
}
}

二、hexo部署

1.在nginx目录的html下新建文件夹hexo

2.在本地开发好了。运行 hexo g

3.将编译后的文件上传到html下新建文件夹hexo



本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!