Notes for the first time deploy a Web site to a server

Source: Internet
Author: User

A few days ago and two friends rented a foreign server, I have a domain name, intends to winter vacation flask Learn to do a website to play a play, but did not work, the afternoon to learn the next flask got a helloworld, so can't wait to try to deploy it to the server up first.

The schema used is uwgsi+nginx+flask.

Nginx is something, we buy the server has an IP address, we 3 people have a personal domain name needs to resolve to this address, the Internet is the default request is through 80 ports, and then our respective Web application on the server need to have its own port, Then Nginx will transfer the request to the corresponding server port, such as my port on the server is 8888.

And Uwsgi is docking with the Python module, Nginx will send the request to the corresponding server port above, UWSGI will call the corresponding server application according to different ports to respond to this request.

The purchase of the server SY to each of us created a user, and the corresponding password, the first attempt to use SSH remote connection to our server, but each time to ssh [email protected] more trouble, because before just bought soon by malicious scanning port crack permissions, SY changed the default port, each time to add-p, and then also to enter the password, more trouble, so in the online study of SSH password-free login method, the specific command is $ ssh-keygen-t RSA, and then found in My Computer user name. SSH directory (I use win), find ID _rsa.pub, then run the command SCP. ssh/id_rsa.pub [Email protected]:/home/user/id_rsa.pub copy it to the server and then run cat id_rsa.pub >> ~/. Ssh/authorized_keys, there is a problem here, I do not have. ssh folder, did not create at the beginning of the error, and then create it can not be created with sudo, or else not, after the last sentence chmod. ssh/authorized_ The keys will be all right. This will enable the password-free landing.

And then because each time to enter the IP address is troublesome, so to change the host file, under win find C:\Windows\System32\drivers\etc inside the hosts, copy it to other places to modify the host, and then paste back to the original place. Because now the computer user name and the same server, so there is no need to add [email protected] in front of [email protected]

OK, the front are some for the convenience of work, after entering the server, find/etc/uwsgi/inside is to store uwsgi some of the configuration files, just another two people have been configured to their, direct CP over to change there is a own (haha), the configuration file there are mainly some parameters, chdir = Path path is the address where my web app is placed, then another module = XXX, which is the one that launches the application,

There is also a socket =: 8888 is the port number that I set up, others are consistent with them, so it is configured Uwsgi, and then sudo systemmctl restart [email protected] can achieve local access to my site, To achieve extranet access, you also need to use Nginx

Nginx configuration is relatively simple, first enter the/usr/local/etc/nginx/vhosts/, there are also friends have been well-equipped files, continue to change CP a copy, inside is very simple, only the following,

1 server {2     listen; 3     server_name www.xxxx.com; 4     Location/ {5        include uwsgi_params; 6         Uwsgi_pass 127.0.0.1:8888; 7 }

This also configures the Nginx.

OK, finally to buy the domain name of the place to resolve the domain name to our server IP address, but only into our server did not return to my Web application, because before the malicious attack Sy all the ports are banned, with a iptable to manage, configuration files in/etc/ Iptables/iptables.rules, add a-a input-p tcp-m TCP--dport 8888-j accept it.

So far the site can be directly accessed through the domain name, may be configured relatively simple, there are many configuration methods on the Internet, this should be considered the most easy, may need to compare multi-functional at a later time to change something, but just contact is too complex and bad, This is enough for one or two hours to get a helloworld out, or very fun.

Ps: This article is not a tutorial. Just simply record the process you just configured (I'm afraid I'll forget about sleeping tonight.) )

Notes for the first time deploy a Web site to a server

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.