Centois6.5初始系统配置:
1Python2.6升级Python2.7
先安装这些防止从新编译Python
yum-y groupinstall "Development Tools"
yuminstall sqlite-devel ncurses-devel openssl-devel bzip2-develreadline-devel
zlib-devel
yuminstall libcurl-devel libxml2 libxml2-devel libxslt libxslt-devel
libjpeg-turbo-devel.x86_64
yuminstall openssl -y
yuminstall openssl-devel -y
注意:
安装python之前,最好确认一下gcc是否安装。yuminstall -y gcc
否则./configure阶段就会报错了
安装Python
wget--no-check-certificate
https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tarxvfz Python-2.7.5.tgz
cdPython-2.7.5
./configure--prefix=/usr/local –enable-shared /usr/local (指定的安装路径) enable -shared (防止编译mod_wsgi时候make出错误)
make&& make install
看版本号:
运行python,发现版本还是默认的,系统自带的2.6版本
更改系统默认的python:
建立软连接,使系统默认的python指向python2.7
正常情况下即使python2.7安装成功后,系统默认指向的python仍然是2.6版本,而yum是基于python2.6才能正常工作。所以要将系统默认的python指向到2.7版本。
#/usr/local/bin/python2.7 -V
#mv /usr/bin/python /usr/bin/python.bak
#ln -s /usr/local/bin/python2.7 /usr/bin/python
要删除python-config,因为默认指向还是Python2.6
rm-rf /usr/bin/python-config
建立Python2.7的软链接
ln-s /usr/bin/python-config /usr/bin/python-config(对应安装的Python2.7的python-config路径)
运行一下python,或者:
#python –V
修正yum报错:
如果打yum命令,你会发现报错了。提示你可能是python版本不对。所以我们要把yum依旧指向老的python2.6版本:
vi/usr/bin/yum
在打开的文件里的头一行,也就是指定python环境的那行代码,修改成:
#!/usr/bin/python2.6
安装easy_install
wgethttp://peak.telecommunity.com/dist/ez_setup.py
pythonez_setup.py
如果报如下错误:
-
Extractingin /tmp/tmpY9tCJJ
-
Traceback(most recent call last):
-
File"<stdin>", line 332, in <module>
-
File"<stdin>", line 329, in main
-
File"<stdin>", line 51, in _install
-
File"/usr/local/python2.7.7/lib/python2.7/contextlib.py", line17, in __enter__
-
returnself.gen.next()
-
File"<stdin>", line 101, in archive_context
-
File"/usr/local/python2.7.7/lib/python2.7/zipfile.py", line1040, in extractall
-
self.extract(zipinfo,path, pwd)
-
File"/usr/local/python2.7.7/lib/python2.7/zipfile.py", line1028, in extract
-
returnself._extract_member(member, path, pwd)
-
File"/usr/local/python2.7.7/lib/python2.7/zipfile.py", line1082, in _extract_member
-
withself.open(member, pwd=pwd) as source,
-
File"/usr/local/python2.7.7/lib/python2.7/zipfile.py", line1010, in open
-
close_fileobj=should_close)
-
File"/usr/local/python2.7.7/lib/python2.7/zipfile.py", line526, in __init__
-
self._decompressor= zlib.decompressobj(-15)
-
AttributeError:'NoneType' object has no attribute 'decompressobj'
安装下 yuminstall zlib-devel ,然后重新编译安装python2.7.5,然后重新安装easyinstall
应该是python2.6.6安装完成的时候已经有zlib的包了,但是python2.7.5是新安装的,没有引入zlib的包引起的问题。
安装pip
wgethttps://pypi.python.org/packages/source/p/pip/pip-1.4.tar.gz#md5=ca790be30004937987767eac42cfa44a
tar-zxf pip-1.4.tar.gz && cd pip-1.4
python setup.pyinstall
如果python是2.7的可以这样安装yuminstall python-pip
注:若直接输入pip出现pip:con(忘记具体的)
如果pip安装后提示依然没有pip命令,需在在添加环境变量
#vim /etc/profile
在文档最后,添加:
exportPATH="/usr/local/python2.7/bin:$PATH"
保存,退出
然后运行:
#source/etc/profile
二、查看pip版本
pip-V
pip1.5.4 from/usr/local/python2.7/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg(python 2.7)
安装mod_wsgi(mod_wsgi和Python版本要一致,centois6.5python2.7需要mod_wsgi3.2版本)
2安装mod_wsgi
下载地址:http://pan.baidu.com/s/1sjM3uY5
解压
tarzxvf mod_wsgi-3.4.tar.gz -C /usr/local/src/ (最好一个选项都不要改,我改过,结果解压失败了)
cd/usr/local/src/mod_wsgi-3.4
./configure--with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/bin/python (指定Python的路径,因为我没有重装Python,所以用的是默认Python路径)
make
makeinstall
注:可能最后出现chmod755 /usr/lib64/httpd/modules/mod_wsgi.so
需要把mod_wsgi.so权限改为775
安装virtualenv
pipinstall virtualenv
注:(配置项目问题参见CERX项目安装文档)
2、安装启动MySQL
yuminstall mysql-server mysql-devel
chkconfigmysqld on
servicemysqld start
注:初始服务器会出现无法远程连接问题:
1、需要在后台开通所有端口
2、关闭防火墙service iptables stop(或者可以尝试配置防火墙文件开放3306端口)
3.加入ip
mysql -uroot -p
use mysql;
select host,user fromuser;
Grant all privileges on*.* to ‘root’@’%’identified by’password’with grantoption;
select host,user fromuser;再次查看
flushprivileges;(运行这句或者重启MySQL才生效)
最后配置httpd.conf
NameVirtualHost *:80
NameVirtualHost *:443
不配置安全域名可以不用加这两句,如果配置安全域名必须加443这句
如有问题可以联系我QQ:2472999643