概述
其实也就是正常的debian系统安装稳定版的nginx
参考链接
步骤
新建文件夹nginx,随便名字都可以
执行lsb_release -a查看Debian版本号:
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.4 (stretch)
Release: 9.4
Codename: stretch
可知,版本号是9.4,代号是stretch
编辑 /etc/apt/sources.list 添加如下代码
deb http://nginx.org/packages/debian/ codename nginx
deb-src http://nginx.org/packages/debian/ codename nginx
替换 codename 为 stretch
执行 apt-get update 等待update完成
执行 apt-get install nginx安装nginx
遇到的问题
apt-get install nginx之后发现出错,信息如下:
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en abled)
Active: failed (Result: exit-code) since Sat 2018-07-07 07:32:02 UTC; 64ms ag o
Docs: man:nginx(8)
Process: 4566 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code =exited, status=1/FAILURE)
Process: 4563 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
提醒nginx.service工作失败,请运行 systemctl status nginx.service和journalctl -xe查看详情。以下是 systemctl status nginx.service 显示的信息:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2018-07-07 07:32:02 UTC; 3min 37s ago
Docs: man:nginx(8)
Process: 4566 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 4563 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Jul 07 07:32:00 dukeworks nginx[4566]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jul 07 07:32:01 dukeworks nginx[4566]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jul 07 07:32:01 dukeworks nginx[4566]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jul 07 07:32:01 dukeworks nginx[4566]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jul 07 07:32:01 dukeworks nginx[4566]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jul 07 07:32:02 dukeworks nginx[4566]: nginx: [emerg] still could not bind()
Jul 07 07:32:02 dukeworks systemd[1]: nginx.service: Control process exited, code=exited status=1
Jul 07 07:32:02 dukeworks systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jul 07 07:32:02 dukeworks systemd[1]: nginx.service: Unit entered failed state.
Jul 07 07:32:02 dukeworks systemd[1]: nginx.service: Failed with result 'exit-code'.
可以看到就是端口被占用的导致启动失败。
经检查,发现80端口被apache2占用了,这个是之前装Aria2的时候安装的。
所以这个是正常的,暂时不予解决,等真正要用到nginx的时候再改。