sudo cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.orin
sudo nano /usr/local/nginx/conf/nginx.conf
nginx.conf:
user eric;
worker_processes 5;
error_log /var/log/nginx/error.log warn;
#pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1k;
gzip_buffers 4 8k;
#gzip_http_version 1.1;
gzip_types text/plain text/css text/javascript;
server {
location / {
root /home/eric/nginx;
index index.html;
concat on;
}
location /js/ {
root /home/eric/nginx/jslib;
autoindex on;
concat on;
}
}
}
创建相关目录
eric@ubuntu:~$ mkdir /home/eric/nginx && mkdir /home/eric/nginx/webportal && mkdir /home/eric/nginx/jslib
eric@ubuntu:~$ sudo mkdir /var/log/nginx/
eric@ubuntu:~$ sudo chown eric:eric /var/log/nginx
eric@ubuntu:~$ sudo /usr/local/nginx/sbin/nginx -s reload
编辑相关测试文件
eric@ubuntu:~/webportal$ nano /home/eric/nginx/webportal/index.html
eric@ubuntu:~/jslib$ nano /home/eric/jslib/js/plus.js
index.html
<html>
<head>
<!-- <script type="text/javascript" src="/js/plus.js"></script>
<script type="text/javascript" src="/js/minus.js"></script>
<script type="text/javascript" src="/js/multiply.js"></script>
-->
<script type="text/javascript" src="/js/??plus.js,minus.js,multiply.js"></script>
</head>
<body>
<h1>hello world</h1>
<div id="x1"/>
<script type="text/javascript">
var x1 = document.getElementById("x1");
x1.textContent=plus(1,1)+" "+minus(20,10)+" "+multiply(2,3.14);
</script>
</body>
</html>
plus.js
function plus (a,b) {
return a+b;
}
minus.js
function minus(a,b) {
return a-b;
}
multiply.js
function multiply(a,b) {
return a*b;
}
favicon.ico(在线制作工具:http://www.favicon.cc/)
eric@ubuntu:~/webportal$ wget https://github.com/feuyeux/meridians/raw/master/picture/favicon.ico
--2013-01-20 16:59:26-- https://github.com/feuyeux/meridians/raw/master/picture/favicon.ico
Resolving github.com (github.com)... 207.97.227.239
Connecting to github.com (github.com)|207.97.227.239|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.github.com/feuyeux/meridians/master/picture/favicon.ico [following]
--2013-01-20 16:59:28-- https://raw.github.com/feuyeux/meridians/master/picture/favicon.ico
Resolving raw.github.com (raw.github.com)... 207.97.227.243
Connecting to raw.github.com (raw.github.com)|207.97.227.243|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 198 [image/vnd.microsoft.icon]
Saving to: `favicon.ico'
100%[=======================================================================================================================================>] 198 --.-K/s in 0s
2013-01-20 16:59:29 (16.3 MB/s) - `favicon.ico' saved [198/198]
查看日志
eric@ubuntu:~/webportal$ sudo rm /var/log/nginx/*
测试页面:
hello world
2 10 6.28