1. 安装Apahce, PHP, MySQL以及php连接mysql库的组件
#yum -y install httpd php mysql mysql-server php-mysql     //这里“-y”参数表示静默安装,不会出现提示及交互

2. 安装apache扩展
#yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

3. 安装php的常用扩展
#yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

4. 安装MySQL的扩展
#yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

5. 配置开机启动服务
#/sbin/chkconfig httpd on     [设置apache  httpd服务开机启动]

安装nginx
yum install nginx
iptables -I INPUT  -p tcp --dport 80 -j ACCEPT
 
 
关于目录
tomcat6相关
配置目录 /etc/tomcat6
工程目录 /var/lib/tomcat6
 
apache的配置文件是/etc/httpd/conf下
modules放在/usr/lib/httpd下
项目目录 /var/www
 
php的配置文件在/etc/php.d/下 和/etc/php.ini
php的modules放在/usr/lib/php/modules下
 
nginx 
配置/etc/nginx
1.备份 /etc/nginx/conf.d/default.conf
编辑/etc/nginx/conf.d/default.conf
upstream tomcat{
    server localhost:8081;
}
server {
    listen      80;
    server_name     tom.yourdomain.cn;
    location / {
        proxy_pass      http://tomcat;
        proxy_redirect      off;
        proxy_set_header    Host $host;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    }
 
}
 
upstream apache_index{
        server localhost:9080;
}
server {
        listen          80;
        server_name     www.yourdomain.cn;
        location / {
                proxy_pass              http://apache_index;
                proxy_redirect          off;
                proxy_set_header        Host $host;
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }
 
}
 
upstream apache_blog{
        server localhost:9090;
}
server {
        listen          80;
        server_name     blog.yourdomain.cn;
        location / {
                proxy_pass              http://apache_blog;
                proxy_redirect          off;
                proxy_set_header        Host $host;
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }
 
}
upstream apache_bbs{
        server localhost:9095;
}
server {
        listen          80;
        server_name     bbs.yourdomain.cn;
        location / {
                proxy_pass              http://apache_bbs;
                proxy_redirect          off;
                proxy_set_header        Host $host;
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }
 
}
 
 
tomcat配置
1./etc/tomcat6/server.xml
端口 <Connector port="8081" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
默认项目
<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="ContactSys" reloadable="true" debug="0" privileged="true">
        </Context>
 
 
apache
1.备份 /etc/httpd/conf/httpd.conf
停止监听80

Listen 9080
Listen 9090
Listen 9095

 
NameVirtualHost localhost:9080
 
<VirtualHost localhost:9080>
    #ServerAdmin yourname@yourdomain.cn
    DocumentRoot "/home/username/www/index"
    #ServerName blog.yourdomain.cn 
    ErrorLog "/home/username/www/errors/index-error.log"
    CustomLog "/home/username/www/errors/index-access.log" common
        #<Directory />
        #       Options FollowSymLinks
        #       AllowOverride None
        #</Directory>
        <Directory "/home/username/www/index/">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride none
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
NameVirtualHost localhost:9090
 
<VirtualHost localhost:9090>
    #ServerAdmin yourname@yourdomain.cn
    DocumentRoot "/home/username/www/blog"
    #ServerName blog.yourdomain.cn 
    ErrorLog "/home/username/www/errors/blog-error.log"
    CustomLog "/home/username/www/errors/blog-access.log" common
        #<Directory />
        #       Options FollowSymLinks
        #       AllowOverride None
        #</Directory>
        <Directory "/home/username/www/blog/">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride none
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
 
NameVirtualHost localhost:9095
 
<VirtualHost localhost:9095>
    #ServerAdmin yourname@yourdomain.cn
    DocumentRoot "/home/username/www/bbs"
    #ServerName blog.yourdomain.cn 
    ErrorLog "/home/username/www/errors/bbs-error.log"
    CustomLog "/home/username/www/errors/bbs-access.log" common
        #<Directory />
        #       Options FollowSymLinks
        #       AllowOverride None
        #</Directory>
        <Directory "/home/username/www/bbs/">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride none
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
2.DocumentRoot  设置权限 777 chmod 777 -R  D

