ubuntu升级软件和安装Nginx

首先看下有没有需要升级的软件

# apt list --upgradable
Listing... Done
linux-generic/focal-updates 5.4.0.60.63 amd64 [upgradable from: 5.4.0.54.57]
linux-headers-generic/focal-updates 5.4.0.60.63 amd64 [upgradable from: 5.4.0.54.57]
linux-image-generic/focal-updates 5.4.0.60.63 amd64 [upgradable from: 5.4.0.54.57]

还好,刚才已经把软件包升级过了,现在只要升级系统就可以。

升级软件包命令

sudo apt-get update 更新源
sudo apt-get upgrade 更新已安装的包

升级系统命令如下

sudo apt-get dist-upgrade 升级系统

然后在看下,都是最新的了。

#apt list --upgradable
Listing... Done
root@MDaliyun ~ # sudo apt update
Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu focal InRelease
Hit:2 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates InRelease
Hit:3 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

下来安装Nginx

安装Nginx

sudo apt install nginx

查看Nginx状态

 sudo systemctl status nginx

root@MDaliyun / # vi /etc/nginx/nginx.conf

编辑 nginx.conf 文件。
找到 server{…},并将 server 大括号中相应的配置信息替换为如下内容。用于取消对 IPv6 地址的监听,同时配置 Nginx,实现与 PHP 的联动。

server {
 listen       80;
 root   /usr/share/nginx/html;
 server_name  localhost;
 #charset koi8-r;
 #access_log  /var/log/nginx/log/host.access.log  main;
 #
 location / {
       index index.php index.html index.htm;
 }
 #error_page  404              /404.html;
 #redirect server error pages to the static page /50x.html
 #
 error_page   500 502 503 504  /50x.html;
 location = /50x.html {
   root   /usr/share/nginx/html;
 }
 #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 #
 location ~ .php$ {
   fastcgi_pass   127.0.0.1:9000;
   fastcgi_index  index.php;
   fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   include        fastcgi_params;
 }
}

参考文档如下
https://www.myfreax.com/how-to-install-nginx-on-ubuntu-18-04/

Leave a Reply

Your email address will not be published. Required fields are marked *