flask+gunicorn+supervisor+nginx環(huán)境安裝,裸Centos

裸centos的一些安裝部署

1、安裝python-pip

首先安裝epel擴(kuò)展源:

    yum -y install epel-release

更新完成之后,安裝pip:

    yum -y install python-pip

2、安裝python依賴包:

初次直接運(yùn)行:

    pip install -r requirement.list

如果是裸的centos絕對(duì)會(huì)報(bào)錯(cuò)!

然后開始漫長(zhǎng)的改錯(cuò)安裝。

### 錯(cuò)誤一:EnvironmentError: mysql_config not found

原因:缺少mysql驅(qū)動(dòng)導(dǎo)致,所以加上mysql就行

`yum -y install mysql-devel`

錯(cuò)誤二:error: command 'gcc' failed with exit status 1

原因:沒有g(shù)cc命令(c語言編譯器),沒有 那就安就行了

`yum -y install gcc`

但是還是會(huì)再次報(bào)錯(cuò):然后 我們需要安裝下 

`yum -y install python-devel`

以上,就安裝完了依賴包。

3、安裝gunicorn

沒有別的就一個(gè):

`pip install gunicorn`

4、安裝supervisor

安裝命令

`easy_install supervisor`

驗(yàn)證是否成功:echo_supervisord_conf

然后mkdir /etc/supervisor

    echo_supervisord_conf > /etc/supervisor/supervisord.conf    

現(xiàn)在有配置文件還是不夠,我們需要擴(kuò)展,所以

    mkdir   /etc/supervisor/config.d 

修改/etc/supervisor/supervisord.conf的最下面的一行include

    files = /etc/supervisor/config.d/*.conf



最基本的配置:

[program:tomcat]
command=/opt/apache-tomcat-8.0.35/bin/catalina.sh run
directory=xxxx
autostart=true
autorestart=true
startsecs=5
priority=1
stopasgroup=true
killasgroup=true

5、安裝nginx

安裝各種依賴項(xiàng):

1、查看內(nèi)核版本,看看是否高于2.6。#2.6版本以上內(nèi)核才支持epoll

2、安裝GCC編譯器

yum -y install gcc

3、安裝C++編譯器

yum -y install gcc-c++

4、安裝PCRE庫 為了支持正則表達(dá)式

yum install -y pcre pcre-devel

5、安裝zlib庫

yum install -y zlib zlib-devel

6、安裝OpenSSL

yum install -y openssl openssl-devel

7、安裝nginx

yum -y install nginx

以上依賴環(huán)境全部安裝完成。

全部都安裝的命令:

yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel nginx

6、設(shè)置系統(tǒng)時(shí)間

下載工具:ntp

yum -y install ntp
ntpdate -u asia.pool.ntp.org
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

7、設(shè)置supervisor為開機(jī)自啟動(dòng)

1、vim /lib/systemd/system/supervisord.service

2、

[Unit]
Description=Process Monitoring and Control Daemon
After=rc-local.service



[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecReload=supervisorctl reload



[Install]
WantedBy=multi-user.target

3、systemctl enable supervisord.service

8、mysql遠(yuǎn)程授權(quán)訪問

 GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "password";
 flush privileges;

 
[mysqld] 
skip_name_resolve 
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容