待解决在问题:
sudo apt-get install yum
sudo yum install openssl-devel
sudo yum updae openssl
openssldir=/etc/ssl
--with-ssl=DIR not --with-openssl=DIR
BTCTrade project
1、apache环境搭建:
编译错误解决方法:
编译:
/configure --prefix=/opt/apache --enable-track-vars --enable-cgi --with-config-file-path=/opt/apache/conf --enable-modules=all --enable-mods-shared=all --enable-file-cache --enable-disk-cache --enable-cache --enable-mem-cache --enable-dumpio --enable-logio --enable-mime-magic --enable-headers --enable-usertrack --enable-version --enable-ssl --enable-http --enable-rewrite --enable-proxy --enable-proxy-connect --enable-proxy-http --enable-proxy-ftp --enable-proxy-ajp --enable-proxy-balancer --enable-so
安装所有扩展模块意味着将 apache 功能扩展到极限,但如果你不会配置这些模块,或者置之不理,他们很可能会给你带来不必要的麻烦或者安全隐患。下面是编译的报错:
checking for APR... no
configure: error: APR not found . Please read the documentation.
可以用./configure –help | grep apr 查看帮助。
--with-included-apr Use bundled copies of APR/APR-Util
--with-apr=PATH prefix for installed APR or the full path to apr-config
--with-apr-util=PATH prefix for installed APU or the full path to
安装APR(Apache Portable Runtime )
下载:http://apr.apache.org/download.cgi
$./configure --prefix=/usr/local/apr
$make
$make install
checking for APR-util... no
configure: error: APR-util not found . Please read the documentation.
$./configure –help | grep apr-util
--with-apr-util=PATH prefix for installed APU or the full path to
下载:http://download.chinaunix.net/download/0001000/472.shtml
$./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
$make
$make install
./configure仍提示APR-util not found,增加--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util后出现
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
$./configure –help | grep pcre
--with-pcre=PATH Use external PCRE library
下载:http://sourceforge.net/projects/pcre
$./configure --prefix=/usr/local/pcre
$make
$make install
继续安装Apache/httpd,./configure 时加上参数 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre,这个问题就解决了
但是又出现
checking for OpenSSL version >= 0.9.7... FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
$wget http://openssl.org/source/openssl-1.0.1.tar.gz
$tar xfz openssl-1.0.1.tar.gz
$cd openssl-*
$./config --prefix=/usr/local/openssl zlib-dynamic --openssldir=/etc/ssl shared
错误有来了:
c_zlib.c:25:18: fatal error: zlib.h: No such file or directory
sudo apt-get install zlib1g-dev
make
sudo make install
继续安装Apache/httpd,./configure 时加上参数 --with-ssl=/usr/local/openssl
注意:Apache在安装时不会检查参数是否正确,错误的参数会直接被丢弃,不会报告给用户。但可以使用echo $?命令检查是否有错误,当输出结果为0时表示没有错误。
#echo $?
0
#make
#make install
至此apache安装完成。
复制Apache启动文件
#cp /usr/local/httpd/bin/apachectl /sbin/
启动Apache
#apachectl start
问题有tm的来了:
Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
解决方法:
$ sudo vi /opt/apache/conf/httpd.conf
add
ServerName localhost
再看 /opt/apache/logs/error_log,会报告[pid 3228:tid 3075336448] AH02282: No slotmem from mod_heartmonitor
AH00020: Configuration Failed, exiting这种错误
解决方法:
/opt/apache/conf/httpd.conf
把这句话去注释:
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
启动apache服务器
打开浏览器输入http://127.0.0.1:80 ok!it works!
2.2 安装Python2.7:
一般linux系统会自带Python,一般是2.4版本的,我们需要重新安装,这里注意,不要使用yum安装,而要用源码编译的方法安装,不然下面在配置之后会出错。
Ubuntu中默认就自带了python的2.5版本,结果我还是装了一个python的2.6版本,在网上查了下才知道python的2.5版本是目前使用者最多的版本,一些python的库都是用的这个版本,无奈只好再换回python的2.5版本了,其实在linux系统中多个python版本是可以共存的,只不过在终端中运行的时候,输入 python2.5 或者 python2.6就能进入不同的版本了,而且在你的*.py文件中可以用 #!/usr/bin/python 来指定程序的解释器版本,不过这样使用起来有些不方便,所以就把/usr/bin/python这个快捷方式的指向修改下好了。
: ~$ sudo rm /usr/bin/python
:~$ sudo ln -s /usr/include/python2.5 /usr/bin/python
这样在终端中输入python默认就是 2.5版本了。
tar -xvf Python-2.7.tar.bz2 make make install |
File "/usr/local/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
或者
python: error while loading shared libraries: libpython2.7.so.1.0:
cannot open shared object file: No such file or
解决方案:
新建下面文件
vim /etc/ld.so.conf.d/python2.7.conf
加入内容:
/usr/local/lib
保存退出后运行:
ldconfig
再次执行 python,问题成功解决。
django# python
>>>import django
>>>django.VERSION
查看是否安装,如果没有安装
tar xzvf Django-1.5.1.tar.gz
cd Django-1.5.1
sudo python setup.py install
首先说一下mod_wsgi,mod_wsgi是mod_python的后继者
大体流程就是在Apache上添加该mod_wsgi模块,然后通过Apache的配置文件和Python的wsgi脚本来完成Python代码的部署和运行。mod_wsgi不仅仅支持Django框架,还支持其他很多的Python的Web框架。
./configure --with-apxs=/opt/apache/bin/apxs
提示找不到Python.h文件:
sudo apt-get install python-dev
:/usr/include/python2.7/Python.h
make
sudo make install
安装完成后,会在/opt/apache/modules添加mod_wsgi.so库文件
更新源:
$ sudo apt-get update
寻找符合条件的软件名称
$apt-cache search mysql
$ sudo apt-get mysql-server mysql-client
安装的过程中会提示设置mysql的root密码
$ sudo mysqld
$mysql -u root -p 以root用户登录,要求验证密码 ,启动mysql客户端
mysql -u root -p
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
mysql>create database 数据库名;
mysql>grant create,select,insert,update,delete,index on 数据库名.* to 用户名@localhost identified by “密码”;
mysql> show databases; //当前数据库
mysql> CREATE DATABASE btcTrade;//创建一个btcTrade数据库
默认的数据库数据文件保存在/var/lib/mysql文件夹中的。(root)
默认的数据库的配置文件在/etc/mysql/my.cnf中。其中包括数据文件的的保存路径datadir= /var/lib/mysql
默认的数据库的日志文件/var/log/mysql/error.log
SSL
sudo cp /etc/ssl/misc/CA.sh //opt/apache/conf
zlm@ubuntu:/opt/apache/conf$ sudo ./ssl.crt -newca
CA certificate filename (or enter to create)//直接回车创建
Making CA certificate ...
Generating a 1024 bit RSA private key
.............................++++++
.........................++++++
writing new private key to './demoCA/private/./cakey.pem'
Enter PEM pass phrase:
AH00526: Syntax error on line 51 of /opt/apache/conf/extra/httpd-ssl.conf:
Invalid command 'SSLCipherSuite', perhaps misspelled or defined by a module not included in the server configuration
# vi /opt/apache/conf/httpd.conf LoadModule ssl_module modules/mod_ssl.so
为了使用mysql中的数据库,首先要下载mysql-python的模块
# apt-get install python-mysqldb
>>> import btcTrade.btcdb
>>> import btcTrade.btcdb.models
>>> from btcTrade.btcdb.models import user_info