[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"article-10":3},{"id":4,"title":5,"title_en":6,"abstract":7,"abstract_en":8,"content":9,"content_en":10,"category":11,"banner_id":12,"banner_path":13,"tags":14,"is_recommend":18,"prev_article":19,"next_article":23,"created_at":27},10,"Django部署","Django deployment","\n\n### **1.nginx**\n\n------------\n\n##### **1.1 腾讯云放通80端口**\n\n在腾讯云的控制台中，对实例主机配置安全组，在入方向新增80端口的安全规则。配置如有疑","### **1.nginx**\n\n------------\n\n##### **1.1 Tencent Cloud Releases 80 Ports**\n\nIn the Tencent Cloud console, configure a security group for the instance host and add a security rule for port 80 in the inbound direction. If there is any doubt about the configuration","\n\n### **1.nginx**\n\n------------\n\n##### **1.1 腾讯云放通80端口**\n\n在腾讯云的控制台中，对实例主机配置安全组，在入方向新增80端口的安全规则。配置如有疑问请参考[官方说明](https:\u002F\u002Fcloud.tencent.com\u002Fdocument\u002Fproduct\u002F213\u002F34601 \"官方说明\")。(购买服务器之后默认是放通的)\n\n**1.2 安装nginx**\n\n我对nginx的版本没有过多要求，此处采用dnf包管理方式安装，此处笔者dnf安装的是1.4.1版本。\n```shell\ndnf install -y nginx\n```\n如果有要求：\n```shell\nsudo yum install nginx\n```\n安装完成后，可以查看一下版本，以验证是否正确安装\n```shell\nnginx -v\n```\n**1.3nginx管理**\n\n基于dnf安装的nginx已经做好了相关设置，可以使用nginx -s、systemctl对nginx进行便捷管理。\nsystemctl管理常用:\n```shell\nsystemctl enable nginx #开机自启动nginx\nsystemctl disable nginx #开机禁止启动nginx\nsystemctl status nginx #查看nginx服务状态\nsystemctl start nginx #开启nginx服务\nsystemctl stop nginx #终止nginx服务\nsystemctl restart nginx #重启nginx服务 \n\n```\n这里也可以使用nginx原生命令：\n```shell\nnginx -V\t\t\t #查看nginx版本和配置项内容\nnginx -t \t\t\t #检查配置文件是否正确\nnginx -c  配置文件路径 #选用某一配置文件\nnginx \t\t\t\t #启动nginx\nnginx -s reload \t #重新载入配置文件\nnginx -s stop\t\t #停止nginx\n\n```\n**1.4nginx使用**\n```shell\nsystemctl start nginx #或者直接使用nginx 启动nginx服务\nsystemctl status nginx #若看到Active变为active(running)则启动正常\nlsof -i:80\t\t\t#可以看到80端口已经被nginx监听了\n\n```\n上面一系列检查确认nginx正常启动后，可以到浏览器输入公网地址或域名，看到nginx欢迎页。\nnginx配置文件在\u002Fetc\u002Fnginx\u002Fnginx.conf\n\n## **2.Mysql**\n\n\n\n\n\nCentos8的dnf对懒人那是相当友好。mysql8.0的完全可以一条命令解决:\n```shell\ndnf install -y @mysql  #@mysql模块将安装MySQL8.0及其所有依赖项\n\n```\n**2.2启动mysql**\n```shell\nsystemctl enable mysqld   #配置mysql开机自启动\nsystemctl start mysqld       #启动mysqld\nsystemctl status mysqld   #查看mysql是否启动成功(active running)\n\n```\n**2.3安全设置**\n\n运行如下脚本，可以设置mysql的root密码，并引导你完成一些必要的安全设置。\n```shell\nmysql_secure_installation\n```\n首先，脚本会让你选择是否配置VALIDATE PASSWORD PLUGIN(密码验证插件)，该插件用来检查mysql用户所设置的密码强度，只有达到一定强度的密码才允许被设置。如果你希望设置请输入y或者Y回车，不想请直接回车。若选择了配置，紧接着你将选择所采用密码验证策略的级别：\n\n&gt; 低:密码长度不少于8位\n中:密码长度不少于8位，必须是数字、大小写字母、特殊字母混合。\n强:密码长度不少于8位，必须是数字、大小写字母、特殊字母混合，需配合字典文件。\n\n通常，我们选择中级别即可。\n\n其次，将要求用户输入两次为root设置的新密码，上一步骤设置的密码验证策略将发挥作用，并对用户设置的密码强度进行打分。设置好密码以后，会提示用户是否继续采用密码保护，选择y回车。\n\n紧接着，将询问用户是否删除匿名用户，选择y回车。\n\n&gt; 默认情况下，MySQL有一个匿名用户，允许任何人登录MySQL，而不必创建用户帐户。这仅用于测试，或者安装时更便利。但在部署生产环境之前，应该先删除匿名用户。\n\n然后，将询问用户是否禁止以root身份远程登陆mysql，选择y回车。\n\n&gt; 通常，mysql中的root用户应只允许通过本地登陆，而不能远程登陆。这样可以降低root用户密码被爆破的风险。\n\n此后，将询问用户是否删除测试数据库，选择y回车。\n\n&gt; 默认情况下，MySQL总有一个名为’test’的数据库，允许任何用户访问。这仅用于安装时的测试，但在部署生产环境之前，应该先删除该数据库。\n\n最后，脚本询问用户是否现在重载 privilege tables，以使当前所有修改立刻生效。选择y回车。\n\n当我们在终端中键入:\n```shell\nmysql -u root -p \t\t\t#回车输入密码并确认\n\n```\n即可登陆mysql。\n\n\n## **3.上传你的Django项目**\n\n**这里把你的项目传到gitee（推荐，速度快） 或 github**\n\n###### 不要忘了现在创建文件夹，在文件夹目录里面拉去你的项目，切记！\n\n\n```shell\ngit clone  \n```\n&gt; 这里的 repository_url 是要克隆的Git仓库的URL地址，destination_folder 是指定的目标文件夹路径。\n\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002Fexample\u002Frepo.git myfolder\n```\n这样，Git仓库repo.git会被克隆到当前目录下的myfolder文件夹中。","\n\n### **1.nginx**\n\n------------\n\n##### **1.1 Tencent Cloud releases port 80 **\n\nIn the console of Tencent Cloud, configure security groups for instance hosts, and add a security rule for port 80 in the inbound direction. If you have any questions about configuration, please refer to [Official Instructions](cloud.tencent.com\u002Fdocument\u002Fproduct\u002F213\u002F34601 \"Official Instructions\"). (It will be opened by default after purchasing the server)\n\n**1.2 Install nginx*\n\nI don't have too many requirements for the version of nginx. I use dnf package management to install it here. Here, I installed version 1.4.1 with dnf.\n```shell\ndnf install -y nginx\n```\nIf required:\n```shell\nsudo yum install nginx\n```\nAfter the installation is complete, you can check the version to verify that it was installed correctly\n```shell\nnginx -v\n```\n** 1.3 nginx management **\n\nnginx installed based on dnf has been set up, and nginx -s and systemctl can be used to manage nginx conveniently.\nCommonly used for systemctl management:\n```shell\nsystemctl enable nginx #Boot nginx automatically\nsystemctl disable nginx #Boot disable nginx\nsystemctl status nginx #Check nginx service status\nsystemctl start nginx #Start nginx services\nsystemctl stop nginx #Terminate nginx services\nsystemctl restart nginx #Restart nginx services \n\n```\nYou can also use nginx native commands here:\n```shell\nnginx -V\t\t\t #View nginx version and configuration item content\nnginx -t \t\t\t #Check whether the configuration file is correct\nnginx -c configuration file path #Select a configuration file\nnginx \t\t\t\t #Start nginx\nnginx -s reload \t #Reload configuration file\nnginx -s stop\t\t #Stop nginx\n\n```\n**1.4nginx usage **\n```shell\nsystemctl start nginx #or directly use nginx to start nginx services\nsystemctl status nginx #If you see Active becoming active, the boot is normal\nlsof -i:80\t\t\t#You can see that port 80 has been monitored by nginx\n\n```\nAfter the above series of checks confirm that nginx starts normally, you can enter the public network address or domain name in the browser and see the nginx welcome page.\nThe nginx configuration file is found in\u002Fetc\u002Fnginx\u002Fnginx.conf\n\n## **2.Mysql**\n\n\n\n\n\nCentos8's dnf is quite friendly to lazy people. mysql 8.0 can be solved with one command:\n```shell\ndnf install -y @mysql #@mysql module will install MySQL 8.0 and all its dependencies\n\n```\n**2.2 Starting mysql**\n```shell\nsystemctl enable mysqld   #Configure mysql booting and self-booting\nsystemctl start mysqld       #Start mysqld\nsystemctl status mysqld   #Check whether mysql started successfully (active running)\n\n```\n**2.3 Security Settings **\n\nRun the following script to set the root password of mysql and guide you through some necessary security settings.\n```shell\nmysql_secure_installation\n```\nFirst, the script will let you choose whether to configure VALIDATE PASSWORD PLUGIN(password verification plug-in), which is used to check the password strength set by mysql users. Only passwords with a certain strength are allowed to be set. If you want to set it, please enter y or Y to enter, otherwise enter directly. If you choose Configuration, you will then choose the level of password authentication policy you use:\n\n&gt;Low: Password length is at least 8 digits\nMedium: The password length must be no less than 8 digits and must be a mixture of numbers, upper and lower case letters, and special letters.\nStrong: The password length is no less than 8 digits, must be a mixture of numbers, upper and lower case letters, and special letters, and needs to be matched with a dictionary file.\n\nNormally, we just choose the medium level.\n\nSecondly, the user will be required to enter a new password set for root twice. The password verification policy set in the previous step will take effect, and the strength of the password set by the user will be scored. After setting the password, the user will be prompted whether to continue password protection and select y Enter.\n\nNext, the user will be asked whether to delete the anonymous user and select y Enter.\n\n&gt;By default, MySQL has an anonymous user that allows anyone to log in to MySQL without having to create a user account. This is for testing only, or it is easier to install. But before deploying a production environment, you should remove anonymous users.\n\nThen, the user will be asked whether to disable remote login to mysql as root, and select y Enter.\n\n&gt;Generally, root users in mysql should only be allowed to log in locally, not remotely. This reduces the risk of root user passwords being blasted.\n\nAfter that, the user will be asked whether to delete the test database and select y Enter.\n\n&gt;By default, MySQL always has a database called 'test' that is accessible to any user. This is for testing at installation time only, but the database should be deleted before deploying a production environment.\n\nFinally, the script asks the user whether to overload privilege tables now so that all current changes take effect immediately. Select y Enter.\n\nWhen we type in the terminal:\n```shell\nmysql -u root -p \t\t\t#Enter Enter password and confirm\n\n```\nYou can log in to mysql.\n\n\n## **3. Upload your Django project **\n\n** Send your project to gitee or github here **\n\n######Don't forget to create a folder now and pull your projects in the folder directory, remember!\n\n\n```shell\ngit clone  \n```\n&gt;Here, repository_url is the URL address of the Git repository to be cloned, and destination_folder is the specified destination folder path.\n\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002Fexample\u002Frepo.git myfolder\n```\nIn this way, the Git repository repo.git will be cloned into the myfolder folder in the current directory.","部署",0,"https:\u002F\u002Fblog4-1316398321.cos.ap-nanjing.myqcloud.com\u002Fblog5\u002F20250712005919__【哲风壁纸】我们俩-起风了.png",[15,16,17],"Linux","Nginx","Django",false,{"id":20,"title":21,"title_en":22},9,"枫枫知道--Vue全系列课程","Maple Fengfeng knows - Vue full range of courses",{"id":24,"title":25,"title_en":26},11,"python基础--什么是数据类型","python basics - what are data types","2025-07-23T07:08:50+08:00"]