【深入學習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。

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

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

 

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

 

 

python 指向的是python2.7

 

2.開始編譯安裝python3

先安裝相關包

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

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

 

 

3.7版本需要一個新的包libffi-devel,安裝此包之后再次進行編譯安裝即可。

yum install libffi-devel -y

 

因為我們要安裝python3版本,所以python要指向python3才行,目前還沒有安裝python3,先備份

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 https://www.cnblogs.com/lulin9501/p/11069093.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

 

還可以參考:https://www.cnblogs.com/nyfz/p/8557137.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

6、配置MySQL

1、授予my.cnf最大權限

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

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

2、復制啟動腳本到資源目錄

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

3、增加mysqld服務控制腳本執行權限 

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

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

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

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

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

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

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

表明mysqld服務已經生效,在2、3、4、5運行級別隨系統啟動而自動啟動,以后可以使用service命令控制mysql的啟動和停止

命令為:service mysqld start和service mysqld stop

6、啟動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的權限太高了。任意用戶都寫操作。

7、將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

8、以root賬戶登錄mysql,默認是沒有密碼的

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

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

9、設置root賬戶密碼為root(也可以修改成你要的密碼)

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

如果忘記密碼:請在配置文件加上

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

密碼修改后,將這行配置注釋掉重啟就可以了。

10、設置遠程主機登錄,注意下面的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關於細節請查看:https://www.cnblogs.com/lizm166/p/7838862.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后台樣式消失


免責聲明!

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



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