私たちの目標:
- CentOSのシステム
- nginxのサーバー
- asp.netのコアアプリケーション
- MySQLサーバ
- テンセントのクラウドサーバー
準備するためのツール
[Xshell] - 使用windwosの[ツールXshellを、原則は----------私たちは、Windowsのリモートホスト用のリモートデスクトップ接続が、今テンセントの雲に似た他のコンピュータに接続することができますSHH契約を使用することです - [ファイル名を指定して実行]
[] WinSCPを - 私たちは、出版文書をasp.netコアサイトを書くとき、あなたはCentOSのコピーに行く必要があり、その後、WinSCPのを使用して、再度、CentOSの上の別のシステムに接続し、IPを設定したとき、あなたは2を達成することができます共有コンピュータのファイルは、ファイルをコピー---------- [コピー]
[ネットコアSDK] - 。ウェブまたはCentOSの上で実行するWebアプリケーションのネットコア開発、あなたがLinuxのインストールの下のダウンロードの様々なバージョンが存在する、環境、Quguanが見.NETコアネットワークを必要とします-------- --- [] ------のCentOSは、.NETのコアをインストール
[nginxの] - それは、httpサーバが転送できるリバースプロキシです
[インストール]
-o nginx.rpmカール
http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
のrpm -ivh nginx.rpm
yumをインストールnginxの#安装[構成]
の/ etc / nginxの中での
CDの/ etc / nginxの
Vimのnginx.confコンテンツ:
ユーザーnginxの、
1をworker_processes。error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; 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; client_max_body_size 2000m; #最大限制为2000M --万一你的web需要上传文件或者图片等大文件 keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; }
最後の根拠が含まれていることに注意してください、これは設定ファイルがネストされていることを意味し、ビットC言語のようなものである、より詳細な構成は/etc/nginx/conf.d/*.conf見つけるために、内部に行きます
cd /etc/nginx/conf.d/
vim default.conf
内容为下:
server {
listen 80;
server_name 118.24.112.238;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
proxy_pass http://localhost:5009;
proxy_http_version 1.1;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
server {
listen 81;
server_name 118.24.112.238;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
おそらく、それがポート80でリッスン意味5009 rpmで、81モニタポート、スイッチ5000、フォローアップ保留中の他の追加的な知識
【重载】
nginx配置文件修改后,请一定不要忘记重载,新手很容易忘,
nginx -s reload
[デーモン]
nginxのインストール構成は、80オープン、DOTNETは5000に、サイトオープン、前方ポート80を実行しnetcore.dll、これは確かにリリースしたが、各ブートDOTNETの実行一度実行されることはほとんどありません良い、ファイアウォールのポートですが、あなたがする必要があります設定ガードサービススーパーバイザー、(ガードサービス - デーモン)、当社のウェブの実行を許可されたものをガードサービス======================、独自のエラー処理彼は再起動しました
[インストール]
YUMのpython-setuptoolsのインストール
easy_installをスーパーバイザ#安装スーパーバイザーを[構成]
Supervisor的默认配置文件supervisord.conf 但是没有使用 自建了一个supervisor目录,
CMD []:MKDIRの/ etc /監督者は
、指定したディレクトリに設定ファイルを出力:
[CMD]:echo_supervisord_conf>#スーパーバイザ構成/etc/supervisor/supervisord.conf
前記ファイルsupervisord.confの終了:
[含む]
;ファイル=相対/ディレクトリ/ .INI
;(スペースなし[注]削除)を変更し
、[含める]
ファイル= conf.d / .confの
とCDの/ etc /スーパーバイザー/
conf.dます。mkdir
:新しいファイルを
Vimのzyhopsys.conf
Vimのzyhopsys -admin.conf
:ファイルの内容は、についてでした
[プログラム:opadmin]
プログラム実行するためのコマンド=コマンドDOTNET ZYH.Operation.Sys.Admin.dll#(注)
ディレクトリを= /ホーム/ opadmin /# (注注)は、対応しますプロジェクトの格納ディレクトリ、この場所は、初心者のミスがたくさんあります!!!
自動再=真の#が突然自動的に再起動し終了し
た環境= ASPNETCORE_ENVIRONMENT =プロダクション#プロセスの環境変数を
stderr_logfile =は/ var / log / myproject.err.log ;# エラー・ログ・ファイルの
stdout_logfile =は/ var / log / myproject.out.log ;# 出力ログファイル
のユーザーIDのユーザー=ルート#プロセスが実行
StopSignal = INT
trueに自動起動=を
自動再です真=のに
startsecs。1 =[ファイル名を指定して実行]プロファイルを運びます
supervisord -c /etc/supervisor/supervisord.conf 这里稍微提一句:supervisord的启动顺讯 supervisord #默认去找$CWD/supervisord.conf,也就是当前目录 supervisord #默认$CWD/etc/supervisord.conf,也就当前目录下的etc目录 supervisord #默认去找/etc/supervisord.conf的配置文件 supervisord -c /home/supervisord.conf #到指定路径下去找配置文件 运行后:ps -ef | grep dotnet 可以查看自己的网站是否已运行,正常如下 root 1877 1817 0 16:40 pts/1 00:00:00 grep --color=auto dotnet root 4971 26752 0 13:57 ? 00:00:07 dotnet ZYH.Operation.Sys.Admin.dll root 4972 26752 0 13:57 ? 00:00:05 dotnet ZYH.Operation.Sys.Web.dll
[リロード]
supervisorctl reload #重新加载 每次重新部署 后,可以执行一下上面的命令
セット[ブート]
-建立配置文件 打开目录 /usr/lib/systemd/system/ 新建文件 supervisord.service cd /usr/lib/systemd/system/ vim supervisord.service 内容: # dservice for systemd (CentOS 7.0+) # by ET-CS (https://github.com/ET-CS) [Unit] Description=Supervisor daemon [Service] Type=forking ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf ExecStop=/usr/bin/supervisorctl shutdown ExecReload=/usr/bin/supervisorctl reload KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target 执行命令: systemctl enable supervisord systemctl is-enabled supervisord #来验证是否为开机启动
[ファイアウォール]
あなたがパブリックネットワークIPにアクセスすることができない場合:CentOSのファイアウォールがブロックされているからです、我々はポートを開きます。
ファイアウォール-CMD --zone =公共--add-ポート= 80 / tcpの--permanent#( オープン80ポート)
firewalld#(即時効果を持つ構成用のファイアウォールを再起動)を再起動しsystemctlファイアウォール-CMD --zone =公共--add-ポート= 80 / tcpの--permanent#( オープン80ポート)
firewalld#(即時効果を持つ構成用のファイアウォールを再起動)を再起動しsystemctl- 私は、上記のコマンドmysqlのリモートアクセスによってテンセントクラウドホストを使用して、ではありません
ファイアウォール-CMD --zone =公共--add-ポート= 3306 / tcpの--permanent#(オープンポート3306)
最後に、iptablesの使用
[インストール]
#先检查是否安装了iptables service iptables status #安装iptables yum install -y iptables #升级iptables yum update iptables #安装iptables-services yum install iptables-services
[停止] firewalld
#停止firewalld服务 systemctl stop firewalld #禁用firewalld服务 systemctl mask firewalld
[iptablesの設定]
vim /etc/sysconfig/iptables # sample configuration for iptables service # you can edit this manually or use system-config-firewall # please do not ask us to add additional ports/services to this default configuration *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 81 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
- 要約すると、今まで、私たちは、データベースレベルでの相互作用が関与していないが、Linux上の.NETコアパブリッシング環境の設定経験
CentOS的安装 远程执行终端Xshell 远程拷贝文件WinSCP .net core 环境的安装 服务器nginx的安装,配置,转发规则配置等 守护服务Supervisor的安装,自启动
ネクサスは、以前にリリースされたが、私たちのダイナミックなウェブサイトされていた、データソースが存在しなければならない、我々は、mysqlの、mysqlのインストールエクスペリエンス、rootアカウントでのログイン、パスワードを選択します
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server
私たちは、遠隔アクセスのmysqlにできるように、許可は、(sqlserver1433ポートに類似)CentOSのファイアウォール-3306開いているポートを開き、ファイアウォールを再起動します
centOS预装了mariadb(mysql之父为了mysql可能存在闭源风险而搞mysql分支)
安装完以后mariadb自动就被替换了,将不再生效。
【安装】
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
【重启mysql服务】
# service mysqld restart
【修改密码】
初次安装mysql,root账户没有密码。
直接 #mysql -u root
# mysql>show databases;
mysql>set password for 'root'@'localhost' =password('设置你的密码');
Query OK, 0 rows affected (0.00 sec)
不需要重启数据库即可生效。
【配置】
#vim /etc/my.cnf
内容如下:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client]
default-character-set=utf8
# 加上 免得有中文乱码
[mysql]
[mysqld]
character-set-server = utf8
# 加上 免得有中文乱码
innodb_log_file_size=640M
max_allowed_packet = 64M
#加上,当你有大量数据要往数据库中存储就需要这个配置,例如二进制文件
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default-storage-engine=InnoDB
max_connections=151
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
【远程连接设置】- 我就想在家,在公司,在任何地方都能进入我自己的数据库操作一下,navicat连一下
#把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。
mysql> grant all privileges on *.* to root@'%'identified by 'password';
#如果是新用户而不是root,则要先新建用户
mysql>create user 'username'@'%' identified by 'password';
【重载】
配置文件修改后,别忘记重启mysql
service mysqld restart
参照します。https://www.cnblogs.com/zhaopei/p/netcore.html---感覚あなたは人生のコード農業Xieyuan