一,首先搭建nginx服务器:
1.1,选定源码目录
选定目录 /usr/local/lwc
cd /usr/local/lwc
1.2,安装PCRE库
cd /usr/local/lwc
到www.pcre.org?下载pcre-8.37.tar.gz, 然后拷贝到/usr/local/HLS
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.37
./configure
make
make install
可以直接 yum install pcre
1.3,安装zlib库
cd /usr/local/lwc
到www.zlib.net?下载zlib-1.2.8.tar.gz, 然后拷贝到/usr/local/HLS
tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
./configure
make
make install?
可以直接 yum install zlib
1.4,安装SSL?
cd /usr/local/lwc
到www.openssl.org下载openssl-1.0.2g.tar.gz, 然后拷贝到/usr/local/lwc
tar -zxvf openssl-1.0.2g.tar.gz
./config
make
make install
可以直接 yum install openssl
1.5,安装nginx
tar -zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure --prefix=/usr/local/nginx
make
make install
1.6,启动
确保系统的80端口没被其他程序占用,
/usr/local/nginx/sbin/nginx
检查是否启动成功:
netstat -ano|grep 80 有结果输入说明启动成功
然后打开浏览器访问此机器的ip地址即可,如果浏览器出现?Welcome to nginx! 则表示?Nginx 已经安装并运行成功。
1.7,重启
/usr/local/nginx/sbin/nginx -s reload
/usr/local/nginx/sbin/nginx -s reload
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
注意:
一, Nginx 处理跨域问题 (2014-07-30 10:09:19)转载▼
标签: it 分类: linux
在Nginx location 里加上如下代码可以解决js 请求跨域问题
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
return 200;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
二, 将crossdomain.xml放到/usr/local/nginx/html目录下.
1.1,选定源码目录
选定目录 /usr/local/lwc
cd /usr/local/lwc
1.2,安装PCRE库
cd /usr/local/lwc
到www.pcre.org?下载pcre-8.37.tar.gz, 然后拷贝到/usr/local/HLS
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.37
./configure
make
make install
可以直接 yum install pcre
1.3,安装zlib库
cd /usr/local/lwc
到www.zlib.net?下载zlib-1.2.8.tar.gz, 然后拷贝到/usr/local/HLS
tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
./configure
make
make install?
可以直接 yum install zlib
1.4,安装SSL?
cd /usr/local/lwc
到www.openssl.org下载openssl-1.0.2g.tar.gz, 然后拷贝到/usr/local/lwc
tar -zxvf openssl-1.0.2g.tar.gz
./config
make
make install
可以直接 yum install openssl
1.5,安装nginx
tar -zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure --prefix=/usr/local/nginx
make
make install
1.6,启动
确保系统的80端口没被其他程序占用,
/usr/local/nginx/sbin/nginx
检查是否启动成功:
netstat -ano|grep 80 有结果输入说明启动成功
然后打开浏览器访问此机器的ip地址即可,如果浏览器出现?Welcome to nginx! 则表示?Nginx 已经安装并运行成功。
1.7,重启
/usr/local/nginx/sbin/nginx -s reload
/usr/local/nginx/sbin/nginx -s reload
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
注意:
一, Nginx 处理跨域问题 (2014-07-30 10:09:19)转载▼
标签: it 分类: linux
在Nginx location 里加上如下代码可以解决js 请求跨域问题
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
return 200;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
二, 将crossdomain.xml放到/usr/local/nginx/html目录下.