It is very convenient to configure virtual host vhost under nginx. Just add a server in the nginx configuration file nginx.conf For example, I want to configure two virtual hosts, accessed through the domain names linux.com and linux2.com, and the corresponding directories are /usr/htdocs/linux and /usr/htdocs/linux2 respectively (this directory is where you put your development project files) Because I installed a local virtual machine, I first added two redirects to the hosts file: 192.168.20.250 linux.com //192.168.20.250 is the IP address of my virtual machine, using bridge mode 192.168.20.250 linux2.com Start configuring: Taking the configuration of linux.com as an example, configuring multiple virtual hosts is exactly the same process. 1. Find the nginx configuration file nginx.conf Generally in the conf file under the nginx installation path > Enter the conf directory and see many configuration files Edit nginx.conf Add a server{}, each server configuration corresponds to a virtual host vhost server { listen 80; //Port 80 server_name linux.com; //Set the domain name #Directly enter the domain name to enter the directory and the default parsed file location / { index index.html; root /usr/htdocs/linux; //Enter linux.com directly to enter here, generally configure and parse the directory where php is located} #Parse .php file location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/htdocs/linux/$fastcgi_script_name; //The directory corresponding to the current virtual host include fastcgi_params; } } Add in nginx.conf Add the file index.php in the corresponding /usr/htdocs/linux for testing Restart nginx: service nginx restart After modifying the nginx configuration file, you need to restart nginx to take effect Open the browser and enter the domain name to test: OK, normal analysis! The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to query data within a certain period of time with Vue front-end and Django back-end
>>: A brief discussion on the calculation method of key_len in mysql explain
Table of contents Overview Environment Preparatio...
Table of contents Global Registration Partial Reg...
To install Jenkins on CentOS 8, you need to use t...
Nginx load balancing server: IP: 192.168.0.4 (Ngi...
How to install PHP7 on Linux? 1. Install dependen...
WeChat applet: Simple calculator, for your refere...
The action of the form is different from the URL j...
1. The role of index In general application syste...
Mysql8.0.12 decompression version installation me...
mysql permissions and indexes The highest user of...
Table of contents 1. Installation 2.APi 3. react-...
The META tag is an auxiliary tag in the head area...
This article mainly summarizes various problems o...
Why mention textarea specifically? Because the tex...
The compatibility of browsers is getting better a...