Ubuntu16.04系統(tǒng)搭建.Net Core開發(fā)環(huán)境
1.安裝 Git
sudo apt-get update sudo apt-get install git Do you want to continue? [Y/n] Y git --version
2. 安裝 UFW
sudo apt-get install ufw sudo ufw enable sudo ufw default deny sudo ufw allow 22/tcp sudo ufw allow 80/tcp sudo ufw allow 3306/tcp sudo ufw allow 27017/tcp sudo ufw allow 6379/tcp sudo ufw allow 8000:9000/tcp
3.安裝 Nginx
sudo apt-get install build-essential sudo apt-get install libtool sudo apt-get update sudo apt-get install libpcre3 libpcre3-dev sudo apt-get install zlib1g-dev sudo apt-get install openssl wget http://nginx.org/download/nginx-1.14.2.tar.gz tar -zxvf nginx-1.14.2.tar.gz cd nginx-1.14.2 ./configure --prefix=/usr/local/nginx make sudo make install sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ps -ef|grep nginx curl -L http://127.0.0.1/index.html vi ~/.profile INSERT >>>>>>> export PATH=$PATH:/usr/local/nginx/sbin source ~/.profile vi /etc/init.d/nginx.server COPY INSERT >>>>>>> sudo chmod +x /etc/init.d/nginx.server sudo sysv-rc-conf nginx.server on
unable to resolve host iZs3y2byjpi9oxZ
解決方案:
vi /etc/hosts INSERT >>>>>>> 127.0.0.1 iZs3y2byjpi9oxZ
/etc/init.d/nginx.server
#!/bin/sh set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="nginx daemon" NAME=nginx DAEMON=/usr/local/nginx/sbin/$NAME SCRIPTNAME=/etc/init.d/$NAME.server # If the daemon file is not found, terminate the script. test -x $DAEMON || exit 0 d_start() { $DAEMON || echo -n " already running" } d_stop() { $DAEMON –s quit || echo -n " not running" } d_reload() { $DAEMON –s reload || echo -n " could not reload" } case "$1" in start) echo -n "Starting $DESC: $NAME" d_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" d_stop echo "." ;; reload) echo -n "Reloading $DESC configuration..." d_reload echo "reloaded." ;; restart) echo -n "Restarting $DESC: $NAME" d_stop # Sleep for two seconds before starting again, this should give the # Nginx daemon some time to perform a graceful stop. sleep 2 d_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2 exit 3 ;; esac exit 0
4.安裝 NetCore
wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-3.1 dotnet --info
5.安裝 MySQL
# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz tar zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz sudo mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql vi /etc/my.cnf COPY INSERT >>>>>>> cd /usr/local/mysql groupadd mysql useradd -r -g mysql mysql chown -R mysql:mysql ./ sudo bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data # copy initial password [Note] A temporary password is generated for root@localhost: kiZI&a&kk6SQ sudo ./support-files/mysql.server start ps -ef|grep mysql ./bin/mysql -u root -p Enter password: kiZI&a&kk6SQ ALTER USER 'root' @'localhost' IDENTIFIED BY '123456'; CREATE USER 'root' @'%' IDENTIFIED BY '123456'; GRANT ALL ON *.* TO 'root' @'%'; FLUSH privileges; sudo cp ./support-files/mysql.server /etc/init.d/mysql.server sudo sysv-rc-conf mysql.server on vi ~/.profile INSERT >>>>>>> export PATH=$PATH:/usr/local/mysql/bin source ~/.profile
/etc/my.cnf
[mysqld] port = 3306 basedir=/usr/local/mysql datadir=/usr/local/mysql/data max_connections=200 max_connect_errors=10 character-set-server=utf8mb4 default-storage-engine=INNODB default_authentication_plugin=mysql_native_password [mysql] default-character-set=utf8mb4 [client] port=3306 default-character-set=utf8mb4
6.安裝 NodeJs
wget https://nodejs.org/dist/v14.15.1/node-v14.15.1-linux-x64.tar.xz tar xf node-v14.15.1-linux-x64.tar.xz sudo mv node-v14.15.1-linux-x64 /usr/local/nodejs cd /usr/local/nodejs ln -s /usr/local/nodejs/bin/node /usr/local/bin/ node -v ln -s /usr/local/nodejs/bin/npm /usr/local/bin/ npm -v npm config set registry https://registry.npm.taobao.org # install pm2 npm install pm2@latest -g ln -s /usr/local/nodejs/bin/pm2 /usr/local/bin/ sudo pm2 status
7.安裝 MongoDB
wget -qO - https://www.mongodb.org/static/pgp/server-3.4.asc | sudo apt-key add - echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list sudo apt-get update sudo apt-get install -y mongodb-org sudo service mongod start sudo service mongod status sudo service mongod stop vi /etc/mongod.conf EDIT >>>>>>> # network interfaces net: port: 27017 #bindIp: 127.0.0.1 bindIp: 0.0.0.0 #security: security: authorization: enabled sudo service mongod restart ps -ef | grep mongod # 進(jìn)入數(shù)據(jù)庫 mongo # 用admin身份 use admin # 創(chuàng)建超級(jí)管理員賬號(hào) db.createUser( {user: "admin",pwd: "admin",roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]}) # 測(cè)試授權(quán) db.auth("admin","admin") # 建庫授權(quán) use testdb # 創(chuàng)建數(shù)據(jù)庫管理賬號(hào) db.createUser( {user: "root",pwd: "123456",roles: [ { role: "readWrite", db: "testdb" } ]}) # 授權(quán)用戶 db.auth("root","123456") # 數(shù)據(jù)測(cè)試 db.log.insert({"created":"db","name":"testdb"}) db.log.insert({"created":"user","name":"root"}) exit # 開機(jī)自啟 sudo systemctl enable mongod
/etc/mongod.conf
# mongod.conf # for documentation of all options, see: # https://docs.mongodb.com/v3.4/reference/configuration-options/ # systemLog Options: systemLog: destination: file path: "/usr/local/mongodb/log/mongod.log" logAppend: true # processManagement Options: processManagement: fork: true # net Options: net: port: 27017 #bindIp: 127.0.0.1 bindIp: 0.0.0.0 # security Options: #security: security: authorization: enabled # setParameter Options: setParameter: enableLocalhostAuthBypass: false # storage Options: storage: dbPath: "/usr/local/mongodb/data" journal: enabled: true # operationProfiling Options: # replication Options: # sharding Options: # auditLog Options: # snmp Options:
MongDB數(shù)據(jù)庫角色對(duì)應(yīng)如下:
- Read:允許用戶讀取指定數(shù)據(jù)庫
- readWrite:允許用戶讀寫指定數(shù)據(jù)庫
- dbAdmin:允許用戶在指定數(shù)據(jù)庫中執(zhí)行管理函數(shù),如索引創(chuàng)建、刪除,查看統(tǒng)計(jì)或訪問system.profile
- userAdmin:允許用戶向system.users集合寫入,可以找指定數(shù)據(jù)庫里創(chuàng)建、刪除和管理用戶
- clusterAdmin:只在admin數(shù)據(jù)庫中可用,賦予用戶所有分片和復(fù)制集相關(guān)函數(shù)的管理權(quán)限。
- readAnyDatabase:只在admin數(shù)據(jù)庫中可用,賦予用戶所有數(shù)據(jù)庫的讀權(quán)限
- readWriteAnyDatabase:只在admin數(shù)據(jù)庫中可用,賦予用戶所有數(shù)據(jù)庫的讀寫權(quán)限
- userAdminAnyDatabase:只在admin數(shù)據(jù)庫中可用,賦予用戶所有數(shù)據(jù)庫的userAdmin權(quán)限
- dbAdminAnyDatabase:只在admin數(shù)據(jù)庫中可用,賦予用戶所有數(shù)據(jù)庫的dbAdmin權(quán)限。
- root:只在admin數(shù)據(jù)庫中可用。超級(jí)賬號(hào),超級(jí)權(quán)限
7.安裝 Redis
sudo apt-get install redis-server Do you want to continue? [Y/n] Y ps -ef|grep redis vi /ect/redis/redis.conf EDIT >>>>>>> #bind 127.0.0.1 requirepass 123456 service redis-server restart
服務(wù)自啟配置
sudo apt-get install sysv-rc-conf # redis-server sudo sysv-rc-conf redis-server on # nginx.server sudo sysv-rc-conf nginx.server on # mysql.server sudo sysv-rc-conf mysql.server on # mongo sudo systemctl enable mongod
實(shí)例軟件的版本:
nginx-1.14.2.tar.gz
packages-microsoft-prod.deb
mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
node-v14.15.1-linux-x64.tar.xz
到此這篇關(guān)于Ubuntu系統(tǒng)搭建.Net Core開發(fā)環(huán)境的文章就介紹到這了。希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- .Net?Core3.0?WebApi?項(xiàng)目框架搭建之使用Serilog替換掉Log4j
- .Net Core服務(wù)治理Consul搭建集群
- 基于Jenkins搭建.NET Core持續(xù)集成環(huán)境過程圖解
- Centos7系統(tǒng)下搭建.NET Core2.0+Nginx+Supervisor環(huán)境
- CodeFirst從零開始搭建Asp.Net Core2.0網(wǎng)站
- .Net Core+Angular Cli/Angular4開發(fā)環(huán)境搭建教程
- VS2015 搭建Asp.net core開發(fā)環(huán)境的方法
- 詳解.Net Core + Angular2 環(huán)境搭建
- 云服務(wù)器下搭建ASP.NET Core環(huán)境
- Linux(Ubuntu)下搭建ASP.NET Core環(huán)境
- win10下ASP.NET Core部署環(huán)境搭建步驟
- Windows Server 2012 R2 Standard搭建ASP.NET Core環(huán)境圖文教程
相關(guān)文章
ASP.NET MVC中將控制器分離到類庫的實(shí)現(xiàn)
這篇文章主要介紹了ASP.NET MVC中將控制器分離到類庫的實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下2015-06-06ASP.NET Core中如何使用表達(dá)式樹創(chuàng)建URL詳解
這篇文章主要給大家介紹了關(guān)于ASP.NET Core中如何使用表達(dá)式樹創(chuàng)建URL的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-10-10.Net獲取URL中文參數(shù)值的亂碼問題解決方法總結(jié)
這篇文章主要介紹了.Net獲取URL中文參數(shù)值的亂碼問題解決方法,總結(jié)分析了針對(duì)URL參數(shù)傳遞中出現(xiàn)的亂碼問題與相應(yīng)的解決方法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2016-08-08asp.net用三層實(shí)現(xiàn)多條件檢索示例
三層將項(xiàng)目分為界面層,業(yè)務(wù)邏輯層和數(shù)據(jù)訪問層,下面為大家介紹下asp.net如何用三層實(shí)現(xiàn)多條件檢索,感興趣的朋友可以參考下2014-07-07調(diào)試ASP.NET應(yīng)用程序的方法和技巧
調(diào)試ASP.NET應(yīng)用程序的方法和技巧...2006-09-09總結(jié)Visual Studio下ASP.NET模板化控件中的數(shù)據(jù)綁定
.NET框架中提供了很多數(shù)據(jù)綁定的組件,這里我們就來總結(jié)Visual Studio下ASP.NET模板化控件中的數(shù)據(jù)綁定,需要的朋友可以參考下2016-06-06