注意:
在将 Nginx 网页文件放入内存进行缓存之前要先安装 Nginx
正文:
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
http {
Open_file_cache max=2000 inactive=20s;
Open_file_cache_valid 60s;
Open_file_cache_min_uses 5;
Open_file_cache_errors off;
}
在将 Nginx 网页文件放入内存进行缓存之前要先安装 Nginx
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
http {
Open_file_cache max=2000 inactive=20s;
Open_file_cache_valid 60s;
Open_file_cache_min_uses 5;
Open_file_cache_errors off;
}
414
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
.....
http{
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
......
}
在设置 Nginx 认证以后才能登录网页之前要先安装 Nginx
# yum -y install httpd-tools
# htpasswd -c /usr/local/nginx/pass zhumingyu1
(补充:这里以删除原来的所有用户新增 zhuming1 用户为例)
# htpasswd /usr/local/nginx/pass zhumingyu2
(补充:这里以新增 zhumingyu2 用户为例)
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
......
server {
listen 80;
server_name localhost;
auth_basic "input password";
auth_basic_user_file “/usr/local/nginx/pass”;
location /{
root html;
root html;
index index.html index.htm;
}
......
}
......
# /usr/local/nginx/sbin/nginx
(步骤略)
(补充:可以输入刚刚添加的 zhumingyu1 和 zhumingyu2 的用户名和密码)
在添加 Nginx 域名、IP 地址或端口的虚拟机主机之前要先安装 Nginx
# vim /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
......
Server {
Listen 80;
Server_name www.eternlcenter.com;
Location / {
Root www;
Index index.html index.html;
}
}
......
(补充:这里以将本地的 80 端口设置为 www.eternalcenter.com 的虚拟机为例)
在设置 Nginx 重定向之前要先安装 Nginx
# cd /usr/local/nginx/conf
# openssl genrsa > cert.key
# openssl req -new -x509 -key cert.key > cert.pem
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
......
server {
listen 443
server_name www.c.com;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
location /{
root html;
index index.html index.htm;
}
......
}
......