sudo apt search nginx | grep ^nginx
查询仓库里面是否有nginx
之后详细见:nginx: Linux packages
跟着步骤安装
安装完后输入
sudo systemctl status nginx
如果是非激活状态
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: inactive (dead)非激活
Docs: https://nginx.org/en/docs/
启动
sudo systemctl start nginx
查询nginx文件所在位置
whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz
usr:软件相关东西
etc:配置
nginx 主配置文件
cat nginx.conf
user (用户) nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice; #日志(错误日志)
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
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;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
安装完之后访问内部防火墙,成功后将ip地址放至浏览器
/etc/nginx/conf.d
curl localhost