第一步
安装nginx,网址http://nginx.org/en/download.html
debhttp://nginx.org/packages/ubuntu/trustynginx
deb-srchttp://nginx.org/packages/ubuntu/trustynginx
将上面两行代码复制到/etc/apt/sources.list
root权限下运行:
apt-get update
apt-get install nginx
第二步
启动nginx:
service nginx start
nginx -t
service nginx status
第三步
配置nginx
cd /etc/nginx/conf.d
cp default.confyourweb.com.conf
vimyourweb.com.conf
配置以下信息:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
其中localhost可以换为服务器地址
在server中加入 root/data1/www/www.yourweb.com; 可配置默认打开文件夹
index 设置默认主页
service nginx reload
搞定