今天尝试将其他站点添加到vps。 CentOS服务器已经具有django / nginx / gunicorn配置设置。
创建一个新的用户帐户,并与该用户进行整个设置。新项目(烧瓶应用程序)已经创建,但是想要在上传之前配置服务器。
我一直遵循DO tutorial。在创建套接字之前,一切似乎都进行得很顺利。全天(5个多小时)试图寻找解决方案,但我仍然站着不动。此外,还有一个错误指出mydomaininfo不是flask软件包的模块。
/etc/systemd/system/mydomaininfo.service
[Unit]描述=服务器mydomaininfo的独角兽实例 After = network.target
[服务]用户=用户组= nginx WorkingDirectory = / home / mdi / mydomaininfo 环境=“ PATH = / home / mdi / mydomaininfo / mdi_env / bin” ExecStart = / home / mdi / mydomaininfo / mdi_env / bin / gunicorn --workers 3 --bind unix:/home/mdi/mydomaininfo/mydomaininfo.socket mydomaininfo.wsgi $ MAINPID PrivateTmp = true
[安装] WantedBy = multi-user.target
/etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 8080;
server_name mydomaininfo.com;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/home/mdi/mydomaininfo/mydomaininfo.sock;
#include proxy_params; proxy_pass http://unix:/home/nginx/mydomaininfo.sock;
}
}
server {
listen 80;
server_name 2nddomain;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/msf/2nddomain/2nddomain;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/home/msf/2nddomain.me/2nddomain/2ndomain.sock;
}
}
mydomaininfo.py:
from flask import Flask
application = Flask(__name__)
@application.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == "__main__":
application.run(host='0.0.0.0')
wsgi.py:
from mydomaininfo import application
if __name__ == "__main__":
application.run()
运行journalctl -u mydomaininfo.service 启动Gunicorn实例到服务器mydomaininfo。 systemd 1:启动Gunicorn实例到服务器mydomaininfo ... systemd 1:mydomaininfo.service:主进程已退出,代码已退出,状态= 217 / USER systemd 1:mydomaininfo.service:控制进程已退出,代码=退出状态= 217 systemd 1:单位mydomaininfo.service进入失败状态。 systemd 1:mydomaininfo.service失败。
我很确定这是一个配置问题,但不知道如何进行。另外,进行配置会降低已经配置的2nddomain,现在也找不到其应用程序的套接字。
我正在考虑废弃所有内容并鞭打一台新服务器,但是,任何见解将不胜感激。