[Nginx] Simple Nginx virtual host configuration and nginx Virtual Host Configuration

Source: Internet
Author: User

[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;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.