web服务配置说明
nginx配置
nginx.conf
# wap的php upstream
upstream yohobuy {
# eg: 10.66.1.2:8080 weight=6 max_fails=2 fail_timeout=5s;
...
}
# pc的php upstream
upstream yohobuy-pc {
# eg: 10.66.1.2:8080 weight=6 max_fails=2 fail_timeout=5s;
...
}
# node pc upstream
upstream yohobuy-node {
...
}
# node wap upstream
upstream yohobuywap-node {
...
}
# old wap的代理
upstream yohobuy_idc {
server 172.31.55.207:80 weight=6 max_fails=2 fail_timeout=30s;
}
# old pc的代理
upstream yohobuy-old-www {
server 172.31.55.70:80 weight=3 max_fails=2 fail_timeout=5s;
server 172.31.55.71:80 weight=3 max_fails=2 fail_timeout=5s;
}
# old huodong.yohobuy.com upstream
upstream yohobuy-old-huodong {
server 172.31.55.207:80 weight=3 max_fails=2 fail_timeout=5s;
server 172.31.55.107:80 weight=6 max_fails=2 fail_timeout=5s;
}
# PC 支付代理
upstream yoho_service {
server service.yoho.cn;
}
# 联盟代理
upstream unionapi{
server 172.31.16.99:8088;
}
# yas采集系统https代理
upstream yohobuy_analytics {
server analytics.yhurl.com;
}
# WAP的 vhosts的配置
include vhosts/yohobuywap.conf;
# PC的 vhosts的配置
include vhosts/yohobuypc.conf;
# 建议废弃
include vhosts/login.m.yohobuy.com.conf;
}
vhosts/yohobuywap.conf
# 80 m.yohobuy.com 配置
server
{
listen 80;
server_name m.yohobuy.com nginx1.m.yohobuy.com;
...
}
# 443 m.yohobuy.com 配置
server
{
listen 443;
server_name m.yohobuy.com;
}
# 80 *.m.yohobuy.com
server
{
listen 80;
server_name *.m.yohobuy.com;
}
# 443 *.m.yohobuy.com
server
{
listen 443;
server_name *.m.yohobuy.com;
}
# 单独 guang.m.yohobuy.com 80
# 单独 cuxiao.m.yohobuy.com 80
# 单独 analytics.m.yohobuy.com 80 443
vhosts/yohobuypc.conf
server
{
listen 80;
server_name www.yohobuy.com *.yohobuy.com;
}
server
{
listen 443;
server_name www.yohobuy.com *.yohobuy.com;
}
# 单独 admin.yohobuy.com union.yohobuy.com 80
# 单独 huodong.yohobuy.com 80 443
# 单独 analytics.m.yohobuy.com 80 443
vhosts/location/yohobuypc_node.conf
这个文件会随着node的功能增多而增加location
整改意见: 把
~* /special_(\d+)_(.*)\.html$
放到对应的location下 80 或者 443 跳转 将 301加在最上面 单独 80访问的location 整理到单独的vhosts文件
apache配置
mod_php方式方式运行PHPweb服务
httpd.conf
Listen 127.0.0.1:8080
Include conf/extra/yohobuy.conf
Include conf/extra/yohobuy_pc.conf
yohobuy.conf
<VirtualHost *:8080>
ServerAdmin root@localhost
CustomLog "/Data/logs/apache/yohobuy_access.log" combined
ErrorLog "/Data/logs/apache/error.huodong.m.yohobuy.com.log"
ServerName huodong.m.yohobuy.com
DocumentRoot "/Data/PE/yohobuy_H5/yohobuy/huodong.m.yohobuy.com/public"
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.gif|\.png|\.jpg|\.jpeg|\.svg|\.woff|\.eot|\.ttf)$
RewriteRule ^/(.+)$ /index.php [L]
<Directory />
LimitRequestBody 10485760
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin root@localhost
CustomLog "/Data/logs/apache/yohobuy_access.log" combined
ErrorLog "/Data/logs/apache/yohobuy_error.log"
ServerName mtesth5.yohobuy.com
ServerAlias *.mtesth5.yohobuy.com
ServerAlias *.m.yohobuy.com
ServerAlias m.yohobuy.com
ServerAlias php1.m.yohobuy.com
DocumentRoot "/Data/PE/yohobuy_H5/yohobuy/m.yohobuy.com/public/"
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.gif|\.png|\.jpg|\.jpeg|\.svg|\.woff|\.eot|\.ttf)$
RewriteRule /home /index.php [L]
RewriteRule ^/(.+)$ /index.php [L]
<Directory />
LimitRequestBody 10485760
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
PHP 应用
缓存配置
memcached缓存配置(/yohobuy/m.yohobuy.com/configs/core/cache.production.config.ini
)
[memcached]
master.hosts=memcache1.yohoops.org:12111,memcache2.yohoops.org:12111,memcache3.yohoops.org:12111
slave.hosts=memcache1.yohoops.org:12112,memcache2.yohoops.org:12112,memcache3.yohoops.org:12112
session.hosts=memcache1.yohoops.org:12111,memcache2.yohoops.org:12111,memcache3.yohoops.org:12111
应用配置
/yohobuy/m.yohobuy.com/configs/core/application.production.ini
...
;模板预编译目录,该目录需要有读写权限
application.template.compile = ROOT_PATH "/compile/m.yohobuy.com"
...
接口配置
<?php
use Yaf\Application;
define('SITE_MAIN', '//m.yohobuy.com'); // 网站主域名
define('OLD_MAIN', '//m.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.yohobuy.com'); // COOKIE作用域
define('SUB_DOMAIN', '.m.yohobuy.com'); // 子域名后缀
define('USE_CACHE', true); // 缓存的开关
define('APPLICATION_PATH', dirname(__DIR__)); // 应用目录
define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); // 根目录
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production');
define('API_URL', 'http://api.yoho.yohoops.org/');
define('SERVICE_URL', 'http://service.yoho.yohoops.org/');
define('YOHOBUY_URL', 'http://www.yohobuy.com/');
define('SERVICE_NOTIFY', 'http://service.yoho.cn/');
$application = new Application(APPLICATION_PATH . '/configs/application.production.ini');
$application->bootstrap()->run();
node 应用
系统配置
yohobuywap-node/config/common.js
/**
* 系统配置
*
* @author hbomb qiqi.zhou@yoho.cn
* @date 2016/05/06
*/
const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
module.exports = {
app: 'h5',
appVersion: '4.6.0', // 调用api的版本
port: 6001,
siteUrl: '//m.yohobuy.com',
domains: {
api: 'http://devapi.yoho.cn:58078/',
service: 'http://devservice.yoho.cn:58077/'
},
useOneapm: false,
useCache: false,
memcache: {
master: ['192.168.102.161:11213'],
slave: ['192.168.102.161:11213'],
session: ['192.168.102.161:11213'],
timeout: 1000,
retries: 0
},
loggers: {
infoFile: {
name: 'info',
level: 'info',
filename: 'logs/info.log'
},
errorFile: {
name: 'error',
level: 'error',
filename: 'logs/error.log',
handleExceptions: true
},
udp: { // send by udp
level: 'debug', // logger level
host: '192.168.102.162', // influxdb host
port: '4444' // influxdb port
},
console: {
level: 'debug',
colorize: 'all',
prettyPrint: true
}
},
thirdLogin: {
wechat: {
appID: 'wx75e5a7c0c88e45c2',
appSecret: 'ce21ae4a3f93852279175a167e54509b'
}
}
};
if (isProduction) {
Object.assign(module.exports, {
appName: 'm.yohobuy.com',
domains: {
api: 'http://api.yoho.yohoops.org/',
service: 'http://service.yoho.yohoops.org/'
},
memcache: {
master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'],
session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
timeout: 1000,
retries: 0
},
useOneapm: true,
useCache: true
});
} else if (isTest) {
Object.assign(module.exports, {
appName: 'm.yohobuy.com for test',
domains: {
api: 'http://testapi.yoho.cn:28078/',
service: 'http://testservice.yoho.cn:28077/'
},
memcache: {
master: ['127.0.0.1:12111'],
slave: ['127.0.0.1:12112'],
session: ['127.0.0.1:12111'],
timeout: 1000,
retries: 0
},
useOneapm: true,
useCache: true
});
}