【深刻學習linux】CentOS 7 最小化安裝後程序必須安裝的組件

centos平臺編譯環境使用以下指令

安裝make:

yum -y install gcc automake autoconf libtool make

安裝g++:

yum install gcc gcc-c++

Nginx安裝參考https://blog.csdn.net/jiangxiaobo666/article/details/90404020

Python

 

CentOS 7.2 默認安裝了python2.7.5 由於一些命令要用它好比yum 它使用的是python2.7.5。html

使用 python -V 命令查看一下是否安裝Pythonnode

而後使用命令 which python 查看一下Python可執行文件的位置python

 

 可見執行文件在/usr/bin/ 目錄下,切換到該目錄下執行 ll python* 命令查看 mysql

 

 

python 指向的是python2.7linux

 

2.開始編譯安裝python3nginx

先安裝相關包c++

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

不能忽略相關包,我以前就沒有安裝readline-devel致使執行python模式沒法使用鍵盤的上下左右鍵;web

 

 

3.7版本須要一個新的包libffi-devel,安裝此包以後再次進行編譯安裝便可。sql

yum install libffi-devel -y

 

由於咱們要安裝python3版本,因此python要指向python3才行,目前尚未安裝python3,先備份shell

mv /usr/bin/python /usr/bin/python.bak

 

由於執行yum須要python2版本,因此咱們還要修改yum的配置,執行:

vi /usr/bin/yum

 

 同理 vi /usr/libexec/urlgrabber-ext-down 文件裏面的#! /usr/bin/python 也要修改成#! /usr/bin/python2

 

python安裝

下載地址:https://www.python.org/ftp/python/3.7.4/

下面是把 python 安裝到 /usr/local/lnmp/python374/ 目錄下的詳細步驟:

cd /usr/local/src/lnmp/
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
tar -zxvf Python-3.7.4.tgz
cd Python-3.7.4

./configure --prefix=/usr/local/lnmp/python374

make
make install

 查看是否安裝成功

[root@localhost Python-3.7.4]# /usr/local/lnmp/python374/bin/python3 -V
Python 3.7.4

 對於centos7系統裏面原本存在python命令,是yum須要的2.7.5的版本,這裏不能進行刪除或者覆蓋,否則yum就用不起了。

[root@localhost Python-3.7.4]# which python
/usr/bin/python

 解決方案:

安裝完畢,/usr/local/lnmp/python374/bin/目錄下就會有python3了,所以咱們能夠添加軟鏈到執行目錄下/usr/bin

ln -s /usr/local/lnmp/python374/bin/python3 /usr/bin/python

測試安裝成功了沒,執行

python -V  看看輸出的是否是python3的版本

執行python2 -V  看到的就是python2的版本

創建pip3的軟連接

ln -s /usr/local/lnmp/python374/bin/pip3 /usr/bin/pip3

 升級pip3命令:

pip3 install --upgrade pip

給python3安裝django和uwsgi以及配置啓動項目的ini(或者xml)文件

pip3 install django 或者 pip3 install django==2.2.5
pip3 install uwsgi

創建軟鏈接

ln   -s   /usr/local/lnmp/python374/bin/django-admin /usr/bin/django-admin

ln   -s  /usr/local/lnmp/python374/bin/uwsgi       /usr/bin/uwsgi

若是下面這行命令輸出了一個版本號,證實你已經安裝了此版本的 Django;若是你獲得的是一個「No module named django」的錯誤提示,則代表你還未安裝。

python -m django --version

建立一個Django項目,打開命令行,cd 到一個你想放置你代碼的目錄,而後運行如下命令:

django-admin startproject mysite

這裏我在根目錄新建了 web 目錄(mkdir -p /home/webcode/django),而後 cd /home/webcode/django,執行 django-admin startproject testweb,發現生成了testweb 。

[root@localhost django]# django-admin startproject testweb
[root@localhost django]# ls
testweb

測試運行:

python manage.py runserver
或者
python manage.py runserver 8080
或者
python manage.py runserver 0:8080
python manage.py runserver 0.0.0.0:8080

