安装包安装
$sudo apt-get install nginx
$sudo apt-get update
$sudo apt-get upgrade
名称 |
目录 |
配置文件 |
/etc/nginx/nginx.conf |
程序文件 |
/usr/sbin/nginx |
日志 |
/varlog/nginx |
默认虚拟主机 |
/var/www/html |
$sudo /etc/init.d/nginx start
$sudo /etc/init.d/nginx stop
$sudo /etc/init.d/nginx restart
$sudo /etc/init.d/nginx status
lsof -i:80
/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
源代码安装
$cd /usr/local //进入local目录
$wget http://nginx.org/download/nginx-1.2.8.tar.gz // 指定版本在线安装
$tar -zxvf nginx-1.2.8.tar.gz //解压缩
$sudo apt-get install libpcre3 libpcre3-dev zlib1g-dev //安装依赖库
$cd nginx-1.2.8
$./configure
$make
$make install
名称 |
目录 |
配置文件 |
/usr/local/nginx/conf/nginx.conf |
程序文件 |
/usr/local/nginx/sbin/nginx |
日志 |
/var/log/nginx |
默认虚拟主机 |
/var/www/ |
启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
conf配置文件示例
server {
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /var/www/html/statium;
location / {
root /var/www/html/statium;
try_files $uri $uri/ /index.html last;
index index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
网友评论