最近一个微信的后台需要,迁移服务器,之前是在Ubuntu12.04上搭了一套。现在要迁到他们公司内部,说是为了安全、统一管理方便,确实能节约成本,提高管理效率,不知道其他大点的公司也是不是这种机制。
给的系统是RHEL6.4,一下子换到这类型的linux系统还有点不习惯,不过也不难,用用就习惯了。
不过,让人最恶心的是,这机子在内网上,并且是通过web统一管理系统登录上去了,各种权限没有,得走流程一步步申请,各种恶心。
下面就是安装过程了。
一、nginx1.62 稳定版
http://nginx.org/en/download.html
或者 wget http://nginx.org/download/nginx-1.6.2.tar.gz tar -zxvf nginx-1.6.2.tar.gz cd nginx-1.6.2 ./configure --sbin-path=/usr/local/sbin/nginxyum -y install pcre-devel openssl openssl-develconfigure 支持下面的选项: --prefix=<path> - Nginx安装路径。如果没有指定,默认为 /usr/local/nginx。 --sbin-path=<path> - Nginx可执行文件安装路径。只能安装时指定,如果没有指定,默认为<prefix>/sbin/nginx。 --conf-path=<path> - 在没有给定-c选项下默认的nginx.conf的路径。如果没有指定,默认为<prefix>/conf/nginx.conf。 --pid-path=<path> - 在nginx.conf中没有指定pid指令的情况下,默认的nginx.pid的路径。如果没有指定,默认为 <prefix>/logs/nginx.pid。 --lock-path=<path> - nginx.lock文件的路径。 --error-log-path=<path> - 在nginx.conf中没有指定error_log指令的情况下,默认的错误日志的路径。如果没有指定,默认为 <prefix>/logs/error.log。 --http-log-path=<path> - 在nginx.conf中没有指定access_log指令的情况下,默认的访问日志的路径。如果没有指定,默认为 <prefix>/logs/access.log。 --user=<user> - 在nginx.conf中没有指定user指令的情况下,默认的nginx使用的用户。如果没有指定,默认为 nobody。 --group=<group> - 在nginx.conf中没有指定user指令的情况下,默认的nginx使用的组。如果没有指定,默认为 nobody。 --builddir=DIR - 指定编译的目录 --with-rtsig_module - 启用 rtsig 模块安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
需要安装相应的包
./configure --sbin-path=/usr/local/sbin/nginxmake
make install
安装完成
但是,每次stop|start都需要 带上路径,下面把nginx配置成服务
初始化脚本(用于启动、停止、查看状态)当你使用源码编译安装Nginx的时候,管理Nginx非常的不方便,比如启动Nginx的命令就很长,这就需要一个初始化脚本来实现诸如使用servicenginx start就可以启动Nginx。下面我们来一步步配置安装。
- wget http://www.centos.bz/wp-content/uploads/2011/07/nginx
- mv nginx /etc/rc.d/init.d/
- chmod 755 /etc/rc.d/init.d/nginx
- /etc/rc.d/init.d/nginx status
脚本执行出现/bin/sh^M: bad interpreter错误提示
这是由于此文件是在Window下编写的,换行跟linux中不一样导致。
vim /etc/rc.d/init.d/nginx
……脚本内容省略……
:set ff
fileformat=doc
然后执行:set ff=unix
……脚本内容省略……
:set ff=unix
/etc/rc.d/init.d/nginx status
显示正在运行......
现在把Nginx加入chkconfig,并设置开机启动。
- chkconfig --add nginx
- chkconfig nginx on
启动、停止,查看状态的命令如下:
- service nginx start
- service nginx stop
- service nginx status
nginx配置 cd /usr/local/conf/nginx/server {listen 80 default;server_name localhost;root /srv/http/static;#charset koi8-r;#access_log logs/host.access.log main;location / {# root html;index index.html index.htm;}location /wx { include uwsgi_params; uwsgi_pass 127.0.0.1:9098;} ##用来把请求转发到uwsgi....................}如上红色加粗显示部分,做三处修改。执行 nginx -t 测试刚才的nginx配置文件是否有语法错误:[root@fsvps nginx]# nginx -tnginx: the configuration file /usr/local/conf/nginx/nginx.conf syntax is oknginx: configuration file /usr/local/conf/nginx/nginx.conf test is successful 二、安装uwsgi(如果python是2.6的,建议先升级到2.7 http://m.oschina.net/blog/210486)wget http://projects.unbit.it/downloads/uwsgi-1.4.2.tar.gz tar -zxvf uwsgi-1.4.2.tar.gz cd uwsgi-1.4.2 python setup.py build make mv uwsgi /usr/bin //将编译好的文件移动到此处
三、安装bottle四、安装 cx_orcale