1、下载链接
wget https://tool-box.oss-cn-hangzhou.aliyuncs.com/nginx-1.10.0.tar.gz
2、安装
yum install gcc gcc-c++ net-snmp net-snmp-devel curl-devel perl-DBI libxml2 libxml2-devel openssl-devel libpng-devel freetype-devel libmcrypt libmcrypt-devel cmake bzip2-libs bzip2-devel libjpeg libjpeg-devel libxslt-devel libtool-ltdl-devel ncurses-devel gd-devel bison.x86_64 -y
./configure --user=www --group=www --prefix=/user/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_sub_module --with-http_image_filter_module
make && make install
3、配置
cat /usr/local/nginx/conf/vhost/log.conf
server {
listen 80;
listen 443;
server_name 192.168.28.103;
include mime.types;
default_type application/octet-stream;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
root /var/logs;
location / {
auth_basic "secret";
auth_basic_user_file /usr/local/nginx/passwd.db;
}
}
4、用htpasswd 创建账号密码
yum -y install httpd
htpasswd -bc /usr/local/nginx/passwd.db admin 123456
5、启动服务
/usr/local/nginx/sbin/nginx
6、加入开机启动
echo '/usr/local/nginx/sbin/nginx' >> /etc/rc.local