腾讯云Centos下Nginx反向代理Apache+Tomcat的更多相关文章

  1. Nginx反向代理实现Tomcat负载均衡

    这篇短文主要介绍Tomcat的集群和用Nginx反向代理实现Tomcat负载均衡. 1.首先需要对一些知识点进行扫盲(对自己进行扫盲,囧): 集群(Cluster) 简单来说就是用N台服务器构成一个松 ...

  2. nginx 反向代理 apache 服务

    反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客户端,此时 ...

  3. Nginx反向代理实现Tomcat+Jpress和halo

    一.利用Nginx反向代理Jpress+Tomcat 1.环境准备 服务器 IP地址 作用 系统版本 Proxy代理服务器 10.0.0.101 负载均衡Nginx Web服务器 Ubuntu2004 ...

  4. Linux下nginx反向代理服务器安装与配置实操

    1.我们只要实现访问nginx服务器能跳转到不同的服务器即可,我本地测试是这样的, 在nginx服务器里面搭建了2个tomcat,2个tomcat端口分别是8080和8081,当我输入我nginx服务 ...

  5. Linux 下 Nginx 反向代理 负载均衡配置

    转载请注明出处:http://blog.csdn.net/smartbetter/article/details/52036350 上一篇分享了 Nginx + JDK + Tomcat + MySQ ...

  6. Nginx反向代理实现Tomcat多个应用80端口访问

    应用背景 一般我们在开发时,一个工程里会有多个Web应用,比如一个前台一个后台,那我们就需要配置2个Tomcat服务器,比如一个是http://localhost:8080,一个是http://loc ...

  7. 【转】Nginx反向代理转发tomcat

    http://blog.csdn.net/mlc1218559742/article/details/53117520 最近刚接触nginx,在网上查阅了相关资料,看到最多的形容nginx的词就是反向 ...

  8. nginx反向代理(proxy_pass)tomcat的过程中,session失效的问题解决

    Nginx反向代理tomcat,很是方便,但是也有些细节的问题需要注意:今天遇到了这样一个问题,tomcat中路径“host/web1”,nginx中直接“host/”代理,这时候session就无法 ...

  9. 腾讯云Centos安装nginx

    使用的是腾讯云主机,选择的镜像如下: Centos7+ 64bit; nginx 1.7.12 1.安装依赖 yum -y install gcc gcc-c++ wget net-tools pcr ...

随机推荐

  1. linux下oracle启动问题

    需要注意的 1.由root用户切换到su oracle 不能启动sqlplus 由root用户切换到su -oracle 可以启动sqlplus 由oracle用户直接登陆也可以启动sqlplus命令 ...

  2. cx_oracle 执行cur.execute(sql)提交数据出现 UnicodeEncodeError: 'ascii' codec can't encode character u'\u2122' in position 170

    还是中文字符的问题, 解决方法见链接:http://www.oracle.com/technetwork/articles/tuininga-cx-oracle-084866.html import ...

  3. win32程序通过LPCREATESTRUCT中的lpCreateParams传递参数给窗口过程函数

    win32窗口程序中如果需要给窗口过程函数传递自定义参数,可以通过LPCREATESTRUCT结构体中的lpCreateParams进行传递. 创建窗口实例函数: m_hWnd = CreateWin ...

  4. css3新增的属性选择器

    使用css选择器,可以实现一个样式对应多个html文档的元素,在{}前面的部分就是"选择器",指明了样式的作用对象. 在CSS中追加了三个属性选择器:[att*=val].[att ...

  5. wget 递归下载整个网站

    wget -r -p -np -k http://xxx.com/xxx -r,  --recursive(递归)          specify recursive download.(指定递归下 ...

  6. OpenGL角轴

    概述 轴旋转 角轴 概述 OpenGL旋转矩阵 旋转角度直接影响OpenGL GL_MODELVIEW矩阵的前三列,准确地说是向左.向上与向前三轴元素.例如,如果一沿X轴的单位向量(1,0,0)与任一 ...

  7. AT Tool --- android手机发送at指令

    之前网上也有一款类似的软件,估计是华为内部人员开发的,不过很变态,不但只支持华为的几款手机,而且只能发一条AT命令,然后就不让你发了:所以很气愤,今天花了一天时间自己写了这么款程序,而且是支持所有An ...

  8. mongoDB之Pipeline Aggregation Stages

    原文链接:https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/ 管道聚合 $project Reshapes ...

  9. Android应用开发-数据存储和界面展现(一)(重制版)

    常见布局 相对布局(RelativeLayout) 相对布局下控件默认位置都是左上角(左对齐.顶部对齐父元素),控件之间可以重叠 可以相对于父元素上下左右对齐,相对于父元素水平居中.竖直居中.水平竖直 ...

  10. Maven项目java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger报错

    本文转载自:http://www.javaweb1024.com/info/894.jspx maven管理的项目,里面已经引入了log4j的包 maven引入如下: <dependency&g ...