本次主机:OVH 128MB OpenVZ VPS Debian6 64bit
目标:运行TransitLG,TransitLG是一个基于MTR的ping/ping6 tracert/tracert6网络诊断工具,需要python环境运行,运行TransitLG需要具备:
Nginx、rpl、Python、GNU Screen、Unzip、MTR、Ping/Ping6、Traceroute/Traceroute6
本次是进行改进和优化的尝试,TransitLG项目:http://sourceforge.net/projects/transitlg
【安装完成后的改变:】本来是要用lighttpd,但是很难运作,最终放弃,改用apache,安装过程只作为记录供以后参考.
OVH主机需要修改源:
原内容:
复制代码
在此之前加入:
之后务必执行reboot重启一次系统,不然不会生效
可以执行更新命令,使用参数,修补一下缺失的包:
也可以在后面安装完成gcc的时候执行
安装make、chkconfig、bzip2、gcc、g++、pcre、unzip:
其中有些可能已经存在,就不用再安装了
安装make:
安装chkconfig:
安装bzip2:
编译方式安装可以访问:http://www.bzip.org/
安装build-essential:
安装gcc:
编译方式安装gcc需要GMP、MPFR、MPC这三个库,下载地址:ftp://gcc.gnu.org/pub/gcc/infrastructure/
gcc网站:http://gcc.gnu.org/ http://ftp.gnu.org/gnu/gcc/ http://gcc.gnu.org/install/
安装g++:
安装pcre(Perl Compatible Regular Expressions):
安装pcre-devel:
【推荐,后面安装nginx还要用到它的源码包】也可以下载源码编译安装pcre:
http://www.pcre.org/
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
安装unzip:
执行:
看到版本号,说明已存在,不需要再安装;如果提示找不到命令,执行命令安装unzip:
安装gzip:
执行:
若提示找不到命令,说明不存在,执行apt-get install gzip命令进行安装
安装curl:
安装GNU Screen、rpl、MTR、Ping/Ping6、Traceroute/Traceroute6:
安装screen:
先执行:
如果看到:
复制代码
说明screen已经存在,不需要再安装,如果提示命令不存在,执行命令安装screen:
如果用编译方式安装screen,可以访问网站下载源码:
http://www.gnu.org/software/screen/
http://aperiodic.net/screen
安装rpl:
先执行:
若看到:
复制代码
说明rpl不存在,可以执行命令安装rpl:
看到显示:
复制代码
rpl成功安装.
安装mtr(my trace route):
先执行:
看到:
复制代码
说明mtr已经存在,如果提示找不到命令,说明不存在,需要执行命令安装mtr:
也可以下载源码编译安装mtr:
http://www.bitwizard.nl/mtr/
ftp://ftp.bitwizard.nl/mtr/
查看网络配置,执行:
若看到:
复制代码
主要是看到inet6 addr后面有IPv6地址,说明已经接入IPv6
进行IPv6网络测试,执行:
正常会显示:
复制代码
再次进行IPv6网络测试,执行:
正常会显示:
复制代码
如果需要修改IPv6配置,可以执行nano /etc/network/interfaces
执行ping6或者traceroute6如果看到:
复制代码
需要执行命令安装miredo:
要配置miredo,可以执行nano /etc/miredo/miredo.conf
miredo网站:http://www.remlab.net/miredo/
安装Nginx之前,先安装zlib:【如果已经有了,不用安装,只下载源码包,后面安装nginx要用到】
http://www.zlib.net/
http://sourceforge.net/projects/libpng/files/zlib/
安装zlibc、zlib1g-dev:
这一步是为了安装python的zlibc的支持,不然后面安装setuptools的时候,会提示出错信息:
复制代码
安装libxml2:
http://www.xmlsoft.org/
ftp://xmlsoft.org/libxml2/
http://www.xmlsoft.org/downloads.html
ftp://gd.tuwien.ac.at/pub/libxml/
/usr/local/share/doc/libxml2-2.9.0
安装libxslt:
http://xmlsoft.org/XSLT/downloads.html
http://xmlsoft.org/XSLT/
ftp://gd.tuwien.ac.at/pub/libxml/
安装python:
先执行:
一般系统中都已经存在python,执行这个命令可以查看python组件的版本号,并进入python,执行Ctrl + D组合键退出Python;执行whereis python查看python目录,输出:
复制代码
如果系统中不存在python,或者已经存在,都可以下载python最新版源码编译安装:
http://www.python.org/getit/
安装完成,输出信息:
复制代码
查看库信息,执行:
输出:
复制代码
对于系统中本来已经存在的python,新安装python后,需要修改一下系统中python命令的链接:
测试一下程序运行情况,执行:
如果出现:
复制代码
【方案一,不使用此方案,这里也可以用方案二通过,不过后面安装Twisted的时候会出错】出错信息的解决办法:
输出:
复制代码
【这个可以忽略】执行:
再执行:
【方案二,可以叠加方案一】出现这个错误信息,执行:
添加一行:
保存后,再执行:
可以查看库信息
这时候,再执行:
正常进入,输出:
复制代码
使用Ctrl + D组合键退出python
Python安装完毕后,还需要安装用来设置python的工具:setuptools,包含easy_install可以用来安装Python第三方扩展包
http://pypi.python.org/pypi/setuptools/
http://pypi.python.org/packages/2.7/s/setuptools/
http://peak.telecommunity.com/DevCenter/EasyInstall#command-line-options
http://peak.telecommunity.com/DevCenter/EasyInstall
http://www.ibm.com/developerworks/cn/linux/l-cppeak3.html
忽略:
执行:
输出:
复制代码
【这个可以忽略】执行:
输出:
复制代码
至此,setuptools安装成功,如果安装出错不成功,也可以跳过这个setuptools和easy_install的安装;安装成功后,运行python,输入import setuptools和import easy_install分别验证一下有没有错误
安装web.py:
http://webpy.org/
http://webpy.org/install.zh-cn
http://webpy.org/docs/0.3/tutorial.zh-cn
https://github.com/webpy/webpy
http://webpy.org/cookbook/mod_wsgi-nginx
最后输出:
复制代码
安装成功;可以输入python命令,之后再输入import web命令,看看有没有错误。
web.py 内置了web服务器,可以写一个简单的code.py应用,然后使用python code.py命令启动web.py内置的服务器,打开你的浏览器输入 http://localhost:8080/ 查看页面。 若要制定另外的端口,使用 python code.py 1234。
安装Spawn-fcgi:
http://www.lighttpd.net/
http://www.lighttpd.net/download
http://redmine.lighttpd.net/projects/spawn-fcgi/wiki
http://download.lighttpd.net/spawn-fcgi/
安装Django:
https://www.djangoproject.com/
https://www.djangoproject.com/download/
最后两行输出:
复制代码
成功安装,可以运行python命令,再输入import django验证一下有没有错误
安装uWSGI:
http://projects.unbit.it/uwsgi/
http://projects.unbit.it/downloads/
http://wiki.nginx.org/HttpUwsgiModule
http://projects.unbit.it/uwsgi/wiki
http://projects.unbit.it/uwsgi/wiki/Quickstart
最后两行输出:
复制代码
【以下步骤省略】
mkdir /usr/local/uwsgi
cd ..
cp -r uwsgi-1.2.6 /usr/local/uwsgi/bin
【以下步骤省略】
mkdir -p /usr/local/uwsgi/conf
mkdir -p /usr/local/uwsgi/logs
【以下步骤省略】
cp welcome.ini /usr/local/uwsgi/bin/welcome.ini
cp uwsgi.xml /usr/local/uwsgi/bin/uwsgi.xml
【以下步骤省略】
nano /usr/local/uwsgi/bin/uwsgi.xml
【以下步骤省略】
# <uwsgi>和</uwsgi>之间写入内容:
<listen>200</listen>
<master>true</master>
<pidfile>/usr/local/uwsgi/logs/uwsgi.pid</pidfile>
<processes>8</processes>
<pythonpath>/usr/local/python_web/www</pythonpath>
<pythonpath>/usr/local/python_web/</pythonpath>
<module>django_wsgi</module>
<profiler>true</profiler>
<memory-report>true</memory-report>
<enable-threads>true</enable-threads>
<logdate>true</logdate>
<limit-as>6048</limit-as>
<daemonize>/usr/local/uwsgi/logs/django.log</daemonize>
安装flup<前面没有安装成功setuptools的在这里跳过>:flup是用python实现的WSGI(网页网关接口)
http://www.saddi.com/software/flup/dist/
http://flup.org/
http://trac.saddi.com/flup
最后三行输出:
复制代码
成功后,可以运行python命令,再输入import flup验证一下有没有错误
【可有可无】安装libevent
http://libevent.org/
【可有可无】安装gevent:
http://www.gevent.org/
http://pypi.python.org/pypi/gevent#downloads
【可有可无】安装memcached:
http://memcached.org/
https://code.google.com/p/memcached/
【可有可无,推荐安装】安装sqlalchemy:
http://www.sqlalchemy.org/
http://sourceforge.net/projects/sqlalchemy/
http://www.sqlalchemy.org/download.html
build命令之后出现:
复制代码
有点小小的错误,不过不影响安装,因为毕竟显示了“Plain-Python build succeeded”,如果没有出现这个,就需要找到那个_speedups.c文件的610行,进行注释或者修改,这里略过不讨论
install命令执行后,安装结束,还是会出现警告提示,但是安装成功:
安装mysql.
【略过,需要先安装MySQL】安装MySQLdb:
http://mysql-python.sourceforge.net/MySQLdb.html
http://mysql-python.sourceforge.net/
http://sourceforge.net/projects/mysql-python/
http://sourceforge.net/projects/mysql-python/files/
http://pypi.python.org/pypi/MySQL-python
【可有可无,推荐安装】安装Twisted:
http://twistedmatrix.com/trac/
前面安装python之后执行python命令后,出现错误的方案一如果没有进行的话,这里build执行后会出错:
复制代码
解决办法:执行前面python安装后的方案一
Twisted安装成功后的最后一段输出信息:
复制代码
要验证是否正确,可以执行python命令,然后执行import twisted命令即可
【可有可无,推荐安装】安装python-memcached:
http://www.tummy.com/Community/software/python-memcached/
http://pypi.python.org/pypi/python-memcached/
安装成功最后几行输出:
复制代码
【可有可无,推荐安装】安装Python Imaging Library(PIL):
http://www.pythonware.com/products/pil/
最后几行输出:
复制代码
要验证,可以执行python命令进入后,执行import PIL命令
【可有可无,推荐安装】安装simplejson:
http://pypi.python.org/pypi/simplejson/
http://code.google.com/p/simplejson/
https://github.com/simplejson/simplejson/
http://simplejson.readthedocs.org/en/latest/index.html
http://json.org/json-zh.html
http://undefined.org/python/
最后两行输出:
复制代码
可以执行python命令后,执行import simplejson进行验证
【可有可无】安装cherrypy:
http://www.cherrypy.org/
http://download.cherrypy.org/cherrypy/3.2.2/
安装输出最后一段:
复制代码
【可有可无,未安装】安装tornado:
http://www.tornadoweb.org/
https://github.com/facebook/tornado
http://pypi.python.org/pypi/tornado
http://www.tornadoweb.org/documentation/index.html
http://www.tornadoweb.cn/
安装输出最后一段:
复制代码
运行python后可以执行import tornado命令验证
安装PostgresSQL.
【略过,要先安装PostgreSQL才能安装这个】安装psycopg2:Python连PostgreSQL要psycopg2模块
http://initd.org/psycopg/
http://initd.org/psycopg/tarballs/
成功后,可以运行python命令,再输入import psycopg2验证一下有没有错误
【可有可无】安装eurasia:
http://code.google.com/p/eurasia/
http://code.google.com/p/eurasia/wiki/eurasia_3_1_userguide
安装pyopenssl:
http://pyopenssl.sourceforge.net/
http://packages.python.org/pyOpenSSL/
http://pypi.python.org/pypi/pyOpenSSL
安装scrapy:
http://scrapy.org/
https://github.com/scrapy/scrapy
http://scrapy.org/download/
http://pypi.python.org/pypi/Scrapy
cd /tmp
wget https://nodeload.github.com/scrapy/scrapy/tarball/0.14
安装pymongo:
http://api.mongodb.org/python/current/
http://pypi.python.org/pypi/pymongo/
Python和相关部件已经安装完毕,接下来,安装前端服务器之一:Lighttpd,解析py脚本,进行80端口对外服务
有说Lighttpd运行需要libpcre和libz,前面安装的pcre即是libpcre:http://www.pcre.org/
安装libz:http://www.zlib.net/
libz即是zlib,前面也已经安装过了
安装Nginx之前,安装openssl,如果要让lighttpd也支持ssl功能,也要先安装openssl,安装openssl之前,先执行openssl命令,如果已经存在,会自动进入,执行exit命令退出
系统已经存在openssl的话,需要执行whereis openssl命令,查看openssl所在的目录,执行后可以看到:
复制代码
系统中没有openssl存在的情况下,需要新安装【如果已经有了,仍然要下载源码包,后面安装nginx要用到】
http://www.openssl.org/
http://www.openssl.org/docs/
http://www.openssl.org/source/
ftp://ftp.openssl.org/source/
配置文件位于:/usr/local/openssl/openssl.cnf
安装autoconf:
安装lighttpd:
http://www.lighttpd.net/
http://www.lighttpd.net/download
http://download.lighttpd.net/lighttpd/
http://webpy.org/cookbook/fastcgi-lighttpd.zh-cn
http://redmine.lighttpd.net/projects/lighttpd/wiki
http://redmine.lighttpd.net/projects/lighttpd/wiki/InstallFromSource
程序位置:
lighttpd的配置文件目录需要手动创建:
主配置文件放置位置:
复制配置文件:
创建用户组和用户:
配置文件备份:
配置过程很麻烦,放到最后进行,继续向下,安装nginx
nginx运行需要:gzip module requires zlib library、rewrite module requires pcre library、ssl support requires openssl library
所需要的准备工作前面都已经完成
安装cmake2.8.4或更高:
http://www.cmake.org
http://cmake.org/cmake/resources/software.html
安装目录:/usr/local/share/cmake-2.8
【这一段为hiawatha而写,放弃】
安装前端服务器之一:hiawatha,进行80端口对外服务,之前的lighttpd方案放弃
http://www.hiawatha-webserver.org/
http://www.hiawatha-webserver.org/files/
http://www.hiawatha-webserver.org/download
http://files.tuxhelp.org/hiawatha/
安装前端服务器之二:Nginx,进行8080端口对外服务
安装nginx:
http://nginx.org/en/
http://nginx.org/cn/
http://nginx.org/en/download.html
http://nginx.org/cn/docs/
为nginx运行创建用户组和用户:
配置文件位于/usr/local/nginx/conf目录中
执行命令备份一下nginx.conf文件:
编辑nginx配置文件:
找到:
复制代码
修改为:
保存配置
测试nginx配置文件:
如果输出:
复制代码
说明配置正确;配置文件示例:http://wiki.nginx.org/NginxFullExample
【这一段为lighttpd而写,放弃】
创建web服务器网页文件目录:
修改lighttpd模块配置文件:
找到:
修改为:
编辑lighttpd主配置文件:
找到:
修改为:
手动建立log文件:
在站点根目录创建一个python测试示例test11:
cd /srv/www/htdocs
/usr/local/python2.7/bin/django-admin.py startproject test11
建立localhost的fcgi文件:
nano localhost.fcgi
#!/usr/local/python2.7
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/usr/local/python2.7")
# Switch to the directory of your project. (Optional.)
# os.chdir("/usr/htdocs/test1")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "localhost.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
chmod +x test11/manage.py
test11/manage.py runfcgi method=prefork socket=/tmp/test11.sock pidfile=django.pid
修改lighttpd配置文件:
nano /etc/lighttpd/lighttpd.conf
找到
server.document-root = server_root + "/htdocs"
后面加入:
fastcgi.server = (
"/localhost.fcgi" => (
"main" => (
"socket" => "/tmp/test11.sock",
"check-local" => "disable"
)
)
)
url.rewrite = (
"^(/site_media/.*)$" => "$1",
"^(/.*)$" => "/localhost.fcgi$1"
)
【创建虚拟主机】
创建普通用户名,以普通用户身份创建web虚拟主机目录:
普通用户身份创建虚拟主机配置文件:
启动lighttpd:
输出:
执行命令复制一个mtr6文件:
【此处mtr目录依据实际情况进行配置,如果是自己编译安装的,就把目录修改成自己安装的目录,系统自带的可以通过whereis mtr命令查询】
下载transitlg:
复制transitlg目录到站点目录:
暂停,这里的站点目录是lighttpd的目录.
目标:运行TransitLG,TransitLG是一个基于MTR的ping/ping6 tracert/tracert6网络诊断工具,需要python环境运行,运行TransitLG需要具备:
Nginx、rpl、Python、GNU Screen、Unzip、MTR、Ping/Ping6、Traceroute/Traceroute6
本次是进行改进和优化的尝试,TransitLG项目:http://sourceforge.net/projects/transitlg
【安装完成后的改变:】本来是要用lighttpd,但是很难运作,最终放弃,改用apache,安装过程只作为记录供以后参考.
OVH主机需要修改源:
nano /etc/apt/sources.list
原内容:
- deb http://mirror.ovh.net/debian/ squeeze main
- deb-src http://mirror.ovh.net/debian/ squeeze main
- deb http://security.debian.org/ squeeze/updates main
- deb-src http://security.debian.org/ squeeze/updates main
deb http://ftp.de.debian.org/debian squeeze main
deb-src http://ftp.debian.org/debian/ squeeze main
deb http://ftp.debian.org/debian/ lenny main
deb-src http://ftp.debian.org/debian/ lenny main
之后务必执行reboot重启一次系统,不然不会生效
可以执行更新命令,使用参数,修补一下缺失的包:
apt-get update --fix-missing
也可以在后面安装完成gcc的时候执行
安装make、chkconfig、bzip2、gcc、g++、pcre、unzip:
其中有些可能已经存在,就不用再安装了
安装make:
apt-get install make
安装chkconfig:
apt-get install chkconfig
安装bzip2:
编译方式安装可以访问:http://www.bzip.org/
apt-get install bzip2
安装build-essential:
apt-get install build-essential
安装gcc:
编译方式安装gcc需要GMP、MPFR、MPC这三个库,下载地址:ftp://gcc.gnu.org/pub/gcc/infrastructure/
gcc网站:http://gcc.gnu.org/ http://ftp.gnu.org/gnu/gcc/ http://gcc.gnu.org/install/
apt-get install gcc
安装g++:
apt-get install g++
安装pcre(Perl Compatible Regular Expressions):
apt-get install pcre
安装pcre-devel:
apt-get install libpcre3 libpcre3-dev
【推荐,后面安装nginx还要用到它的源码包】也可以下载源码编译安装pcre:
http://www.pcre.org/
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
cd /tmp
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
tar zxvf pcre-8.31.tar.gz
# 已经有pcre的不继续安装
cd pcre-8.31
./configure --prefix=/usr/local/pcre --enable-shared
make
make test
make install
安装unzip:
执行:
unzip -v
看到版本号,说明已存在,不需要再安装;如果提示找不到命令,执行命令安装unzip:
apt-get install unzip
安装gzip:
执行:
gzip -h
若提示找不到命令,说明不存在,执行apt-get install gzip命令进行安装
安装curl:
apt-get install curl
安装GNU Screen、rpl、MTR、Ping/Ping6、Traceroute/Traceroute6:
安装screen:
先执行:
screen -v
如果看到:
- Screen version 4.00.03jw4 (FAU) 2-May-06
apt-get install screen
如果用编译方式安装screen,可以访问网站下载源码:
http://www.gnu.org/software/screen/
http://aperiodic.net/screen
安装rpl:
先执行:
rpl -v
若看到:
- -bash: rpl: command not found
apt-get install rpl
看到显示:
- Unpacking rpl (from .../archives/rpl_1.5.5-1_all.deb) ...
- Processing triggers for man-db ...
- Setting up rpl (1.5.5-1) ...
- Processing triggers for python-support ...
安装mtr(my trace route):
先执行:
mtr -v
看到:
- mtr 0.75
apt-get install mtr
也可以下载源码编译安装mtr:
http://www.bitwizard.nl/mtr/
ftp://ftp.bitwizard.nl/mtr/
查看网络配置,执行:
ifconfig
若看到:
- venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
- inet addr:127.0.0.2 P-t-P:127.0.0.2 Bcast:0.0.0.0 Mask:255.255.255.255
- inet6 addr: 2607:5300:10:501::1:7741/128 Scope:Global
- UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
- RX packets:11599 errors:0 dropped:0 overruns:0 frame:0
- TX packets:9937 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
- RX bytes:15644443 (14.9 MiB) TX bytes:700996 (684.5 KiB)
进行IPv6网络测试,执行:
ping6 ipv6.google.com
正常会显示:
- PING ipv6.google.com(2a00:1450:400c:c06::69) 56 data bytes
- 64 bytes from 2a00:1450:400c:c06::69: icmp_seq=1 ttl=53 time=81.6 ms
- 64 bytes from 2a00:1450:400c:c06::69: icmp_seq=2 ttl=53 time=81.5 ms
- 64 bytes from 2a00:1450:400c:c06::69: icmp_seq=3 ttl=51 time=81.7 ms
- 64 bytes from 2a00:1450:400c:c06::69: icmp_seq=4 ttl=51 time=82.0 ms
traceroute6 ipv6.google.com
正常会显示:
- traceroute to ipv6.google.com (2a00:1450:400c:c06::69), 30 hops max, 80 byte packets
- 1 2607:5300:10:500::1511 (2607:5300:10:500::1511) 0.071 ms 0.021 ms 0.018 ms
- 2 2607:5300::58 (2607:5300::58) 0.601 ms * *
- 3 * * *
- 4 rbx-g1-a9.fr.eu (2001:41d0::771) 73.974 ms 73.963 ms 73.941 ms
- 5 ams-1-6k.nl.eu (2001:41d0::7d2) 77.025 ms ams-1-6k.nl.eu
(2001:41d0::1b1) 77.028 ms ams-1-6k.nl.eu (2001:41d0::1ad) 77.900 ms
- 6 amsix-router.google.com (2001:7f8:1::a501:5169:1) 77.248 ms 134.847 ms 134.626 ms
执行ping6或者traceroute6如果看到:
- connect: Network is unreachable
apt-get install miredo
要配置miredo,可以执行nano /etc/miredo/miredo.conf
miredo网站:http://www.remlab.net/miredo/
安装Nginx之前,先安装zlib:【如果已经有了,不用安装,只下载源码包,后面安装nginx要用到】
http://www.zlib.net/
http://sourceforge.net/projects/libpng/files/zlib/
cd /tmp
wget http://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.7/zlib127.zip
unzip zlib127.zip
# 已经有zlib的不继续安装
cd zlib-1.2.7
./configure --prefix=/usr/local/zlib --enable-shared
make
make test
make install
安装zlibc、zlib1g-dev:
apt-get install zlibc zlib1g-dev
这一步是为了安装python的zlibc的支持,不然后面安装setuptools的时候,会提示出错信息:
- zipimport.ZipImportError: can't decompress data; zlib not available
安装libxml2:
http://www.xmlsoft.org/
ftp://xmlsoft.org/libxml2/
http://www.xmlsoft.org/downloads.html
ftp://gd.tuwien.ac.at/pub/libxml/
cd /tmp
wget ftp://gd.tuwien.ac.at/pub/libxml/libxml2-sources-2.9.0.tar.gz
tar zxvf libxml2-sources-2.9.0.tar.gz
cd libxml2-2.9.0
./configure --enable-shared
make
make check
make install
/usr/local/share/doc/libxml2-2.9.0
apt-get -f install
安装libxslt:
http://xmlsoft.org/XSLT/downloads.html
http://xmlsoft.org/XSLT/
ftp://gd.tuwien.ac.at/pub/libxml/
cd /tmp
wget ftp://xmlsoft.org/libxml2/libxslt-git-snapshot.tar.gz
tar zxvf libxslt-git-snapshot.tar.gz
cd libxslt-1.1.27
./configure --enable-shared
make
make check
make install
安装python:
先执行:
python -v
一般系统中都已经存在python,执行这个命令可以查看python组件的版本号,并进入python,执行Ctrl + D组合键退出Python;执行whereis python查看python目录,输出:
- python: /usr/bin/python /usr/bin/python2.6 /etc/python /etc/python2.6 /usr/lib/python2.6 /usr/lib/python2.5 /usr/lib/python2.4 /usr/lib64/python2.6 /usr/lib64/python2.5 /usr/lib64/python2.4 /usr/local/lib/python2.6 /usr/include/python2.6 /usr/share/python /usr/share/man/man1/python.1.gz
如果系统中不存在python,或者已经存在,都可以下载python最新版源码编译安装:
http://www.python.org/getit/
cd /tmp
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar zxvf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/usr/local/python2.7 --enable-unicode=ucs4 --enable-shared
# 【之前已经安装zlib和zlibc,这里不再进行修改,不然会出错】
# 修改模块配置,让python支持zlib:
# nano Modules/Setup
# 在454行左右找到:#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
# 去掉前面的#注释
# 变成:zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
make
make test
make install
安装完成,输出信息:
- test -d /usr/local/python2.7/lib/pkgconfig || /usr/bin/install -c -d -m 755 /usr/local/python2.7/lib/pkgconfig
- rm -f /usr/local/python2.7/lib/pkgconfig/python2.pc
- (cd /usr/local/python2.7/lib/pkgconfig; ln -s python-2.7.pc python2.pc)
- rm -f /usr/local/python2.7/lib/pkgconfig/python.pc
- (cd /usr/local/python2.7/lib/pkgconfig; ln -s python2.pc python.pc)
- /usr/bin/install -c -m 644 ./Misc/python.man \
- /usr/local/python2.7/share/man/man1/python2.7.1
查看库信息,执行:
file python
输出:
- python: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
对于系统中本来已经存在的python,新安装python后,需要修改一下系统中python命令的链接:
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python2.7/bin/python /usr/bin/python
ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python2.7
测试一下程序运行情况,执行:
python
如果出现:
- python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
【方案一,不使用此方案,这里也可以用方案二通过,不过后面安装Twisted的时候会出错】出错信息的解决办法:
whereis libpython2.7.so.1.0
输出:
- libpython2.7.so.1: /usr/local/lib/libpython2.7.so.1.0
chmod +x /usr/local/lib/libpython2.7.so
chmod +x /usr/local/lib/libpython2.7.so.1.0
再执行:
cp /usr/local/python2.7/lib/libpython2.7.so.1.0 /usr/local/lib
cd /usr/local/lib
ln -s libpython2.7.so.1.0 libpython2.7.so
【方案二,可以叠加方案一】出现这个错误信息,执行:
nano /etc/ld.so.conf
添加一行:
/usr/local/python2.7/lib
保存后,再执行:
/sbin/ldconfig
/sbin/ldconfig -v
可以查看库信息
这时候,再执行:
python
正常进入,输出:
- Python 2.7.3 (default, Sep 20 2012, 07:48:33)
- [GCC 4.4.5] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>>
Python安装完毕后,还需要安装用来设置python的工具:setuptools,包含easy_install可以用来安装Python第三方扩展包
http://pypi.python.org/pypi/setuptools/
http://pypi.python.org/packages/2.7/s/setuptools/
http://peak.telecommunity.com/DevCenter/EasyInstall#command-line-options
http://peak.telecommunity.com/DevCenter/EasyInstall
http://www.ibm.com/developerworks/cn/linux/l-cppeak3.html
忽略:
cd /tmp
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
mkdir -p /usr/local/python2.7/setuptools/lib/python2.7/site-packages
sh setuptools-0.6c11-py2.7.egg --prefix=/usr/local/python2.7/setuptools
执行:
cd /tmp
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
输出:
- Installed /usr/local/python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
- Processing dependencies for setuptools==0.6c11
- Finished processing dependencies for setuptools==0.6c11
sh /usr/local/python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
输出:
- Processing setuptools-0.6c11-py2.7.egg
- setuptools 0.6c11 is already the active version in easy-install.pth
- Installing easy_install script to /usr/local/python2.7/bin
- Installing easy_install-2.7 script to /usr/local/python2.7/bin
- Installed /usr/local/python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
- Processing dependencies for setuptools==0.6c11
- Finished processing dependencies for setuptools==0.6c11
安装web.py:
http://webpy.org/
http://webpy.org/install.zh-cn
http://webpy.org/docs/0.3/tutorial.zh-cn
https://github.com/webpy/webpy
http://webpy.org/cookbook/mod_wsgi-nginx
cd /tmp
wget http://webpy.org/static/web.py-0.37.tar.gz
tar zxvf web.py-0.37.tar.gz
cd web.py-0.37
python setup.py build
python setup.py install
最后输出:
- running install_egg_info
- Writing /usr/local/python2.7/lib/python2.7/site-packages/web.py-0.37-py2.7.egg-info
web.py 内置了web服务器,可以写一个简单的code.py应用,然后使用python code.py命令启动web.py内置的服务器,打开你的浏览器输入 http://localhost:8080/ 查看页面。 若要制定另外的端口,使用 python code.py 1234。
安装Spawn-fcgi:
http://www.lighttpd.net/
http://www.lighttpd.net/download
http://redmine.lighttpd.net/projects/spawn-fcgi/wiki
http://download.lighttpd.net/spawn-fcgi/
cd /tmp
wget http://download.lighttpd.net/spawn-fcgi/releases-1.6.x/spawn-fcgi-1.6.3.tar.gz
tar zxvf spawn-fcgi-1.6.3.tar.gz
cd spawn-fcgi-1.6.3
./configure --prefix=/usr/local/spawn-fcgi --bindir=/usr/bin --libdir=/usr/lib
make
make check
make install
# 建立链接【输入spawn-fcgi命令执行,如果打开,这一步忽略】
ln -s /usr/local/spawn-fcgi/bin/spawn-fcgi /usr/bin/
安装Django:
https://www.djangoproject.com/
https://www.djangoproject.com/download/
cd /tmp
wget http://www.djangoproject.com/m/releases/1.4/Django-1.4.1.tar.gz
tar zxvf Django-1.4.1.tar.gz
cd Django-1.4.1
python setup.py build
python setup.py install
最后两行输出:
- running install_egg_info
- Writing /usr/local/python2.7/lib/python2.7/site-packages/Django-1.4.1-py2.7.egg-info
安装uWSGI:
http://projects.unbit.it/uwsgi/
http://projects.unbit.it/downloads/
http://wiki.nginx.org/HttpUwsgiModule
http://projects.unbit.it/uwsgi/wiki
http://projects.unbit.it/uwsgi/wiki/Quickstart
cd /tmp
wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gz
tar zxvf uwsgi-latest.tar.gz
cd uwsgi-1.2.6
python uwsgiconfig.py --build
python setup.py build
python setup.py install
最后两行输出:
- Copying uWSGI.egg-info to /usr/local/python2.7/lib/python2.7/site-packages/uWSGI-1.2.6-py2.7.egg-info
- running install_scripts
【以下步骤省略】
mkdir /usr/local/uwsgi
cd ..
cp -r uwsgi-1.2.6 /usr/local/uwsgi/bin
【以下步骤省略】
mkdir -p /usr/local/uwsgi/conf
mkdir -p /usr/local/uwsgi/logs
【以下步骤省略】
cp welcome.ini /usr/local/uwsgi/bin/welcome.ini
cp uwsgi.xml /usr/local/uwsgi/bin/uwsgi.xml
【以下步骤省略】
nano /usr/local/uwsgi/bin/uwsgi.xml
【以下步骤省略】
# <uwsgi>和</uwsgi>之间写入内容:
<listen>200</listen>
<master>true</master>
<pidfile>/usr/local/uwsgi/logs/uwsgi.pid</pidfile>
<processes>8</processes>
<pythonpath>/usr/local/python_web/www</pythonpath>
<pythonpath>/usr/local/python_web/</pythonpath>
<module>django_wsgi</module>
<profiler>true</profiler>
<memory-report>true</memory-report>
<enable-threads>true</enable-threads>
<logdate>true</logdate>
<limit-as>6048</limit-as>
<daemonize>/usr/local/uwsgi/logs/django.log</daemonize>
安装flup<前面没有安装成功setuptools的在这里跳过>:flup是用python实现的WSGI(网页网关接口)
http://www.saddi.com/software/flup/dist/
http://flup.org/
http://trac.saddi.com/flup
cd /tmp
wget http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gz
tar zxvf flup-1.0.2.tar.gz
cd flup-1.0.2
python setup.py build
python setup.py install
最后三行输出:
- Installed /usr/local/python2.7/lib/python2.7/site-packages/flup-1.0.2-py2.7.egg
- Processing dependencies for flup==1.0.2
- Finished processing dependencies for flup==1.0.2
【可有可无】安装libevent
http://libevent.org/
cd /tmp
wget https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
tar zxvf libevent-2.0.20-stable.tar.gz
cd libevent-2.0.20-stable
./configure --prefix=/usr/local/libevent --enable-shared
make
make check
make install
【可有可无】安装gevent:
http://www.gevent.org/
http://pypi.python.org/pypi/gevent#downloads
cd /tmp
wget http://pypi.python.org/packages/source/g/gevent/gevent-0.13.8.tar.gz
tar zxvf gevent-0.13.8.tar.gz
cd gevent-0.13.8
python setup.py build
python setup.py install
【可有可无】安装memcached:
http://memcached.org/
https://code.google.com/p/memcached/
cd /tmp
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
tar zxvf memcached-1.4.15.tar.gz
cd memcached-1.4.15
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
make
make test
make install
【可有可无,推荐安装】安装sqlalchemy:
http://www.sqlalchemy.org/
http://sourceforge.net/projects/sqlalchemy/
http://www.sqlalchemy.org/download.html
cd /tmp
wget http://downloads.sourceforge.net/project/sqlalchemy/sqlalchemy/0.7.8/SQLAlchemy-0.7.8.tar.gz
tar zxvf SQLAlchemy-0.7.8.tar.gz
cd SQLAlchemy-0.7.8
python setup.py build
python setup.py install
build命令之后出现:
- ***************************************************************************
- WARNING: The C extension could not be compiled, speedups are not enabled.
- Plain-Python build succeeded.
- ***************************************************************************
install命令执行后,安装结束,还是会出现警告提示,但是安装成功:
- Installed /usr/local/python2.7/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7.egg
- Processing dependencies for SQLAlchemy==0.7.8
- Finished processing dependencies for SQLAlchemy==0.7.8
- ***************************************************************************
- WARNING: The C extension could not be compiled, speedups are not enabled.
- Plain-Python build succeeded.
- ***************************************************************************
安装mysql.
【略过,需要先安装MySQL】安装MySQLdb:
http://mysql-python.sourceforge.net/MySQLdb.html
http://mysql-python.sourceforge.net/
http://sourceforge.net/projects/mysql-python/
http://sourceforge.net/projects/mysql-python/files/
http://pypi.python.org/pypi/MySQL-python
cd /tmp
wget http://downloads.sourceforge.net/project/mysql-python/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
【可有可无,推荐安装】安装Twisted:
http://twistedmatrix.com/trac/
cd /tmp
wget http://pypi.python.org/packages/source/T/Twisted/Twisted-12.2.0.tar.bz2
bzip2 -d Twisted-12.2.0.tar.bz2
tar xvf Twisted-12.2.0.tar
cd Twisted-12.2.0
python setup.py build
python setup.py install
前面安装python之后执行python命令后,出现错误的方案一如果没有进行的话,这里build执行后会出错:
- /usr/bin/ld: cannot find -lpython2.7
- collect2: ld returned 1 exit status
- error: command 'gcc' failed with exit status 1
Twisted安装成功后的最后一段输出信息:
- Installed /usr/local/python2.7/lib/python2.7/site-packages/zope.interface-4.0.1-py2.7-linux-x86_64.egg
- Searching for setuptools==0.6c11
- Best match: setuptools 0.6c11
- Processing setuptools-0.6c11-py2.7.egg
- setuptools 0.6c11 is already the active version in easy-install.pth
- Installing easy_install script to /usr/local/python2.7/bin
- Installing easy_install-2.7 script to /usr/local/python2.7/bin
- Using /usr/local/python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
- Finished processing dependencies for Twisted==12.2.0
【可有可无,推荐安装】安装python-memcached:
http://www.tummy.com/Community/software/python-memcached/
http://pypi.python.org/pypi/python-memcached/
cd /tmp
wget ftp://ftp.tummy.com/pub/python-memcached/python-memcached-latest.tar.gz
tar zxvf python-memcached-latest.tar.gz
cd python-memcached-1.48
python setup.py build
python setup.py install
安装成功最后几行输出:
- Copying python_memcached-1.48-py2.7.egg to /usr/local/python2.7/lib/python2.7/site-packages
- Adding python-memcached 1.48 to easy-install.pth file
- Installed /usr/local/python2.7/lib/python2.7/site-packages/python_memcached-1.48-py2.7.egg
- Processing dependencies for python-memcached==1.48
- Finished processing dependencies for python-memcached==1.48
【可有可无,推荐安装】安装Python Imaging Library(PIL):
http://www.pythonware.com/products/pil/
cd /tmp
wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
tar zxvf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
python setup.py build
python setup.py install
最后几行输出:
- running install_egg_info
- Writing /usr/local/python2.7/lib/python2.7/site-packages/PIL/PIL-1.1.7-py2.7.egg-info
- creating /usr/local/python2.7/lib/python2.7/site-packages/PIL.pth
【可有可无,推荐安装】安装simplejson:
http://pypi.python.org/pypi/simplejson/
http://code.google.com/p/simplejson/
https://github.com/simplejson/simplejson/
http://simplejson.readthedocs.org/en/latest/index.html
http://json.org/json-zh.html
http://undefined.org/python/
cd /tmp
wget http://pypi.python.org/packages/source/s/simplejson/simplejson-2.6.1.tar.gz
tar zxvf simplejson-2.6.1.tar.gz
cd simplejson-2.6.1
python setup.py build
python setup.py install
最后两行输出:
- running install_egg_info
- Writing /usr/local/python2.7/lib/python2.7/site-packages/simplejson-2.6.1-py2.7.egg-info
【可有可无】安装cherrypy:
http://www.cherrypy.org/
http://download.cherrypy.org/cherrypy/3.2.2/
cd /tmp
wget http://download.cherrypy.org/cherrypy/3.2.2/CherryPy-3.2.2.tar.gz
tar zxvf CherryPy-3.2.2.tar.gz
cd CherryPy-3.2.2
python setup.py build
python setup.py install
安装输出最后一段:
- Processing CherryPy-3.2.2-py2.7.egg
- creating /usr/local/python2.7/lib/python2.7/site-packages/CherryPy-3.2.2-py2.7.egg
- Extracting CherryPy-3.2.2-py2.7.egg to /usr/local/python2.7/lib/python2.7/site-packages
- Adding CherryPy 3.2.2 to easy-install.pth file
- Installing cherryd script to /usr/local/python2.7/bin
- Installed /usr/local/python2.7/lib/python2.7/site-packages/CherryPy-3.2.2-py2.7.egg
- Processing dependencies for CherryPy==3.2.2
- Finished processing dependencies for CherryPy==3.2.2
【可有可无,未安装】安装tornado:
http://www.tornadoweb.org/
https://github.com/facebook/tornado
http://pypi.python.org/pypi/tornado
http://www.tornadoweb.org/documentation/index.html
http://www.tornadoweb.cn/
cd /tmp
wget https://github.com/downloads/facebook/tornado/tornado-2.4.tar.gz
tar xvzf tornado-2.4.tar.gz
cd tornado-2.4
python setup.py build
python setup.py install
安装输出最后一段:
- Processing tornado-2.4-py2.7.egg
- creating /usr/local/python2.7/lib/python2.7/site-packages/tornado-2.4-py2.7.egg
- Extracting tornado-2.4-py2.7.egg to /usr/local/python2.7/lib/python2.7/site-packages
- Adding tornado 2.4 to easy-install.pth file
- Installed /usr/local/python2.7/lib/python2.7/site-packages/tornado-2.4-py2.7.egg
- Processing dependencies for tornado==2.4
- Finished processing dependencies for tornado==2.4
安装PostgresSQL.
【略过,要先安装PostgreSQL才能安装这个】安装psycopg2:Python连PostgreSQL要psycopg2模块
http://initd.org/psycopg/
http://initd.org/psycopg/tarballs/
cd /tmp
wget http://initd.org/psycopg/tarballs/psycopg2-latest.tar.gz
tar zxvf psycopg2-latest.tar.gz
cd psycopg2-2.4.5
python setup.py build
python setup.py install
成功后,可以运行python命令,再输入import psycopg2验证一下有没有错误
【可有可无】安装eurasia:
http://code.google.com/p/eurasia/
http://code.google.com/p/eurasia/wiki/eurasia_3_1_userguide
cd /tmp
wget http://eurasia.googlecode.com/files/eurasia-3.1-snapshot.tar.bz2
tar jxf eurasia-3.1-snapshot.tar.bz2
cd eurasia-3.1-snapshot
python setup.py install
安装pyopenssl:
http://pyopenssl.sourceforge.net/
http://packages.python.org/pyOpenSSL/
http://pypi.python.org/pypi/pyOpenSSL
cd /tmp
wget http://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.13.tar.gz
tar zxvf pyOpenSSL-0.13.tar.gz
cd pyOpenSSL-0.13
python setup.py build
python setup.py install
安装scrapy:
http://scrapy.org/
https://github.com/scrapy/scrapy
http://scrapy.org/download/
http://pypi.python.org/pypi/Scrapy
cd /tmp
wget https://nodeload.github.com/scrapy/scrapy/tarball/0.14
安装pymongo:
http://api.mongodb.org/python/current/
http://pypi.python.org/pypi/pymongo/
Python和相关部件已经安装完毕,接下来,安装前端服务器之一:Lighttpd,解析py脚本,进行80端口对外服务
有说Lighttpd运行需要libpcre和libz,前面安装的pcre即是libpcre:http://www.pcre.org/
安装libz:http://www.zlib.net/
libz即是zlib,前面也已经安装过了
安装Nginx之前,安装openssl,如果要让lighttpd也支持ssl功能,也要先安装openssl,安装openssl之前,先执行openssl命令,如果已经存在,会自动进入,执行exit命令退出
系统已经存在openssl的话,需要执行whereis openssl命令,查看openssl所在的目录,执行后可以看到:
- openssl: /usr/bin/openssl /usr/share/man/man1/openssl.1ssl.gz
http://www.openssl.org/
http://www.openssl.org/docs/
http://www.openssl.org/source/
ftp://ftp.openssl.org/source/
cd /tmp
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar zxvf openssl-1.0.1c.tar.gz
# 已经有openssl可以不继续安装
cd openssl-1.0.1c
./config --prefix=/usr/local/openssl
make
make test
make install
配置文件位于:/usr/local/openssl/openssl.cnf
安装autoconf:
apt-get install autoconf
安装lighttpd:
http://www.lighttpd.net/
http://www.lighttpd.net/download
http://download.lighttpd.net/lighttpd/
http://webpy.org/cookbook/fastcgi-lighttpd.zh-cn
http://redmine.lighttpd.net/projects/lighttpd/wiki
http://redmine.lighttpd.net/projects/lighttpd/wiki/InstallFromSource
cd /tmp
wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.31.tar.bz2
tar jxf lighttpd-1.4.31.tar.bz2
cd lighttpd-1.4.31
# 可以先执行./configure --help查看配置帮助
./configure --prefix=/usr/local/lighttpd --with-zlib --with-openssl --enable-shared --with-ldap --with-memcache --with-pcre
# 备用./configure --prefix=/usr/local/lighttpd --with-zlib --with-openssl --enable-shared --with-ldap --with-memcache --without-pcre --without-bzip2
# --with-pcre这个不能少,在这里配置出错:configure: error: pcre-config not found, install the pcre-devel package or build with --without-pcre
# --with-openssl也可以带上路径,--with-openssl=/usr/bin/openssl具体目录依照实际情况配置
# 如果已经安装mysql,可以使用--with-mysql=/usr/local/mysql/bin/mysql_config
# 整合php的时候,使用--enable-fastcgi不能指定 --with-apxs选项【别处看到的,未经验证】
make
make check
make install
程序位置:
/usr/local/lighttpd/sbin/lighttpd
lighttpd的配置文件目录需要手动创建:
mkdir /etc/lighttpd
主配置文件放置位置:
/etc/lighttpd/lighttpd.conf
复制配置文件:
cp doc/config/lighttpd.conf /etc/lighttpd
cp doc/config/modules.conf /etc/lighttpd
cp -r doc/config/conf.d /etc/lighttpd
cp -r doc/config/vhosts.d /etc/lighttpd
chmod 777 /etc/lighttpd/vhosts.d
cp doc/scripts/spawn-php.sh /usr/local/lighttpd/
cp doc/scripts/rrdtool-graph.sh /usr/local/lighttpd/
创建用户组和用户:
groupadd lighttpd
useradd -g lighttpd lighttpd
配置文件备份:
cp /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.bak
配置过程很麻烦,放到最后进行,继续向下,安装nginx
nginx运行需要:gzip module requires zlib library、rewrite module requires pcre library、ssl support requires openssl library
所需要的准备工作前面都已经完成
安装cmake2.8.4或更高:
http://www.cmake.org
http://cmake.org/cmake/resources/software.html
# 这个太陈旧了 apt-get install cmake
# apt-get remove cmake
cd /tmp
wget http://www.cmake.org/files/v2.8/cmake-2.8.9.tar.gz
tar zxvf cmake-2.8.9.tar.gz
cd cmake-2.8.9
./configure
# --prefix=/usr/local/cmake
make
make test
make install
安装目录:/usr/local/share/cmake-2.8
【这一段为hiawatha而写,放弃】
安装前端服务器之一:hiawatha,进行80端口对外服务,之前的lighttpd方案放弃
http://www.hiawatha-webserver.org/
http://www.hiawatha-webserver.org/files/
http://www.hiawatha-webserver.org/download
http://files.tuxhelp.org/hiawatha/
此方法不适用
cd /tmp
wget http://www.hiawatha-webserver.org/files/hiawatha-8.5.tar.gz
# wget http://files.tuxhelp.org/hiawatha/hiawatha-8.5.tar.gz
tar zxvf hiawatha-8.5.tar.gz
cd hiawatha-8.5
apt-get install libc6-dev libssl-dev dpkg-dev debhelper fakeroot libxml2-dev libxslt1-dev build-essentail
cmake -DENABLE_CACHE=ON -DENABLE_CHROOT=on -DENABLE_IPV6=ON -DENABLE_MONITOR=on -DENABLE_RPROXY=ON -DENABLE_SSL=ON -DENABLE_TOMAHAWK=on -DENABLE_TOOLKIT=ON -DENABLE_XSLT=ON -DCMAKE_INSTALL_PREFIX=/usr/local/hiawatha -DCMAKE_INSTALL_SYSCONFDIR=/etc
make
make check
make install
deb包安装方法:
wget http://files.tuxhelp.org/hiawatha/hiawatha_8.5_amd64.deb
dpkg -i hiawatha_8.5_amd64.deb
安装前端服务器之二:Nginx,进行8080端口对外服务
安装nginx:
http://nginx.org/en/
http://nginx.org/cn/
http://nginx.org/en/download.html
http://nginx.org/cn/docs/
cd /tmp
wget http://nginx.org/download/nginx-1.2.3.tar.gz
tar zxvf nginx-1.2.3.tar.gz
cd nginx-1.2.3
【--with-pcre=这里是需要设定源码目录,不是安装后的目录,--with-zlib=和--with-openssl=都是,前面没有下载的,需要下载,并且解压缩,不用安装】
#可以使用./configure --help命令查看帮助
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-zlib=/tmp/zlib-1.2.7 --with-pcre=/tmp/pcre-8.31/ --with-openssl=/tmp/openssl-1.0.1c --with-http_ssl_module --with-http_stub_status_module --with-http_stub_status_module --with-rtsig_module --with-http_realip_module --with-http_addition_module --with-mail --with-mail_ssl_module --with-ipv6
make
make install
为nginx运行创建用户组和用户:
groupadd nginx
useradd -g nginx nginx
配置文件位于/usr/local/nginx/conf目录中
执行命令备份一下nginx.conf文件:
cd /usr/local/nginx/conf
cp nginx.conf nginx.conf.bak
编辑nginx配置文件:
nano /usr/local/nginx/conf/nginx.conf
找到:
- #user nobody;
- 然后再找到:
- server {
- listen 80;
- server_name localhost;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- root html;
- index index.html index.htm;
- }
- #error_page 404 /404.html;
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
修改为:
user nginx;
# 剩下部分:
server {
listen 8080;
server_name localhost;
#charset koi8-r;
access_log /var/log/host.access.log;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
保存配置
测试nginx配置文件:
/usr/local/nginx/sbin/nginx -t
如果输出:
- nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
- nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
说明配置正确;配置文件示例:http://wiki.nginx.org/NginxFullExample
【这一段为lighttpd而写,放弃】
创建web服务器网页文件目录:
mkdir -p /srv/www/htdocs
修改lighttpd模块配置文件:
cp /etc/lighttpd/modules.conf /etc/lighttpd/modules.conf.bak
# 先备份一份
nano /etc/lighttpd/modules.conf
找到:
server.modules = (
"mod_access",
# "mod_alias",
# "mod_auth",
# "mod_evasive",
# "mod_redirect",
# "mod_rewrite",
# "mod_setenv",
# "mod_usertrack",
)
修改为:
server.modules = (
"mod_access",
"mod_alias",
"mod_rewrite",
"mod_fastcgi",
"mod_evasive",
# "mod_alias",
# "mod_auth",
# "mod_evasive",
# "mod_redirect",
# "mod_rewrite",
# "mod_setenv",
# "mod_usertrack",
)
编辑lighttpd主配置文件:
nano /etc/lighttpd/lighttpd.conf
找到:
#server.bind = "localhost"
index-file.names += (
"index.xhtml", "index.html", "index.htm", "default.htm", "index.php"
)
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".scgi" )
server.upload-dirs = ( "/var/tmp" )
修改为:
server.bind = "localhost"
index-file.names += (
"index.xhtml", "index.html", "index.htm", "default.htm", "index.php", "index.py"
)
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".scgi", ".py" )
server.upload-dirs = ( "/var/tmp" )
手动建立log文件:
mkdir /var/log/lighttpd
chmod 777 /var/log/lighttpd
touch /var/log/lighttpd/error.log
chmod 666 /var/log/lighttpd/error.log
在站点根目录创建一个python测试示例test11:
cd /srv/www/htdocs
/usr/local/python2.7/bin/django-admin.py startproject test11
建立localhost的fcgi文件:
nano localhost.fcgi
#!/usr/local/python2.7
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/usr/local/python2.7")
# Switch to the directory of your project. (Optional.)
# os.chdir("/usr/htdocs/test1")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "localhost.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
chmod +x test11/manage.py
test11/manage.py runfcgi method=prefork socket=/tmp/test11.sock pidfile=django.pid
修改lighttpd配置文件:
nano /etc/lighttpd/lighttpd.conf
找到
server.document-root = server_root + "/htdocs"
后面加入:
fastcgi.server = (
"/localhost.fcgi" => (
"main" => (
"socket" => "/tmp/test11.sock",
"check-local" => "disable"
)
)
)
url.rewrite = (
"^(/site_media/.*)$" => "$1",
"^(/.*)$" => "/localhost.fcgi$1"
)
【创建虚拟主机】
创建普通用户名,以普通用户身份创建web虚拟主机目录:
useradd -d /home/net73yi -m net73yi
chown net73yi -R /home/net73yi
passwd net73yi
su - net73yi
mkdir -p html/demo73yi
chmod 777 html/demo73yi
普通用户身份创建虚拟主机配置文件:
nano /etc/lighttpd/vhosts.d/demo.urdomain.com.conf
# 写入内容:
$HTTP["host"] == "demo.urdomain.com" {
var.server_name = "demo.urdomain.com"
server.name = server_name
server.document-root = "/path/to/ur-document-root"
# server.document-root = vhosts_dir + "/example.com/download/htdocs"
##
## use a seperate access log file
## At the moment you cant have different error log files.
accesslog.filename = log_root + "/" + server_name "/access.log"
}
#$SERVER["socket"] == "127.0.0.1:443" {
# server.name = "localhost"
# ssl.pemfile = "/etc/ssl/private/lighttpd-localhost.pem"
# ssl.engine = "enable"
#
# server.document-root = vhosts_dir + "/ssl-localhost/pages/"
#}
启动lighttpd:
/usr/local/lighttpd/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
输出:
2012-09-22 06:44:52: (plugin.c.131) Cannot load plugin mod_accesslog more than once, please fix your config (we may not accept such configs in future releases
2012-09-22 06:44:52: (network.c.260) warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes
2012-09-22 06:44:52: (log.c.118) opening errorlog '/var/log/lighttpd/error.log' failed: No such file or directory
执行命令复制一个mtr6文件:
【此处mtr目录依据实际情况进行配置,如果是自己编译安装的,就把目录修改成自己安装的目录,系统自带的可以通过whereis mtr命令查询】
cp /usr/bin/mtr /usr/bin/mtr6
下载transitlg:
cd /root
wget http://downloads.sourceforge.net/project/transitlg/transitlg.zip
unzip transitlg.zip
cd transitlg
chmod +x transitlg.py
chmod +x run.sh
复制transitlg目录到站点目录:
暂停,这里的站点目录是lighttpd的目录.