linux下nginx安装及简单使⽤教程(⼀)1.使⽤yum安装nginx,如下图。显⽰安装成功。
yum install nginx
2.⾸先我们查看⼀下nginx的版本,yum默认安装的版本是1.12.2
nginx -v
3.启动⼀下nginx看⼀下,没有任何提⽰信息,表明我们启动成功了。
nginx
4.查看⼀下端⼝可知,nginx默认的端⼝号是80端⼝。
netstat -ntlp
5.访问⼀下安装nginx的电脑ip地址,出现以下界⾯表⽰启动成功了。
以下是Nginx的默认路径:
(1) Nginx配置路径:/etc/nginx/
(2) PID⽬录:/var/run/nginx.pid
(3) 错误⽇志:/var/log/nginx/error.log
(4) 访问⽇志:/var/log/nginx/access.log
(5) 默认站点⽬录:/usr/share/nginx/html
6.我们看⼀下nginx的配置⽂件,不知道位置的情况下使⽤find命令检索⼀下电脑find / -f
cat /etc/f
linux离线安装nginx详细教程# For more information on configuration, see:
# * Official English Documentation: /en/docs/
# * Official Russian Documentation: /ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/pes;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See /en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
注:nginx常⽤相关命令
nginx -v #查看版本
nginx #启动命令
nginx -s stop #停⽌
nginx -t #修改完f后检查语法是否正确
nginx -s -reload #重启(修改完配置⽂件可以使⽤此命令重新加载配置⽂件)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论