發現出現異常錯誤:

exception:django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).

翻譯下就是當前sqlite3的版本是3.7.17,可是須要sqlite3.8.3之後的版本才能夠啓動。若是不須要使用sqlite能夠忽略,好比我直接使用mysql。

將配置使用mysql數據庫:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'xx',
        'USER': 'x',
        'PASSWORD': 'xxx',
        'HOST': 'xxx',
        'PORT': 'xx'
    }
}

發現出現異常錯誤:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?

那麼能夠查詢當前安裝哪些模塊?

[root@localhost testweb]# python
Python 3.7.4 (default, Oct 24 2019, 20:27:49) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 3.7's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at https://docs.python.org/3.7/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

help> modules
Please wait a moment while I gather a list of all available modules...

__future__          _weakref            heapq               selectors
_abc                _weakrefset         hmac                setuptools
_ast                _xxtestfuzz         html                shelve
_asyncio            abc                 http                shlex
_bisect             aifc                idlelib             shutil
......

發現沒有mysql相關模塊,那麼只能進行安裝了:

pip3 install pymysql

很是順利的就安裝成功了,然而Django並不認這個外來的和尚,咋辦呢,也好辦,找到mysite/mysite/__init__.py,在裏面輸入如下內容並保存:

import pymysql
pymysql.install_as_MySQLdb()

而後我再運行python manage.py runserver時,又爆了一個錯誤:

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

別急,這主要是django2.2內部的一個版本限制在做怪

處理方案

1.修復源碼
按照文中配置,報錯django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
緣由:django2.2和pymysql版本不匹配。mysqldb不支持python3.

具體:

解決方案:
1、raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.’ % Database.version)
  django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.  
解決辦法:
C:\Python37\Lib\site-packages\django\db\backends\mysql(python安裝目錄)打開base.py,註釋掉如下內容:        
if version < (1, 3, 13):           raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.’ % Database.version)   
2、File 「C:\Python37\lib\site-packages\django\db\backends\mysql\operations.py」, line 146, in last_executed_query   
query = query.decode(errors=‘replace’)   
AttributeError: ‘str’ object has no attribute ‘decode’   
解決辦法:
打開此文件把146行的decode修改成encode

找到安裝python的這個位置

cd /usr/local/lnmp/python374/lib/python3.7/site-packages/django/db/backends/mysql

vim base.py

而後進行修改35行,進行註釋:

#if version < (1, 3, 13):
#    raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)

錯誤:AttributeError: 'str' object has no attribute 'decode' 而後進行修改

cd /usr/local/lnmp/python374/lib/python3.7/site-packages/django/db/backends/mysql

vim operations.py

而後進行修改146行,將 decode 改爲 encode:

        query = getattr(cursor, '_executed', None)
        if query is not None:
            query = query.encode(errors='replace')
        return query

而後我再運行python manage.py runserver 0:8000時,又爆了一個提示:

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

固然這個提示並不影響自帶服務器的運行,這時候咱們訪問http://xxxx:8000,會看到成功提示:

DisallowedHost at /
Invalid HTTP_HOST header: '192.168.182.129:8000'. You may need to add '192.168.182.129' to ALLOWED_HOSTS.

在咱們建立的項目裏修改setting.py文件

ALLOWED_HOSTS = [‘*‘]  #在這裏請求的host添加了*,表示任意地址均可以訪問

固然了,對於前面那個警告提示,我固然看着不爽,並且他也告訴我怎麼作能夠解決他,固然要處理啦!我飛快的複製一下內容到命令行中:

python manage.py makemigrations
python manage.py migrate

而後在重啓服務,就很正常啦!

 

django-nginx-uwsgi 搭建

在 /etc/ 目錄下建立一個 uwsgi9090.ini 文件

vim /etc/uwsgi9090.ini

[uwsgi]
master = true

processes = 4
pythonpath = /home/webcode/django/testweb

module = testweb.wsgi

socket = 127.0.0.1:9090

