[Nginx] Simple Nginx virtual host configuration and nginx Virtual Host Configuration
Bytes -------------------------------------------------------------------------------------------------------
Configure the VM:
1. Bind a domain name
Vim/etc/hosts # Add a format such as 192.168.1.11 www. chenwei. ws
2. Add a VM
Cd to the root directory, run vhost. sh to add the VM, and enter the domain name.
3. Edit the configuration file
Vim/usr/local/nginx/conf/vhost/www. chenwei. ws. conf # The configuration is as follows:
------------------------------ @ Blackeye poet <www. chenwei. ws> ----------------------------------
Server {listen 80; # listen [:]: 80; server_name www. chenwei. ws; # server name index index.html index.htm index. php default.html default. ht m default. php; root/home/wwwroot/default/www. chenwei. ws; # include other. conf; # error_page 404/404 .html;} # Add location ~ when calling the font across domains ~ * \. (Eot | ttf | woff) $ {add_header Access-Control-Allow-Origin *;}
4. Configure open_basedir in PHP (restrict the activity scope of user files to the specified region, and open_basedir is the access directory ):
Vim/usr/local/php/etc/php. ini
Run the command G to move the cursor to the end of the line and configure the root directory of the host accessed by php. If yes, do not change it:
[HOST = www. chenwei. ws]
[PATH =/home/wwwroot/default/www. chenwei. ws]
Open_basedir =/home/wwwroot/default/www. chenwei. ws/:/tmp/
Nginx VM Problems
You are the default virtual host.
For example, if your server IP address is 10.10.10.10, add
Server {
Server_name 10.10.10.10;
Listen 80;
Location /{
Rewrite (. *) http: // The domain name you want to jump;
}
}
Restart your nginx.
Nginx VM Problems
Paste the configuration as much as possible.
According to your description, this configuration may be appropriate.
Server
{
Listen 80;
Server_name a.com;
...
}
Server {
Listen 80;
Server_name XXX. OOO. XXX. OOO;
...
}
Server
{
Listen 80;
Server_name B .com;
}