欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

怎么用CentOS7+node.js+nginx+MySQL搭建服務(wù)器

本篇內(nèi)容介紹了“怎么用CentOS7+node.js+nginx+MySQL搭建服務(wù)器”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!

站在用戶的角度思考問題,與客戶深入溝通,找到訥河網(wǎng)站設(shè)計與訥河網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都網(wǎng)站建設(shè)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名注冊、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋訥河地區(qū)。

工具

安裝git

執(zhí)行:

sudo yum install git

安裝nodejs

查看最新版本

下載

先進入/usr/src文件夾,這個文件夾通常用來存放軟件源代碼:

cd /usr/local/src/
wget https://nodejs.org/dist/v4.6.0/node-v4.6.0.tar.gz

版本自己替換

解壓

tar zxvf node-v4.6.0.tar.gz

編譯安裝

cd node-v4.6.0/
./configure // 執(zhí)行 node.js 安裝包自帶的腳本,修改相關(guān)的系統(tǒng)配置文件

發(fā)現(xiàn)報錯了,提示系統(tǒng)中沒有安裝c編譯器,接下來先安裝c編譯器

安裝gcc

yum install gcc

安裝g++

yum install gcc-c++

安裝gfortran

yum install gcc-gfortran

重新執(zhí)行:

cd node-v4.6.0/
./configure // 執(zhí)行 node.js 安裝包自帶的腳本,修改相關(guān)的系統(tǒng)配置文件
make //編譯 c源代碼為 可執(zhí)行的 linux程序

好慢啊。。。。。。難道是我買的最低配置的原因么。。。。。。

終于跑完了?,全程大約十幾分鐘,所以大家要耐心等待哦。。。。。。

sudo make install // 安裝文件
node –version //查看安裝node的版本
npm -v //查看npm的版本

現(xiàn)在已經(jīng)安裝了node.js, 可以開始部署應(yīng)用程序, 首先要使用node.js的模塊管理器npm安裝express middleware 和forever(一個用來確保應(yīng)用程序啟動并且在需要時重啟的非常有用的模塊),其中g(shù)參數(shù)是把express安裝到nodejs的lib目錄,d參數(shù)表示同時安裝依賴模塊包:

npm install -gd express-generator forever

建立測試項目并執(zhí)行

在/home文件夾下執(zhí)行:

express testapp
cd testapp
npm install
npm start

上面,第一條命令是創(chuàng)建express框架通用項目,第三條命令是安裝依賴包,第四條是執(zhí)行。

執(zhí)行:

cat package.json

怎么用CentOS7+node.js+nginx+MySQL搭建服務(wù)器

第四條命令就相當于執(zhí)行了node ./bin/www。

怎么用CentOS7+node.js+nginx+MySQL搭建服務(wù)器

這樣就運行成功了。

但是當我們關(guān)閉終端之后,進程就將結(jié)束,現(xiàn)在剛安裝的forever就派上用場了,forever可以讓進程在終端關(guān)閉之后繼續(xù)運行:

forever start ./bin/www

我們可以使用下面命令查看forever運行的程序:

forever list

怎么用CentOS7+node.js+nginx+MySQL搭建服務(wù)器

現(xiàn)在我們就可以在瀏覽器中輸入:公網(wǎng)ip + :3000,來訪問我們的程序。

如果要修改3000端口,我們可以修改./bin/www文件中關(guān)于監(jiān)聽3000端口的字段。

停止運行:

forever stop 0 //0代表前面[0],這是當前進程的id

停止所有:

forever stopall

二、安裝nginx

http請求是80端口,但是在linux上非root權(quán)限是無法使用1024以下端口的,并且因為安全原因,最好不要使用root權(quán)限登錄服務(wù)器,所以無法直接用node.js程序監(jiān)聽80端口。因此我們需要使用nginx給node.js做反向代理,將80端口指向應(yīng)用程序監(jiān)聽的端口(如node.js默認的3000端口)。

添加nginx倉庫

yum install epel-release

下載nginx

yum install nginx

啟用nginx服務(wù)

service nginx start

添加開機啟動

systemctl enable nginx

修改nginx配置文件

vim /etc/nginx/nginx.conf //使用lnpm意見安裝,nginx 目錄: /usr/local/nginx/

添加:

server {
 listen 80;
 server_name jakexin.top,www.jakexin.top;  #綁定的域名
 location /
 {
 proxy_set_header x-real-ip  $remote_addr;
 proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
 proxy_set_header host   $http_host;
 proxy_set_header x-nginx-proxy true;
 proxy_set_header connection "";
 proxy_http_version 1.1;
 proxy_pass http://127.0.0.1:3000;  #對應(yīng)該的nodejs程序端口
 }
 access_log /mnt/log/www/jakexin_access.log; #網(wǎng)站訪問日志
}

測試配置文件是否能夠正確運行

nginx -t

怎么用CentOS7+node.js+nginx+MySQL搭建服務(wù)器

這樣就是配置成功

重啟nginx

service nginx restart

現(xiàn)在直接在瀏覽器中輸入我們配置的域名就可以訪問我們的項目了。

三、安裝mysql

查看可用版本

yum list | grep mysql

怎么用CentOS7+node.js+nginx+MySQL搭建服務(wù)器

