Version: centos6.5; mysql-5.6.26, nginx-1.6.3;p hp-5.4.37
Environment Architecture: LNMP
1. Configure a second virtual host
You can add a line to the nginx.conf
Include vhosts/*.conf;
This allows us to create a virtual host configuration file under the/usr/local/nginx/conf/vhosts directory.
#mkdir/usr/local/nginx/conf/vhosts
#cd!$
#vim 111.conf//Join
Server
Server
{
Listen 80;
server_name 192.168.137.100;
Index index.html index.htm index.php;
root/data/www;
Location ~. *admin\.php$ {
Auth_basic "Xiayun auth";
AUTH_BASIC_USER_FILE/USR/LOCAL/NGINX/CONF/HTPASSWD;
Include Fastcgi_params;
Fastcgi_pass Unix:/tmp/www.sock;
Fastcgi_index index.php;
Fastcgi_param Script_filename/data/www$fastcgi_script_name;
}
Location ~ \.php$ {
Include Fastcgi_params;
Fastcgi_pass Unix:/tmp/www.sock;
Fastcgi_index index.php;
Fastcgi_param Script_filename/data/www$fastcgi_script_name;
}
}
2. User authentication
You need to install Apache first, you can install it using yum install httpd
Generate a password file, create a user
Htpasswd-c/USR/LOCAL/NGINX/CONF/HTPASSWD Test
Add the test user, the first time you add the-c parameter, the second time add does not need the-c parameter
Summary: User authentication can enable users to log in to a path when user authentication, improve the density
This article from the "10707334" blog, reproduced please contact the author!
Nginx Advanced Configuration (1)--Add user authentication for a virtual host