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