2013-03-05-14:43:09   原创:容易


系统环境

centos6.3-32位选择base server安装

一、安装后基本配置
1)创建用户
useradd -s /sbin/nologin www   #nginx等应用的运行账户
useradd pgsql   #postgresql,pgbouncer运行账户
2)selinux,iptables
cat /etc/sysconfig/selinux   修改selinux配置
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq #保存,关闭。
chkconfig --level 35 iptables off   关闭防火墙
shutdown -r now #重启系统


二、修改内核参数 vi /etc/sysctl.conf


添加如下内容,运行  sysctl -p  使其生效,具体含义可以参考其他资料
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 15
net.core.somaxconn = 20480
net.ipv4.ip_local_port_range =  1024 65000
net.core.netdev_max_backlog = 20480
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 20480
net.ipv4.tcp_max_tw_buckets = 600
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

三、安装编译环境
yum install gcc-4.4.6
yum install zlib-devel
yum install pcre-devel
yum install readline readline-devel
yum install openssl-devel
yum install libjpeg-devel
yum install freetype-devel


四、编译安装python-2.7.3环境(假如缺少库文件将python重新编译安装)


./configure --prefix=/app/python
make && make install
安装后配置PATH
 cat .bashrc 添加如下
 export PATH=/app/python/bin:$PATH
安装python setuptools
tar -zxvf setuptools-0.6c11.tar.gz
python setup.py  install


五、安装postgresql
tar -zxvf postgresql-9.2.2.tar.gz
./configure --prefix=/app/pgsql
gmake world    
gmake install-world
添加以下内容到cat .bashrc
export PATH=/app/python/bin:/app/pgsql/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/pgsql/lib
source .bashrc


六、安装psycopg2-2.4.5(连接PG数据库)
python setup.py build_ext --pg-config /app/pgsql/bin/pg_config build install
测试安装结果
import psycopg2   没有报错说明一切正常
可能的错误
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib64/python2.3/site-packages/pg.py", line 21, in ?
 from _pg import *
ImportError: libpq.so.5: cannot open shared object file: No such file or directory
解决:
cd /etc/ld.so.conf.d
echo "/usr/local/pgsql/lib" >>pgsql.conf
ldconfig
可能也可以:未试
# nano /etc/profile
在 unset i前面添加环境变量
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgsql/lib
# source /etc/profile


七、安装django-1.4.2
tar -zxvf Django-1.4.2.tar.gz
cd Django-1.4.2
python setup.py  install
测试django  输入python 运行以下命令
>>> import django
>>> django.VERSION
(1, 4, 2, 'final', 0)
在/app/mysite 目录下运行以下命令
django-admin.py startproject 3qos


八、安装PIL(Imaging-1.1.7.tar.gz)
tar -zxvf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
python setup.py build_ext -i
 查看编译结果看是否支持jpeg等
  --------------------------------------------------------------------
  version       1.1.7
  platform      linux2 2.7.3 (default, Nov 20 2012, 18:20:19)
       [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]
  --------------------------------------------------------------------
  *** TKINTER support not available
  --- JPEG support available
  --- ZLIB (PNG/ZIP) support available
  --- FREETYPE2 support available
  *** LITTLECMS support not available
  --------------------------------------------------------------------
 python setup.py install


九、安装 pgbouncer
tar -zxvf libevent-2.0.20-stable.tar.gz
./configure --prefix=/app/libevent
make  && make install
tar -zxvf pgbouncer-1.5.4.tar.gz
./configure --prefix=/app/pgbouncer --with-libevent=/app/libevent/
make && make install

cd /app/pgbouncer

mkdir etc  log  run



十、安装nginx
./configure --prefix=/app/nginx --with-md5=/usr/lib --with-sha1=/usr/lib --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module  --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_realip_module --without-http_ssi_module --with-http_perl_module --without-http_scgi_module --without-http_fastcgi_module

 make && make install
 
十一、安装uwsgi  
tar -zxvf uwsgi-1.4.4.tar.gz
python uwsgiconfig.py --build     生成bin文件
*** uWSGI is ready, launch it with ./uwsgi ***  看到如下输出说明编译成功
创建/app/uwsgi目录 子目录包括bin  etc log
将生产的bin文件 uwsgi 拷贝到 /app/uwsgi/bin 目录下
编写配置文件如下参数说明可以通过uwsgi --help查看
在/app/mysite/uwsgi/etc目录下创建uwsgi的配置文件内容如下


启动uwsgi

/opt/uwsig/bin/uwsig --ini /opt/uwsig/etc/uwsgi.ini

重新加载

uwsgi --reload /opt/uwsgi/log/uwsgi-master.pid



十三、安装python-memcached
tar -zxvf python-memcached-1.48.tar.gz
cd python-memcached-1.48
python setup.py install
测试模块导入
import memcache

十四、安装memcached
./configure --prefix=/app/memcached --with-libevent=/app/libevent/
make && make install
cd /app/memcached/
mkdir etc log run       创建三个目录
安装 start-stop-daemon   该命令用于/etc/init.d/memcached 脚本运行使用
tar -zxvf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
cd apps/sys-utils/start-stop-daemon-IR1_9_18-2/
编译
gcc start-stop-daemon.c -o start-stop-daemon
将生产的bin文件放到指定目录
cp start-stop-daemon /usr/bin/  
cd etc    创建 memcached.conf配置文件



安装过程完成,以后逐步将各个应用的相关配置过程与大家分享,不足和错误请留言我将及时改正,谢谢。

One Response


    还没有评论!
1  

Leave your comment

请留下您的姓名(*)

请输入正确的邮箱地址(*)

请输入你的评论(*)


感谢开源 © 2016. All rights reserved.&3Q Open Source&^_^赣ICP备15012863号-1^_^
乐于分享共同进步 KreativeThemes