logto = /tmp/uwsgi9090.log

  # pid文件,用於下面的腳本啓動、中止該進程
  pidfile = /var/run/uwsgi9090.pid

 

找到nginx的安裝目錄(如:/usr/local/lnmp/nginx-1.4.2/),打開vim nginx.conf文件,修改server配置:

location / {
            include uwsgi_params;
            # 必須和uwsgi中的設置一致
            uwsgi_pass 127.0.0.1:9090;
        }

你能夠閱讀 Nginx 安裝配置 瞭解更多內容。

這裏也須要設置下靜態文件:

# 靜態文件
        location /static/ {
            alias /home/webcode/django/testweb/staticfiles/;
            index  index.html index.htm;
        }

 

設置完成後,在終端運行:

前後臺運行 uwsgi
uwsgi --ini /etc/uwsgi9090.ini &

而後在運行 nginx:/usr/local/lnmp/nginx-1.4.2/nginx
/usr/bin/nginx142 -> /usr/local/lnmp/nginx-1.4.2/nginx

在瀏覽器輸入:http://xxxx,訪問正常。

nginx和uwsgi還能夠配置更多的東西,這裏配置的都是最簡單須要的內容

這裏列出 nginx 和 uwsgi 關閉和開啓

ps -ef | grep uwsgi
root       1658   1268  2 15:26 pts/0    00:00:00 uwsgi --ini /etc/uwsgi9090.ini
root       1659   1658  0 15:26 pts/0    00:00:00 uwsgi --ini /etc/uwsgi9090.ini
root       1660   1658  0 15:26 pts/0    00:00:00 uwsgi --ini /etc/uwsgi9090.ini
root       1661   1658  0 15:26 pts/0    00:00:00 uwsgi --ini /etc/uwsgi9090.ini
root       1662   1658  0 15:26 pts/0    00:00:00 uwsgi --ini /etc/uwsgi9090.ini
root       1664   1268  0 15:26 pts/0    00:00:00 grep --color=auto uwsgi

kill -INT 1658 殺死全部進程
kill -9 1658 殺死某個進程

 參考地址:https://www.jianshu.com/p/c060448b3e78

 

centos7 安裝mysql5.6 http://www.javashuo.com/article/p-ovpuwphw-ez.html

1 卸載系統自帶的Mariadb

[root@localhost ~]# rpm -qa | grep mariadb  
mariadb-libs-5.5.64-1.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64
[root@localhost ~]# rpm -qa | grep mariadb  
[root@localhost ~]# 

2 下載mysql,

cd /usr/local/src/lnmp

wget  http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz

3 安裝軟件包:

yum install gcc gcc-c++ cmake ncurses-devel bison

建立mysql數據存放的文件

[root@localhost mysql]# mkdir -p /usr/local/lnmp/mysql/data

4 安裝mysql

tar -zxvf mysql-5.6.45.tar.gz
[root@localhost ~]# cd /usr/local/src/lnmp/mysql-5.6.45
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql \
-DINSTALL_DATADIR=/usr/local/lnmp/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1

參數說明:

-DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql        //安裝目錄

-DINSTALL_DATADIR=/usr/local/lnmp/mysql/data         //數據庫存放目錄

-DDEFAULT_CHARSET=utf8                        //使用utf8字符

-DDEFAULT_COLLATION=utf8_general_ci            //校驗字符

-DEXTRA_CHARSETS=all                            //安裝全部擴展字符集

-DENABLED_LOCAL_INFILE=1                        //容許從本地導入數據 


編輯安裝mysql,大概須要30 分鐘

make

make install  

5 初始化數據庫,配置mysql的配置文件

這裏須要添加一個mysql組和一個mysql用戶:

groupadd mysql

useradd -g mysql mysql

注::-g 所屬組 -d 家目錄 -s 所用的SHELL

 

還能夠參考:http://www.javashuo.com/article/p-yslfsfni-es.html

cd /usr/local/lnmp/mysql

./scripts/mysql_install_db --user=mysql

其餘配置

