.net core 部署在Linux系統上運行的環境搭建總結


 

安裝Linux用的是騰訊雲的centos7.5,需要安裝有環境有mysql5.7  .netcore2.1 nginx1.14

1.首先是mysql的安裝

我用的鏈接工具是putty,首先root登入系統

采用yum的方式安裝mysql

1.安裝mysql的yum源

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

2.安裝mysql-community.repo
mysql-community-source.repo依賴包

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

 

3.安裝mysql

yum install -y mysql-server

 

安裝完成

4.運行mysql,並查看運行狀態

service mysqld start
service mysqld status

運行成功

 

5.由於mysql5.7 會生成一個隨機密碼,所有先查看密碼 (mysql5.6 也有隨機密碼,5.5不知道)

 

grep "password" /var/log/mysqld.log

箭頭值得就是隨機密碼,我們記錄下來

6.登錄 MySQL並更新用戶 root 的密碼,這里我們設置了passwordA1.作為新密碼

mysql -u root -p
SET PASSWORD
= PASSWORD('passwordA1.'); ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; flush privileges;

7.設置mysql可以被任意ip訪問和root 本地訪問

grant all privileges on *.* to root@"%" identified by "passwordA1."; 
grant all privileges on
*.* to root@"localhost" identified by "passwordA1.";
flush privileges;

8.MySQL控制命令:啟動、停止、重啟、查看狀態

service mysqld start
service mysqld stop
service mysqld restart
service mysqld status
systemctl start mysqld
service mysqld stop
service mysqld restart
systemctl status mysqld

9.測試遠程連接

 連接成功!

2. .net core2.1的安裝

參照官方文檔,地址:https://www.microsoft.com/net/learn/dotnet/hello-world-tutorial#install

1.添加yum源

sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm

2.升級所有包同時也升級軟件和系統內核

sudo yum update

3.安裝.net core

sudo yum install dotnet-sdk-2.1.4

3. nginx的安裝

1.添加nginx源

sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2.安裝nginx

sudo yum install nginx

3.啟動nginx並設置開機啟動

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

訪問web服務成功

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM