LINUX 安装django1.9.7

1)安装pip

wget --no-check-certificate https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/pip-8.1.2.tar.gz#md5=87083c0b9867963b29f7aba3613e8f4a

2)安装django1.9.7

pip install Django==1.9.7

tar包安装

1)官网下载

wget --no-check-certificate https://www.djangoproject.com/m/releases/1.9/Django-1.9.7.tar.gz

2)安装python-setuptools 

#安装好多模块需要这个

wget –q http://peak.telecommunity.com/dist/ez_setup.py

  python ez_setup.py

  显示出Finished processing dependencies for setuptools==0.6c11 说明安装成功

3)安装Django

python setup.py install

4)验证

python 
>>> import django
>>> django.VERSION
(1, 9, 7, 'final', 0)
>>>

安装成功

安装mysql

cd /mnt/wget http://58.68.224.134/hope/mysql-5.5.48.tar.gz
tar -xf
mysql-5.5.48.tar.gz

cd mysql-5.5.48

CMAKE安装

cd /mnt
wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
tar -xf cmake-2.8.5.tar.gz
cd cmake-2.8.5
./configure
make && make install

 安装

cmake -DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_UNIX_ADDR=/app/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_INNODB_MEMCACHED=1 -DWITH_DEBUG=OFF -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DENABLED_PROFILING=ON -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/app/mysql/boost -DMYSQL_MAINTAINER_MODE=OFF -DMYSQL_DATADIR=/app/mysql/data -DMYSQL_TCP_PORT=3306
make && make install

创建mysql运行使用的用户mysql:

/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql

创建binlog和库的存储路径并赋予mysql用户权限

mkdir -p /app/mysql/binlog /app/www/data_mysql
chown mysql.mysql /app/mysql/binlog/ /app/www/data_mysql/

把/etc/my.cnf改为以下内容

[client]
port = 3306
socket = /app/mysql/mysql.sock
[mysqld]
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user = mysql
port = 3306
socket = /app/mysql/mysql.sock
basedir = /app/mysql
datadir = /app/www/data_mysql
log-error = /app/mysql/mysql_error.log
pid-file = /app/mysql/mysql.pid
open_files_limit = 65535
back_log = 600
max_connections = 5000
max_connect_errors = 1000
table_open_cache = 1024
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 600
#thread_concurrency = 8
query_cache_size = 128M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
default-tmp-storage-engine=MYISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 128M
max_heap_table_size = 128M
log-slave-updates
log-bin = /app/mysql/binlog/binlog
binlog-do-db=oa_fb
binlog-ignore-db=mysql
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /app/mysql/relaylog/relaylog
relay-log-info-file = /app/mysql/relaylog/relaylog
relay-log = /app/mysql/relaylog/relaylog
expire_logs_days = 10
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
interactive_timeout = 120
wait_timeout = 120
skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
#master-host = 192.168.1.2
#master-user = username
#master-password = password
#master-port = 3306
server-id = 1
loose-innodb-trx=0 
loose-innodb-locks=0 
loose-innodb-lock-waits=0 
loose-innodb-cmp=0 
loose-innodb-cmp-per-index=0
loose-innodb-cmp-per-index-reset=0
loose-innodb-cmp-reset=0 
loose-innodb-cmpmem=0 
loose-innodb-cmpmem-reset=0 
loose-innodb-buffer-page=0 
loose-innodb-buffer-page-lru=0 
loose-innodb-buffer-pool-stats=0 
loose-innodb-metrics=0 
loose-innodb-ft-default-stopword=0 
loose-innodb-ft-inserted=0 
loose-innodb-ft-deleted=0 
loose-innodb-ft-being-deleted=0 
loose-innodb-ft-config=0 
loose-innodb-ft-index-cache=0 
loose-innodb-ft-index-table=0 
loose-innodb-sys-tables=0 
loose-innodb-sys-tablestats=0 
loose-innodb-sys-indexes=0 
loose-innodb-sys-columns=0 
loose-innodb-sys-fields=0 
loose-innodb-sys-foreign=0 
loose-innodb-sys-foreign-cols=0

slow_query_log_file=/app/mysql/mysql_slow.log
long_query_time = 1
[mysqldump]
quick
max_allowed_packet = 32M
my.cnf

 复制完成之后请把default-tmp-storage-engine=MyISAM 注释掉

把mysql文件夹更改权限

chown mysql.mysql /app/mysql

创建开机启动脚本

cd /app/mysql/
cp support-files/mysql.server /etc/rc.d/init.d/mysqld 
chkconfig --add mysqld 
chkconfig --level 35 mysqld on

启动mysql

service mysqld start

修改root初始密码

进入mysql
SET PASSWORD FOR '用户名'@'主机' = PASSWORD(‘密码');

或者

mysqladmin -u用户名 -p旧密码 password 新密码

创建新用户并授权

grant all privileges on *.* to 用户名@'%' identified by '密码' with grant option;

其他命令

  • 启动:service mysqld start
  • 停止:service mysqld stop
  • 重启:service mysqld restart
  • 重载配置:service mysqld reload

安装mysqldb模块

wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
tar zxvf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
python setup.py build
python setup.py install

如果在执行:python setup.py build 遇到以下错误:

修改setup_posix.py文件,在26行:
mysql_config.path = “mysql_config” 修改为:
mysql_config.path = “/app/mysql/bin/mysql_config”

保存后再次执行

python setup.py build
python setup.py install

进入python环境导入模块

python
import MySQLdb

如果遇到以下错误:

/app/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /app/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_mysql.pyc, but /app/lib/python2.7/site-packages/MySQL-python-1.2.3 is being added to sys.path
Traceback (most recent call last):
  File "", line 1, in 
  File "MySQLdb/__init__.py", line 19, in 
    import _mysql
  File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in 
  File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory

去看看mysql下的libmysqlclient.so.18在不在

如果在,创建一个链接

ln -s /app/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18

再次进入python环境导入模块

Python 2.7.9 (default, Jul 19 2042, 11:47:02)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>

ok.成功

 

转载于:https://www.cnblogs.com/pangzhonghua/p/5684345.html

你可能感兴趣的:(LINUX 安装django1.9.7)