1、在 etc 下新建配置文件my.cnf,並在該文件中添加一下代碼: 
固然,也有簡單方式:直接copy一份my.cnf文件到/etc下,而後再修改便可。
e g:copy一份/usr/local/lnmp/mysql/support-files/下的my-default.cnf文件到/etc下 
命令爲:[root@localhost support-files]# cp my-default.cnf /etc/my.cnf

而後,配置/etc目錄下的my.cnf文件

[root@localhost support-files]# vim /etc/my.cnf

經過vim編輯器編輯my.cnf代碼以下:

[mysql]
# 設置mysql客戶端默認字符集
default-character-set=utf8 
socket=/var/lib/mysql/mysql.sock

[mysqld]
skip-name-resolve
# 設置3306端口
port = 3306 
socket=/var/lib/mysql/mysql.sock
# 設置mysql的安裝目錄
basedir=/usr/local/lnmp/mysql
# 設置mysql數據庫的數據的存放目錄
datadir=/usr/local/lnmp/mysql/data
# 容許最大鏈接數
max_connections=200
# 服務端使用的字符集默認爲8比特編碼的latin1字符集
character-set-server=utf8
# 建立新表時將使用的默認存儲引擎
default-storage-engine=INNODB
lower_case_table_name=1
max_allowed_packet=16M

六、配置MySQL

一、授予my.cnf最大權限

[root@localhost ~]# chmod 777 /etc/my.cnf

設置開機自啓動服務控制腳本:

二、複製啓動腳本到資源目錄

