centos安装nginx配置webpy

一、安装nginx
1、sudo yum install nginx

Loaded plugins: fastestmirror, security
Determining fastest mirrors
 * rpmforge: mirror.oscc.org.my
base                                                                                                 | 3.7 kB     00:00     
extras                                                                                               | 3.4 kB     00:00     
rpmforge                                                                                             | 1.9 kB     00:00     
rpmforge/primary_db                                                                                  | 2.7 MB     00:08     
updates                                                                                              | 3.4 kB     00:00     
updates/primary_db                                                                                   | 3.2 MB     00:16     
Setting up Install Process
No package nginx available.
Error: Nothing to do

出错了,看来要先下载,不如apt-get能直接安装

2、下载
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

--2014-06-16 16:32:34--  http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
正在解析主机 nginx.org... 206.251.255.63
正在连接 nginx.org|206.251.255.63|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:4311 (4.2K) [application/x-redhat-package-manager]
正在保存至: “nginx-release-centos-6-0.el6.ngx.noarch.rpm”

100%[==================================================================================>] 4,311       17.9K/s   in 0.2s

2014-06-16 16:32:35 (17.9 KB/s) - 已保存 “nginx-release-centos-6-0.el6.ngx.noarch.rpm” [4311/4311])

3、解包
sudo rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm

4、再次执行安装
sudo yum install nginx

nginx的几个默认目录

whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx

1 配置所在目录:/etc/nginx/
2 PID目录:/var/run/nginx.pid
3 错误日志:/var/log/nginx/error.log
4 访问日志:/var/log/nginx/access.log
5 默认站点目录:/usr/share/nginx/html

然后随便找台内网机器访问一下nginx所在IP,如果出现nginx信息页面则安装成功。
如果访问不了,可能有防火墙问题,参看其它网页:http://blog.163.com/weiwenjuan_bj/blog/static/140350336201342611253264/

二、uwsgi
wget http://projects.unbit.it/downloads/uwsgi-1.4.2.tar.gz

在这过程中发现python是2.6,不确定会有什么问题,还是安装2.7吧
sudo wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 --no-check-certificate
sudo tar -jxvf Python-2.7.3.tar.bz2  
cd Python-2.7.3
./configure
怎么都不成功,发现出错
configure: error: cannot find sources (Include/object.h) in . or ..

装gcc,试一试
yum -y install gcc

还是不行,用find / -name "object.h"发现权限不够,好吧,不是gcc的事,提升权限吧
sudo ./configure
sudo make all
sudo make install  
sudo make clean  
sudo make distclean 
/usr/local/bin/python2.7 -V 
重新链接到2.7
sudo mv /usr/bin/python /usr/bin/python2.6.6
sudo ln -s /usr/local/bin/python2.7 /usr/bin/python

解决系统 Python 软链接指向 Python2.7 版本后,因为yum是不兼容 Python 2.7的,所以yum不能正常工作,我们需要指定 yum 的Python版本
[plain] view plaincopy
#vi /usr/bin/yum  
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6.6

安装setuptools
sudo wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea --no-check-certificate
sudo sh setuptools-0.6c11-py2.7.egg
又出错了
setuptools-0.6c11-py2.7.egg: line 3: exec: python2.7: not found
那建立个链接试试
sudo ln -s /usr/local/bin/python2.7 /usr/bin/python2.7
再执行成功了

现在可以root执行以下命令了
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
cd uwsgi-1.4.2
python setup.py build
make
mv uwsgi /usr/bin       //将编译好的文件移动到此处
sudo cp uwsgi /usr/bin/

安装webpy,各种方法没安装成功,直接在webpy.org上用git下载
git clone git://github.com/webpy/webpy.git
sudo python setup.py install
居然成功了

