启动时候若显示端口80被占用: Starting nginx: [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use),修改文件:
/etc/nginx/sites-available/default,去掉 listen 前面的 # 号 , # 号在该文件里是注释的意思 , 并且把 listen 后面的 80 端口号改为自己的端口,访问是需要添加端口号 。(安装完后如出现403错误,那可能是nginx配置文件里的网站路径不正确)
文件default里面的配置信息为:
### You should look at the following URL's in order to grasp a solid understanding# of Nginx configuration files in order to fully unleash the power of Nginx.# https://www.nginx.com/resources/wiki/start/# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/# https://wiki.debian.org/Nginx/DirectoryStructure## In most cases, administrators will remove this file from sites-enabled/ and# leave it as reference inside of sites-available where it will continue to be# updated by the nginx packaging team.## This file will automatically load configuration files provided by other# applications, such as Drupal or WordPress. These applications will be made# available underneath a path with that package name, such as /drupal8.## Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.### Default server configuration#server {listen 80 default_server;listen [::]:80 default_server;# SSL configuration## listen 443 ssl default_server;# listen [::]:443 ssl default_server;## Note: You should disable gzip for SSL traffic.# See: https://bugs.debian.org/773332## Read up on ssl_ciphers to ensure a secure configuration.# See: https://bugs.debian.org/765782## Self signed certs generated by the ssl-cert package# Don't use them in a production server!## include snippets/snakeoil.conf;root /var/www/html;# Add index.php to the list if you are using PHPindex index.html index.htm index.nginx-debian.html;server_name _;location / {# First attempt to serve request as file, then# as directory, then fall back to displaying a 404.try_files $uri $uri/ =404;}# pass PHP scripts to FastCGI server"default" [readonly] 91 lines, 2416 characters5、管理nginx
$ sudo systemctl status nginx$ sudo systemctl start nginx$ sudo systemctl stop nginx$ sudo systemctl restart nginx$ sudo systemctl reload nginx$ sudo systemctl enable nginx$ sudo systemctl disable nginx6、查看nginx配置文件
$ nginx -t7、设置防火墙
$ sudo ufw allow 'Nginx Full'$ sudo ufw status
【Linux安装调试Nginx】
推荐阅读
- linux安装安全狗
- PhotoShop 2021 九月最新版本安装使用测试
- 智能电视如何利用U盘安装第三方应用?附小程序密码
- linux高性能服务器开发十大必须掌握的核心技术
- linux之chroot命令
- 制作网线不求人,内行人教你徒手安装水晶头,省心又省力
- Linux中su,sudo,sudo su,sudo -i命令的使用和区别
- 最强的漏洞扫描工具Nessus安装教程
- win10win10双系统怎么装,window10双系统怎么安装-
- 如何安装打印机驱动程序