[root@localhost mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

三、增長mysqld服務控制腳本執行權限 

[root@localhost mysql]# chmod +x /etc/rc.d/init.d/mysqld

四、將mysqld服務加入到系統服務 

[root@localhost mysql]# chkconfig --add mysqld

五、檢查mysqld服務是否已經生效

[root@localhost mysql]# chkconfig --list mysqld

命令輸出相似下面的結果:

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

代表mysqld服務已經生效,在二、三、四、5運行級別隨系統啓動而自動啓動,之後可使用service命令控制mysql的啓動和中止

命令爲:service mysqld start和service mysqld stop

六、啓動mysqld 

[root@localhost mysql]# service mysqld start

啓動時候報錯:

[root@localhost ~]# service mysqld start
Warning: World-writable config file '/etc/my.cnf' is ignored
Starting MySQL.Warning: World-writable config file '/etc/my.cnf' is ignored
Warning: World-writable config file '/etc/my.cnf' is ignored
Logging to '/usr/local/lnmp/mysql/data/localhost.localdomain.err'.
 ERROR! The server quit without updating PID file (/usr/local/lnmp/mysql/data/localhost.localdomain.pid).

首先添加一個Mysql用戶:

groupadd mysql     //建立mysql組
useradd -g mysql mysql //建立mysql用戶添加到mysql組

解決辦法有下面這幾種:

cd /usr/local/lnmp/mysql/
chown -R mysql.mysql .
su - mysql
cd /usr/local/lnmp/mysql/

scripts/mysql_install_db
Warning: World-writable config file '/etc/my.cnf' is ignored
Installing MySQL system tables...Warning: World-writable config file '/etc/my.cnf' is ignored
2019-10-26 10:52:25 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-10-26 10:52:25 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2019-10-26 1

/usr/local/lnmp/mysql/bin/mysqld_safe --user=mysql &

/etc/rc.d/init.d/mysql status
Warning: World-writable config file '/etc/my.cnf' is ignored
 SUCCESS! MySQL running (1932)

而後再從新啓動:

service mysqld start
或者
/etc/rc.d/init.d/mysql start

Warning: World-writable config file '/etc/my.cnf' is ignored

出現這個警告是說:/etc/my.cnf的權限過高了。任意用戶都寫操做。

七、將mysql的bin目錄加入PATH環境變量,編輯 ~/.bash_profile文件

[root@localhost mysql]# vim ~/.bash_profile

在文件最後添加以下信息:

export PATH=$PATH:/usr/local/lnmp/mysql/bin

而後按ESC鍵

繼續 shift鍵加冒號打出來=>  :

接下來輸入wq回車便可

執行下面的命令是修改的內容當即生效:

[root@localhost mysql]# source ~/.bash_profile

八、以root帳戶登陸mysql,默認是沒有密碼的

[root@localhost mysql]# mysql -uroot -p

要輸入密碼的時候直接回車便可。

九、設置root帳戶密碼爲root(也能夠修改爲你要的密碼)

mysql>use mysql;
mysql>update user set password = PASSWORD('root') WHERE user = 'root'
mysql>flush privileges;

若是忘記密碼:請在配置文件加上

[mysqld]
# 忘記密碼請解開下面註釋
# skip-grant-tables

密碼修改後,將這行配置註釋掉重啓就能夠了。

十、設置遠程主機登陸,注意下面的your username 和 your password改爲你須要設置的用戶和密碼

mysql>GRANT ALL PRIVILEGES ON *.* TO 'your username'@'%' IDENTIFIED BY 'your password' WITH GRANT OPTION;

host xxx is not allowed to connect to this MYSQL server關於細節請查看:http://www.javashuo.com/article/p-ekzytwwt-ek.html

你想root使用123456從任何主機鏈接到mysql服務器的話,代碼以下:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

若是你想容許用戶root從ip爲192.168.1.3的主機鏈接到mysql服務器,並使用123456做爲密碼,代碼以下:
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’192.168.1.3′ IDENTIFIED BY ’123456′ WITH GRANT OPTION;

 Mysql> flush privileges

11. 若是本身想創建MYSQL用戶:

【若是記得root的帳號密碼,就能夠不設置這步】設置跳過密碼登錄root用戶

vim /etc/my.cnf

[mysqld]
# 忘記密碼請解開下面註釋
# skip-grant-tables

登錄

mysql -u root -p

完成以上流程就實現了一個基本的用戶生成並配置權限,若是須要控制用的CURD操做更改相關的權限便可

1、建立用戶:CREATE USER 'username'@'host' IDENTIFIED BY 'password';

username:用戶名;

host:指定在哪一個主機上能夠登陸,本機可用localhost,%通配全部遠程主機;

password:用戶登陸密碼;

舉例: CREATE USER 'test'@'%' IDENTIFIED BY 'I6FVIavxZl8Dkjhn';
2、受權:GRANT ALL PRIVILEGES ON  *.* TO 'username'@'%' IDENTIFIED BY 'password’; 格式:grant 權限 on 數據庫名.表名 to 用戶@登陸主機 identified by "用戶密碼"*.* 表明全部權; @ 後面是訪問MySQL的客戶端IP地址(或是 主機名) % 表明任意的客戶端,若是填寫 localhost 爲本地訪問(那此用戶就不能遠程訪問該mysql數據庫了)。
舉例:
GRANT ALL PRIVILEGES ON  *.* TO 'test'@'%' IDENTIFIED BY 'I6FVIavxZl8Dkjhn'; #任意客戶端能夠,可是本地是不能鏈接的,因此還須要一句
GRANT ALL PRIVILEGES ON  *.* TO 'test'@'localhost' IDENTIFIED BY 'I6FVIavxZl8Dkjhn'; #執行這兩句話,才能讓test用戶便可以在不一樣客戶端和本地進行使用MYSQL


3、刷新權限:FLUSH PRIVILEGES;

 

最後再創建幾個快捷shell文件:

1. 進入 /root/exec_shell 目錄,創建第一個 nginx.sh 文件,內容以下:

vim nginx.sh

#!/bin/sh
action=$1
if [ $action -a $action = "start" ]
then
        echo "starting"
        /usr/local/lnmp/nginx-1.4.2/nginx
        echo "start successful"
elif [ $action -a $action = "stop" ]
then
        echo "stoping"
        /usr/bin/kill -INT `cat /usr/local/lnmp/nginx-1.4.2/nginx.pid`
        echo "stop successful"
elif [ $action -a $action = "restart" ]
then
        echo "restarting"
        #/usr/bin/kill -USR2 `cat /usr/local/lnmp/nginx-1.4.2/nginx.pid`
        /usr/bin/kill -HUP `cat /usr/local/lnmp/nginx-1.4.2/nginx.pid`
        echo "restart successful"
else
        echo "start,stop,restart"       
fi

而後必定要對該文件賦予可執行的權限:

chmod 755 ./nginx.sh

2. 創建 vim uwsgi.sh:

#!/bin/sh
action=$1
if [ $action -a $action = "start" ]
then
        echo "starting"
        /usr/bin/uwsgi --ini /etc/uwsgi9090.ini &
        echo "start successful"
elif [ $action -a $action = "stop" ]
then
        echo "stoping"
        /usr/bin/kill -INT `cat /var/run/uwsgi9090.pid`
        echo "stop successful"
elif [ $action -a $action = "restart" ]
then
        echo "restarting"
        #/usr/bin/kill -USR2 `cat /var/run/uwsgi9090.pid`
        #kill -HUP PID 該命令讓Linux和緩的執行進程關閉,而後當即重啓。
        #在配置應用程序的時候,這個命令很方便,
        #在對配置文件修改後須要重啓進程時就能夠執行此命令
        #/usr/bin/kill -HUP `cat /var/run/uwsgi9090.pid`
        #先關閉,在啓動
        /usr/bin/kill -INT `cat /var/run/uwsgi9090.pid`
        sleep 3
        /usr/bin/uwsgi --ini /etc/uwsgi9090.ini &
        echo "restart successful"
else
        echo "start,stop,restart"       
fi
# ps -ef | grep uwsgi

3. 第三個 nginx_uwsgi.sh:

#!/bin/sh
action=$1
if [ $action -a $action = "start" ]
then
        echo "uwsgi starting"
        /usr/bin/uwsgi --ini /etc/uwsgi9090.ini &
        echo "uwsgi start successful"
        sleep 3
        echo "nginx starting"
        /usr/local/lnmp/nginx-1.4.2/nginx
        echo "nginx start successful"
elif [ $action -a $action = "stop" ]
then
        echo "uwsgi stoping"
        /usr/bin/kill -INT `cat /usr/local/lnmp/nginx-1.4.2/nginx.pid`
        echo "uwsgi stop successful"
        sleep 3
        echo "nginx stoping"
        /usr/bin/kill -INT `cat /var/run/uwsgi9090.pid`
        echo "nginx stop successful"
elif [ $action -a $action = "restart" ]
then
        echo "uwsgi restarting"
        #/usr/bin/kill -HUP `cat /var/run/uwsgi9090.pid`
        /usr/bin/kill -INT `cat /var/run/uwsgi9090.pid`
        sleep 3
        /usr/bin/uwsgi --ini /etc/uwsgi9090.ini &
        echo "uwsgi restart successful"
        sleep 3
        echo "nginx restarting"
        #/usr/bin/kill -USR2 `cat /usr/local/lnmp/nginx-1.4.2/nginx.pid`
        #/usr/bin/kill -USR2 `cat /var/run/uwsgi9090.pid`
        /usr/bin/kill -HUP `cat /usr/local/lnmp/nginx-1.4.2/nginx.pid`
        echo "nginx restart successful"
else
        echo "start,stop,restart"       
fi

而後就能夠執行:

# 開啓nginx,中止nginx,重啓nginx
/root/exec_shell/nginx.sh start
/root/exec_shell/nginx.sh stop
/root/exec_shell/nginx.sh restart


# 開啓uwsgi,中止uwsgi,重啓uwsgi
/root/exec_shell/uwsgi.sh start
/root/exec_shell/uwsgi.sh stop
/root/exec_shell/uwsgi.sh restart


# 同時開啓nginx+uwsgi,中止nginx+uwsgi,重啓nginx+uwsgi
/root/exec_shell/nginx_uwsgi.sh start
/root/exec_shell/nginx_uwsgi.sh stop
/root/exec_shell/nginx_uwsgi.sh restart

 

Django+Nginx+uWSGI部署到服務器Django admin後臺樣式消失

相關文章
相關標籤/搜索