三、配置nginx
在nginx.conf最后一行加入:
include /etc/nginx/sites-enabled/*;

在/etc/nginx中建立目录sites-available和sites-enabled,配置文件放在sites-available中,在sites-enabled中建立对应的链接即可。
配置文件如下:
server {
  # Change this if you want to serve your application on another port
  listen 80;

# Replace this with your domain name
  server_name 172.28.14.170;

# You can use virtual directory like '/apps/' here, but remember that
  # this should match 'urls' defined in your web.py application file
  location / {
    include uwsgi_params;

# This should match the 'socket' entry in your uwsgi configuration
    uwsgi_pass unix:///tmp/uwsgi_vpoker.sock;
    #uwsgi_pass 127.0.0.1:3031;

# This is the absolute path to the folder containing your application
    uwsgi_param UWSGI_CHDIR /var/www/apps/texas;

# This is actually not necessary for our simple application,
    # but you may need this in future
    uwsgi_param UWSGI_PYHOME /var/www/apps/texas;

# This is the name of your application file, minus the '.py' extension
    uwsgi_param UWSGI_SCRIPT hello;
  }

location ^~ /static/ {
    alias /var/www/apps/texas/static/;
  }
}

sudo /usr/sbin/nginx
sudo uwsgi -s 127.0.0.1:3031 --wsgi-file /var/www/apps/texas/test.py
注意test.py最下方调用需要用:
application = app.wsgifunc()

如果端口被nginx占用,执行:
sudo killall -9 nginx
被其它进程占用,则要kill

四、配置自动启动服务
在init.d下配置nginx和uwsgi脚本,具体脚本去查吧

sudo chmod +x /etc/init.d/nginx
sudo chmod +x /etc/init.d/uwsgi

发现没有start-stop-daemon,原来这也是个要安装的东西
wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
tar zxf 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 
sudo cp start-stop-daemon /usr/local/bin/start-stop-daemon

uwsgi还是没有跑通!!!!!!!!!

五:python需要库
安装redis库
sudo wget https://pypi.python.org/packages/source/r/redis/redis-2.10.1.tar.gz --no-check-certificate
tar...
cd...
python setup.py install

安装Mysql-python
sudo wget http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
tar -zxvf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3

Mysql
查看是否安装过
rpm -qa mysql
看机器32位还是64位
file /sbin/init
uname -a

安装MySQL真是很麻烦,见此:http://www.2cto.com/database/201209/156148.html
yum -y install gcc libxml2-dev curl screen libpng12-dev autoconf libpcre3-dev make bzip2 libevent-dev patch libjpeg62-dev libcurl4-openssl-dev libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz

wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
tar zxvf cmake-2.8.5.tar.gz
cd cmake-2.8.5
./bootstrap 
make
make install
cmake –version

rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
yum install libmysqlclient15 --enablerepo=webtatic
yum install mysql55 mysql55-server --enablerepo=webtatic
装5.5总有冲突,先装个5.1吧
yum install mysql51 mysql51-server --enablerepo=webtatic

service mysqld start
mysql_upgrade

上面装的MySQLdb有问题,用yum安装:
yum install MySQL-python
找不到文件出错,可能是没安装开发环境吧
sudo yum install python-devel mysql-devel

删除有冲突安装:
sudo yum -y remove mysql51w-libs-5.1.73*
sudo yum -y remove mysql-libs-5.1.73*

setuptools
wget --no-check-certificate  http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxf setuptools-0.6c11.tar.gz && cd setuptools-0.6c11
python setup.py build
python setup.py install

好像安装的mysql51w有问题,为什么有w呢?折腾来折腾去,不用这个源吧
sudo yum -y remove mysql51w-libs-5.1.73*
sudo yum install mysql mysql-server

mysql终于启动了,这都需要sudo,习惯了不用。。。
sudo service mysqld start

但是MySQLdb还是有问题,引入时又报错:
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: No module named _mysql
这个用sudo python进去就可以了,权限啊权限啊

sudo usermod -g root nginx

sudo nohup python webpy-texas.py &

centos安装nginx配置webpy相关推荐

  1. centos 安装、配置metis

    centos 安装.配置metis 1.安装依赖包 #安装python-pip curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # 下载 ...

  2. centos安装和配置masakari(stein版本)

    centos安装和配置masakari(stein版本) 一.基本环境参数 环境:centos7.6 opentack-masakari版本stein python2.7.5/python3.6,都是 ...

  3. CentOS安装与配置LNMP

    本文PDF文档下载:http://www.coderblog.cn/doc/Install_and_config_LNMP_under_CentOS.pdf 本文EPUB文档下载:http://www ...

  4. php5.3+for+linux,Centos 安装 nginx + php5.3

    Centos 安装 nginx + php5.3,点开查看详情. #查看系统版本信息cat /etc/issue uname -a#设置时区 rm -rf /etc/localtime ln -s / ...

  5. Centos 安装FTP配置目录权限,iptables设置ftp服务

    Centos 安装FTP配置目录权限,iptables设置ftp服务 2012-07-06 admin Leave a comment Go to comments CentOS 安装vsftpd,设 ...

  6. centos安装nginx详细教程及配置虚拟机域名重定向

    转载自 https://www.cnblogs.com/taiyonghai/p/6728707.html 一.Nginx简介 Nginx是一个web服务器也可以用来做负载均衡及反向代理使用,目前使用 ...

  7. Centos 7离线安装Nginx 配置负载均衡集群

    场景 项目中有三台应用服务器,系统为Centos 7 ,应用地址分别为: 192.168.198.229:8080 192.168.198.230:8080 192.168.198.231:8080 ...

  8. Centos安装、配置nginx

    参考 https://www.cnblogs.com/jeffhong99/p/11362361.html 安装nginx [root@localhost~]# yum -y install ngin ...

  9. centos安装nginx,配置负载均衡

     1.安装nginx 安装教程,参照:http://mp.weixin.qq.com/s/RVaRlRpHqZRjCaXGmOlfKw 2.反向代理的配置 修改部署目录下conf子目录的nginx ...

  10. CentOS 安装nginx及配置

    一.去官网下载ngnix安装包 官网 : http://nginx.org/ 二.安装nginx前需要安装的依赖环境 2.1 安装安装gcc gcc-c++(如新环境,未安装请先安装) yum ins ...

最新文章

  1. Attention的相关工作
  2. 装Linux后分区丢失,找到了linux分区顺序错乱修复方法
  3. javascript调用dll_Blazor条码识别:Web中运行C#和JavaScript
  4. php繁体输出,PHP输出控制功能在简繁体转换中的应用
  5. CentOS图形界面下如何安装Eclipse和使用maven
  6. Linux C语言在用户态实现一个低时延通知(eventfd)+轮询(无锁队列ring)机制的消息队列
  7. html 读取 vb,VB编程:vb读取textbox控件某一行的方法
  8. 七月最后一波!微软专属内推码等你来抢
  9. 判断请求是通过点击链接还是直接输入网址
  10. c语言80c51控制系统设计,89C51单片机的步进电动机控制系统设计
  11. 从零开始学Java自己利用接口和集合框架做的简单图书管理系统
  12. 今天吃什么随机网页_灵魂拷问:今天在西昌你想吃什么?
  13. 学校考场重要组成部分ntp子母钟(时间同步系统)方案
  14. 基于Java Servlet图片服务器
  15. 从猎豹移动到瑞幸咖啡,看中国企业在海外的信誉破产
  16. 人工智能+大数据+云计算
  17. CentOS7 mysql8.0 国内镜像源安装
  18. 协同过滤推荐之基于近邻协同过滤(一)
  19. 使用DXperience开发Asp.net2.0程序——序
  20. cf Sonya and Robots

热门文章

  1. java项目第12期-淘客系统源码(安卓+IOS+java后端)【毕业设计】
  2. 随机生成游戏建筑物的算法
  3. 纠正英语语法错误---Grammarly安装
  4. 星际争霸、魔兽争霸3、红色警戒之完全对比
  5. 葛冬冬斯坦福专业_比较预测模型的表现冬冬与有马
  6. html制作动态3d图片,如何制作3D动态图片?
  7. 关键词查找器,关键词搜索查询挖掘
  8. 微软ime日文输入法在假名输入模式下怎么快速输入英文
  9. 使用java实现简单推箱子游戏
  10. 软件工程阶段性总结(一)——概述