Nginx微服务搭建-下载器
1、pcre软件安装
准备目录:mkdir -p /data/{server, softs}/nginx
切换目录:cd /data/softs
下载:wget https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz/download
解压:tar -zxf pcre-8.39.tar.gz
配置:sudo ./configure
编译:sudo make
安装:sudo make install
2、配置主题风格-fancyindex
切换目录:cd /data/softs
下载配置:git clone https://github.com/aperezdc/ngx-fancyindex.git ngx-fancyindex
下载主题:git clone https://github.com/lanffy/Nginx-Fancyindex-Theme.git
3、nginx软件安装
切换目录:cd /data/softs
复制配置:cp ngx-fancyindex /data/server/nginx/
下载:wget http://nginx.org/download/nginx-1.10.2.tar.gz
解压:tar -zxf nginx-1.10.2.tar.gz
配置:sudo ./configure --prefix=/data/server/nginx --without-http_gzip_module --with-http_stub_status_module --add-module=/data/server/nginx/ngx-fancyindex
编译:sudo make
安装:sudo make install
4、配置nginx.conf文件
复制主题:cp /data/softs/Nginx-Fancyindex-Theme /data/server/nginx/html/
切换目录:cd /data/server/nginx/conf
编辑配置:sudo vim nginx.conf
worker_processes auto;
error_log logs/error.log;
http {
# 引用主题配置
include /data/server/nginx/html/Nginx-Fancyindex-Theme/fancyindex.conf;
server {
listen 80;
server_name localhost;
charset utf-8;
# 让主题配置生效
location /Nginx-Fancyindex-Theme {
root html;
}
# 配置目录显示
location / {
alias /data/test_dir/; # 指定要显示的目录
autoindex on; # 开启目录自动索引
autoindex_exact_size off; # 默认on,显示文件大小
autoindex_localtime on; # 默认off,显示文件的服务器时间
}
# 配置监听状态
location /status {
stub_status on; # 开启监控状态
access_log off; # 不记录日志
}
}
}
5、nginx服务操作
检查:/data/server/nginx/sbin/nginx -t
开启:/data/server/nginx/sbin/nginx
关闭:/data/server/nginx/sbin/nginx -s stop
重启:/data/server/nginx/sbin/nginx -s reload