python阿里云配置

2015-07-12  本文已影响3341人  信息技术教育应用

操作系统是CENTOS 6.5

yum中最新的也是Python 2.6.6,只能下载Python 2.7.9的源代码自己编译安装。

操作步骤如下:

1)安装devtoolset

yum groupinstall "Development tools"

2)安装编译Python需要的包包

yum install zlib-devel
yum install bzip2-devel
yum install openssl-devel
yum install ncurses-devel
yum install sqlite-devel

安装Python2.7

用root登陆之后使用命令

wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz

使用解压命令tar解压刚刚下载的文件

tar xf Python-2.7.10.tgz

进入解压之后的文件

cd Python-2.7.10.tgz

运行检查目录结构

./configure --prefix=/usr/local
编译
make && make install
安装成功之后,你可以在 /usr/local/bin/python2.7
找到 Python 2.7

将python命令指向Python 2.7.9

ln -s /usr/local/bin/python2.7 /usr/local/bin/python

检查Python版本

sh
sh-4.1# python -V
Python 2.7.9

安装PIP

To install pip, securely download

wget https://bootstrap.pypa.io/get-pip.py
Then run the following (which may require administrator access):
python get-pip.py

使用VIM编辑

vim开始使用
:wq保存退出

yum命令不兼容python2.7,需修改/usr/bin/yum文件,将第一行由“#!/usr/bin/python”改为“#!/usr/bin/python2.6"

安装Mysql

1.使用yum命令安装mysql

yum -y install mysql-server

2.设置开机启动

chkconfig mysqld on

3.启动MySQL服务

service mysqld start

4.设置MySQL的root用户设置密码

mysql -u root
mysql> select user,host,password from mysql.user;
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | |
| root | bogon | |
| root | 127.0.0.1 | |
| | localhost | |
| | bogon | |
+------+-----------+----------+
5 rows in set (0.01 sec)

查询用户的密码,都为空,用下面的命令设置root的密码为root

mysql> set password for root@localhost=password('root');
mysql> exit

5.用新密码登陆

mysql -u root -p
Enter password:

6.创建mysql新用户test_user

mysql> create user 'test_user'@'%' identified by 'test_user';
Query OK, 0 rows affected (0.00 sec)

7.给新用户test_user授权,让他可以从外部登陆和本地登陆注意:@左边是用户名,右边是域名、IP和%,表示可以访问mysql的域名和IP,%表示外部任何地址都能访问。

mysql> grant all privileges on . to 'test_user'@'localhost' identified by 'test_user';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on . to 'test_user'@'%' identified by 'test_user';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+----------+-----------+-------------------------------------------+
| user | host | password |
+----------+-----------+-------------------------------------------+

| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | bogon | |
| root | 127.0.0.1 | |
| | localhost | |
| | bogon | |
| test_user | % | *3046CF87132BBD4FDDF06F321C6859074843B7D3 |
| test_user | localhost | *3046CF87132BBD4FDDF06F321C6859074843B7D3 |
+----------+-----------+-------------------------------------------+
7 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

8.查看mysql5.1的默认存储引擎从下面的执行结果可以看出,mysql的默认引擎是MyISAM,这个引擎是不支持事务的。

mysql> show engines;
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
5 rows in set (0.00 sec)

也可以以下面的方式查看

mysql> show variables like 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | MyISAM |
+----------------+--------+
1 row in set (0.00 sec)

9.修改mysql的默认引擎为InnoDB
9.1 停止mysql

mysql> exit;
service mysqld stop

9.2 修改/etc/my.cnf
[mysqld] 后加入

default-storage-engine=InnoDB

加入后my.cnf的内容为:

more my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
default-storage-engine=InnoDB
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

9.3 启动mysql

service mysqld start
Starting mysqld: [ OK ]

9.4 查看mysql默认存储引擎

mysql> show variables like 'storage_engine';

10.CentOS6.5开放mysql端口3306CentOS6.5默认是不开放端口的,如果要让外部的系统访问CentOS6.5上的mysql,必须开放mysql的端口330610.1 修改/etc/sysconfig/iptables添加下面一行

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

修改后iptables中的内容是

more /etc/sysconfig/iptables

11.重启防火墙

service iptables restart

这样就可以从外部访问mysql了。
至此,mysql在CentOS6.5上的安装过程、用户创建、外部访问的步骤全部完成。

安装nginx

1、安装prce(重定向支持)和openssl(https支持,如果不需要https可以不安装。)

yum -y install pcre*
yum -y install openssl*

CentOS 6.5 我安装的时候是选择的“基本服务器”,默认这两个包都没安装全,所以这两个都运行安装即可。

2、下载nginx 1.8.0

wget http://nginx.org/download/nginx-1.8.0.tar.gz

3、解压编译安装

tar -zxvf nginx-1.8.0.tar.gz

然后进入目录编译安装

cd nginx-1.8.0
./configure --prefix=/usr/local/nginx-1.8.0 --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-pcre

如果没有error信息,就可以执行下边的安装了:

make
make install

4、开启nginx进程

/usr/local/nginx-1.8.0/sbin/nginx

重启或关闭进程:

/usr/local/nginx-1.8.0/sbin/nginx -s reload
/usr/local/nginx-1.8.0/sbin/nginx -s stop

5、关闭防火墙,或者添加防火墙规则就可以测试了。

service iptables stop

或者编辑配置文件:

vi /etc/sysconfig/iptables

添加这样一条开放80端口的规则后保存:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

重启服务即可:

service iptables restart

ok,,可以浏览器访问了。Welcome to nginx!

6、配置nginx.conf
vim /usr/local/nginx-1.8.0/conf/nginx.conf
运行用户去掉注释
user www-data;

安装MYSQL-python

首先安装 setuptools,下载源代码包:

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar -xzvf setuptools-0.6c11.tar.gz
python setup.py build
python setup.py install

然后安装一些扩展库

yum -y install rpm-build gcc-c++ mysql-devel python-devel

最后安装MySQL-python 下载源代码包:

wget http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
tar -zxvf MySQL-python-1.2.3.tar.gz

编辑 site.cfg
把 mysql_config 那一行取消注释,并改为:

mysql_config = /usr/lib64/mysql/mysql_config (根据自己mysql安装位置定义)
python setup.py build
python setup.py install

Nginx配置问题

上一篇下一篇

猜你喜欢

热点阅读