首页 技术 正文
技术 2022年11月23日
0 收藏 729 点赞 4,592 浏览 1361 个字

1.1 安装Nginx

$sudo apt-get install nginx

  

Ubuntu安装之后的文件结构大致为:

所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下

  程序文件在/usr/sbin/nginx

  日志放在了/var/log/nginx中

  并已经在/etc/init.d/下创建了启动脚本nginx

  默认的虚拟主机的目录设置在了/var/www/nginx-default (有的版本 默认的虚拟主机的目录设置在了/var/www, 请参考/etc/nginx/sites-available里的配置)

1.2 启动Nginx

$sudo /etc/init.d/nginx start

<!–
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.s2 {font-variant-ligatures: no-common-ligatures; color: #34bc26}
–>

[ ok ] Starting nginx (via systemctl): nginx.service.

Nginx的配置文件是 cd /etc/nginx/nginx.conf

vim nginx.conf

cd  /etc/nginx/sites-enabled

vim default

server {
#服务启动时监听的端口
listen 80 default_server;
listen [::]:80 default_server;
#服务启动时文件加载的路径
root /var/www/html/wordpress;
#默认加载的第一个文件
index index.php index.html index.htm index.nginx-debian.html;
#页面访问域名,如果没有域名也可以填写_
server_name www.xiexianbo.xin; location / {
#页面加载失败后所跳转的页面
try_files $uri $uri/ =404;
} #以下配置只服务于php
# 将PHP脚本传递给在127.0.0.1:9000上监听的FastCGI服务器
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
} # 如果Apache的文档为root,则拒绝访问.htaccess文件
location ~ /\.ht {
deny all;
}
}

  

  1. 全局配置文件: /etc/nginx/nginx.conf
  2. 站点的配置文件: /etc/nginx/sites-enabled/default
  3. 错误日志文件 : /var/log/nginx/error.log
  4. 访问日志文件 :/var/log/nginx/access.log

新增touch  +文件名

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,023
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,513
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,361
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,143
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,774
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,853