今天在termux上門安裝nginx
pkg install nginx
第二步切換模擬root權限
tsu
第三步,重新掛載,獲取讀寫權限(不確定是不是必要的)
mount -o remount,rw /system
第四步,測試運行nginx(在模擬root權限下,-t是測試的意思)
nginx -t
然後出現了錯誤
nginx: the configuration file /data/data/com.termux/files/usr/etc/nginx/nginx.conf syntax is ok
nginx: [emerg] getgrnam("nogroup") failed (2: No such file or directory)
nginx: configuration file /data/data/com.termux/files/usr/etc/nginx/nginx.conf test failed
第五步,進去返回信息中的配置文件的路徑,修改配置文件
vim /data/data/com.termux/files/usr/etc/nginx/nginx.conf
把第一行
#user nobody;
去掉註釋,修改成
user root;
root 表示運行的用戶,如果不修改會因爲不一致而導致在訪問的時候報 403
然後再運行nginx -t就顯示成功了
第六步,開啓nginx (默認是8080)
nginx
重啓nginx的命令
killall nginx
nginx