最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
centos下Nginx虚拟主机配置步骤
时间:2022-06-30 21:21:31 编辑:袖梨 来源:一聚教程网
前期准备工作:
[root@lnmp ~]# mkdir /usr/local/nginx/conf/extra -p #其中/usr/local/nginx/conf是nginx的默认配置文件
[root@lnmp ~]# mdkir /var/site/www -p #建立网站目录
[root@lnmp ~]# mdkir /var/site/bbs #bbs目录
[root@lnmp ~]# cd /usr/local/nginx/conf/
[root@lnmp conf]# egrep -v "#|^$" /usr/local/nginx/conf/nginx.conf >extra/nginx-www.conf #空行、注释排除,且放置在/var/local/nginx/conf/extra目录下的nginx-www.conf
[root@lnmp conf]# egrep -v "#|^$" /usr/local/nginx/conf/nginx.conf >nginx-default.conf
[root@lnmp conf]# mv nginx.conf nginx.conf.backup
[root@lnmp conf]# mv nginx-default.conf nginx.conf
nginx主nginx.conf:
[root@lnmp conf]# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
include extra/*.conf; #加载虚拟主机配置文件
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
}
虚拟主机配置:
[root@lnmp conf]# cat extra/nginx-www.conf
server {
listen 80;
server_name www.111com.net;
location / {
root /var/site/www;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/site/www;
}
error_page 404 /404.html;
location = /404.html {
root /var/site/www;
}
location ~ .php$ {
root /var/site/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/site/www$fastcgi_script_name;
include fastcgi.conf;
}
}
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22