[Nginx] Simple nginx Virtual Host Configuration

Source: Internet
Author: User

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:

[Email protected] Black Eye 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] Simple nginx Virtual Host Configuration

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.