1. Problem description
Lao Zhang’s company was established. I saw that my friend Lao Li’s company had just set up a website, mainly for the introduction of the company, such as what business, contact information, etc., and wanted to get one, so I asked the company employee Xiao Zhang, Zhang said that it’s easy. The content of the website can be taken from Mr. Li and changed to ours. However, the website needs to be deployed on the Internet and a server can be purchased, otherwise others will not be able to access it. The budget is about 4,000 yuan, Lao Zhang Hesitated after hearing this, the company has just been established, and the fart hasn't yet, so just pay!
2. Solution
Who has few friends yet, Lao Wang will take you to deploy Lao Zhang’s website to Lao Li’s server without spending a penny, and there is no need to add a suffix after the domain name, Lao Li will not be affected in any way, Lao Wang Take you to the actual operation.
2.1 First, you need to associate the domain name with the server (ip)
(1) Enter the domain name management under the Alibaba Cloud console
(2) Select the corresponding domain name to be operated, and click the management button at the end
(3) Select the domain name resolution menu, Lao Wang is already configured here
(4) The main item here is to fill in the record value. Here is to configure your server ip so that the server is associated with your domain name.
2.2 Server configuration
First install nginx on the Alibaba Cloud server, and then configure nginx. The main principle is: in the nginx configuration file, create two new servers, and the listening ports are both: 80. Configure different domain names to reach one server. Corresponding to the effect of multiple domain names (official website).
In Lao Wang's current project, online (100% available) is being used, and multiple domain names correspond to one server (online ip and domain names are replaced), the source code is as follows, the visitip item in it is to jump to For specific service links on the server, when the browser clicks on a different domain name, it will enter a different service interface and display different official website content, achieving the effect of deploying multiple websites on one server.
upstream visitip{
server 192.168.0.11:3107;
}
Source code:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name test1.hbusy.com;
location / {
root html;
index index_test1.html index_test1.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
upstream visitip{
server 192.168.0.11:3107;
}
server {
listen 80;
server_name test2.hbusy.com www.test2.hbusy.com;
location / {
proxy_pass http://visitip;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 2000m;
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
}
}
}
For more knowledge, please pay attention to the official account: "Software King" , share IT technology and related dry goods, reply to keywords to get corresponding dry goods, java , send 10 must-see "Martial Arts Cheats"; pictures , send more than 1 million copies for commercial use High-definition pictures; interview , send java interview questions with a monthly salary of "20k" just after graduation. Follow-up updates, such as " soft test ", " tools ", etc., are already being sorted.