************************* Core 2.0.2 *******************************
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl= https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'
sudo yum install libunwind libicu
sudo yum install dotnet-sdk-2.0.2
****************************** MySQL *****************************
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
yum install mysql-community-server
//2、重启MySQL服务 systemctl start mysqld.service
systemctl restart mysqld.service
//mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。
//在这里A temporary password is generated for root@localhost:
ALTER USER 'root'@'localhost' IDENTIFIED BY '自定义特殊密码';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '自定义特殊密码' WITH GRANT OPTION;
systemctl start firewalld.service
firewall-cmd --zone=public --add-port=3306/tcp --permanent
//11、修改默认编码配置 在[mysqld]下面直接添加
character_set_server=utf8
init_connect='SET NAMES utf8'
systemctl restart mysqld.service
//13、创建MySQL用户(用户名,密码,权限)
CREATE USER 'admin'@'%' IDENTIFIED BY '自己的密码';
GRANT GRANT OPTION ON *.* TO 'admin'@'%';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON *.* TO 'admin'@'%';
***************************** 防火墙配置 *********************************
//1、将接口添加到区域,默认接口都在public
firewall-cmd --zone=public --add-interface=eth0 --permanent
# firewall-cmd --set-default-zone=public --permanent
firewall-cmd --zone=public --add-port=5000/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
************************* Nginx ***************************************
curl -o nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
systemctl enable nginx.service
vim /etc/nginx/conf.d/default.conf
proxy_pass http://localhost:5000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
//6、如遇到报错:nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory),执行下面的
yum install policycoreutils-python
sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx
sudo semodule -i mynginx.pp
****************** 配置守护服务(Supervisor) ******************
yum install python-setuptools
echo_supervisord_conf > /etc/supervisor/supervisord.conf
vim /etc/supervisor/supervisord.conf
;files = relative/directory/*.ini
command=dotnet first.dll ;
//运行程序的命令
directory=/mycore/first/ ;
//命令执行的目录
autorestart=true ;
//程序意外退出是否自动重启
stderr_logfile=/var/log/myCore1.err.log ;
//错误日志文件
stdout_logfile=/var/log/myCore1.out.log ;
输出日志文件
environment=ASPNETCORE_ENVIRONMENT=Production ;
//进程环境变量
supervisord -c /etc/supervisor/supervisord.conf
Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.
//解决方法:(如果在失败,参见:https://segmentfault.com/a/1190000003955182)
sudo unlink /tmp/supervisor.sock
vim /usr/lib/systemd/system/supervisord.service
# dservice for systemd (CentOS 7.0+)
# by ET-CS (https://github.com/ET-CS)
Description=Supervisor daemon
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
WantedBy=multi-user.target
systemctl enable supervisord
systemctl is-enabled supervisord