在centos 7中不能使用yum -y install mysql mysql-server mysql-devel安裝,這樣會默認安裝mysql的分支mariadb。

mariadb數(shù)據(jù)庫管理系統(tǒng)是mysql的一個分支,主要由開源社區(qū)在維護,采用gpl授權(quán)許可 mariadb的
的是完全兼容mysql,包括api和命令行,使之能輕松成為mysql的代替品。

正確的安裝方法

眾所周知,linux系統(tǒng)自帶的repo是不會自動更新每個軟件的最新版本(基本都是比較靠后的穩(wěn)定版),所以無法通過yum方式安裝mysql的高級版本。所以我們需要先安裝帶有當前可用的mysql5系列社區(qū)版資源的rpm包。

rpm -uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum repolist enabled | grep “mysql.-community.“ //查看當前可用資源

從上面的列表可以看出, mysql56-community/x86_64 和 mysql 5.6 community server 可以使用。

因此,我們就可以直接用yum方式安裝了mysql5.6版本了。

yum -y install mysql-community-server

mysql基礎(chǔ)配置

systemctl enable mysqld //添加到開機啟動
systemctl start mysqld //啟用進程
mysql_secure_installation
note: running all parts of this script is recommended for all mysql
 servers in production use! please read each step carefully!
in order to log into mysql to secure it, we'll need the current
password for the root user. if you've just installed mysql, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
enter current password for root (enter for none): 
ok, successfully used password, moving on...
setting the root password ensures that nobody can log into the mysql
root user without the proper authorisation.
set root password? [y/n] y   [設(shè)置root用戶密碼]
new password: 
re-enter new password: 
password updated successfully!
reloading privilege tables..
 ... success!
by default, a mysql installation has an anonymous user, allowing anyone
to log into mysql without having to have a user account created for
them. this is intended only for testing, and to make the installation
go a bit smoother. you should remove them before moving into a
production environment.
remove anonymous users? [y/n] y   [刪除匿名用戶]
 ... success!
normally, root should only be allowed to connect from 'localhost'. this
ensures that someone cannot guess at the root password from the network.
disallow root login remotely? [y/n] y [禁止root遠程登錄]
 ... success!
by default, mysql comes with a database named 'test' that anyone can
access. this is also intended only for testing, and should be removed
before moving into a production environment.
remove test database and access to it? [y/n] y  [刪除test數(shù)據(jù)庫]
 - dropping test database...
error 1008 (hy000) at line 1: can't drop database 'test'; database doesn't exist
 ... failed! not critical, keep moving...
 - removing privileges on test database...
 ... success!
reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
reload privilege tables now? [y/n] y  [刷新權(quán)限]
 ... success!
 
all done! if you've completed all of the above steps, your mysql
installation should now be secure.
thanks for using mysql! 
cleaning up...

四、操作mysql

配置遠程連接

grant all privileges on . to ‘root'@'%' identified by ‘密碼' with grant option; //添加授權(quán)的用戶
flush privileges; //刷新數(shù)據(jù)庫

檢測是否開啟3306端口

netstat -tunlp[object Object]

看到3306端口被開啟之后,我們就可以使用本地客戶端遠程訪問數(shù)據(jù)庫了

“怎么用CentOS7+node.js+nginx+MySQL搭建服務(wù)器”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

文章題目:怎么用CentOS7+node.js+nginx+MySQL搭建服務(wù)器
網(wǎng)頁URL:http://chinadenli.net/article26/ppcecg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標簽優(yōu)化、小程序開發(fā)網(wǎng)站維護、電子商務(wù)網(wǎng)站收錄、關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作
国产欧美日韩精品一区二区| 精品推荐国产麻豆剧传媒| 久久99午夜福利视频| 中文字幕一区二区久久综合| 尤物久久91欧美人禽亚洲| 国产欧洲亚洲日产一区二区| av在线免费观看在线免费观看| 成年午夜在线免费视频| 千仞雪下面好爽好紧好湿全文 | 亚洲欧美日本视频一区二区| 国产女高清在线看免费观看| 国产在线观看不卡一区二区| 麻豆视传媒短视频免费观看| 精品伊人久久大香线蕉综合| 国产亚洲欧美另类久久久| 国产精品免费福利在线| 欧美人妻盗摄日韩偷拍| 亚洲欧洲精品一区二区三区| 日韩av亚洲一区二区三区| 欧美黑人精品一区二区在线| 又色又爽又无遮挡的视频| 少妇肥臀一区二区三区| 午夜久久久精品国产精品| 91在线国内在线中文字幕| 国内精品偷拍视频久久| 亚洲国产成人av毛片国产| 大香蕉伊人精品在线观看| 国产亚洲二区精品美女久久| 在线观看欧美视频一区| 都市激情小说在线一区二区三区| 午夜亚洲少妇福利诱惑| 日韩精品一区二区三区四区| 真实国产乱子伦对白视频不卡| 91麻豆视频国产一区二区 | 沐浴偷拍一区二区视频| 日本深夜福利视频在线| 亚洲欧美中文字幕精品| 国产成人综合亚洲欧美日韩| 四季av一区二区播放| 国产精品国产亚洲看不卡| 国产一区二区三区草莓av|