forum.gl-inet.cn

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 6357|回复: 1

[经验分享] AXT1800 编译安装nginx并支持php8搭建web服务器

[复制链接]

4

主题

17

帖子

118

积分

注册会员

Rank: 2

积分
118
发表于 2023-2-26 14:28:52 | 显示全部楼层 |阅读模式
按照https://forum.gl-inet.cn/forum.p ... &extra=page%3D1教程,实际上原版的feeds中就包含了很多额外的插件,但没有放开。

在make编译前,可以执行
./script/feeds update -a
./script/feeds install -a
这样就安装很多外插件,包括php8。
编译选项中新增支持php8,可以选中后把需要的依赖都加上,路径在Languages下,比如cgi、 mysqli等。截图见附件。
本人选项参考:
CONFIG_PACKAGE_php8-mod-ctype=y
CONFIG_PACKAGE_php8-mod-mysqli=y
CONFIG_PACKAGE_php8-mod-mysqlnd=y
CONFIG_PACKAGE_php8-mod-openssl=y
CONFIG_PACKAGE_php8-mod-pdo=y
CONFIG_PACKAGE_php8-mod-pdo-mysql=y
CONFIG_PACKAGE_php8-mod-pdo-sqlite=y
CONFIG_PACKAGE_php8-mod-session=y
CONFIG_PACKAGE_php8-mod-sockets=y
CONFIG_PACKAGE_php8-mod-sqlite3=y
CONFIG_PACKAGE_php8-mod-zip=y

nginx是原生支持的,选项参考:
CONFIG_PACKAGE_luci-nginx=y
CONFIG_PACKAGE_nginx-all-module=y
CONFIG_PACKAGE_nginx-mod-luci=y


编译后,启动AXT1800,在etc/nginx下有nginx.conf文件,
原本的文件没有虚拟服务器配置,可以按照如下步骤配置(仅供参考):
1、/etc/nginx/nginx.conf
user root;
worker_processes  auto;
pid        /var/run/nginx.pid;
error_log  /var/log/nginx_error.log;
events {
    use epoll;
    worker_connections  1024;
}
http {
  server_names_hash_bucket_size 64;
  include /etc/nginx/mime.types;
  sendfile on;
  client_max_body_size 128M;
  large_client_header_buffers 2 1k;
  gzip on;
  gzip_vary on;
  gzip_proxied any;
  keepalive_timeout 60;
  include vhost.conf;
}


2、新建/etc/nginx/vhost.conf (分离server的配置,指定端口号和web根目录)
server {
    listen 8080;   #nginx另起进程,端口号自行设置,但不可与uhttpd的80端口相同。
    listen [::]:8080;
    server_name  localhost;
    root /usr/www;  #自行设置
    index  index.html index.htm index.php default.php;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    location ~\.php$ {  #支持php
        fastcgi_pass unix:/var/run/php8-fpm.sock;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        include /etc/nginx/fastcgi_params;
    }

    location = / {  #支持访问lan口ip跳转到uhttpd的luci界面
        return 302 http://$host/cgi-bin/luci/;
    }

    location /cgi-bin/luci/ {
        client_max_body_size 128m;
        proxy_pass http://127.0.0.1/cgi-bin/luci/;
    }

    location /luci-static/ {
        alias /www/luci-static/;
    }
}


3、/etc/php.ini
此文件只需要改动一个地方:
doc_root = "/usr/www"   
这里按照自定义设置路径即可。

4、在任意目录新建sh脚本nginx.sh。如下:
#!/bin/sh

NGINX_CONFIG="/etc/nginx/nginx.conf"
PHP_FPM_CONFIG="/etc/php8-fpm.conf"
PHP_CONFIG="/etc/php.ini"


start() {
mkdir -p /var/log/nginx /var/lib/nginx
/usr/bin/php8-fpm -R -c $PHP_CONFIG -y $PHP_FPM_CONFIG
/usr/sbin/nginx -c $NGINX_CONFIG >/dev/null 2>&1 &
/etc/init.d/uhttpd start
}


stop() {
/usr/sbin/nginx -c $NGINX_CONFIG -s stop >/dev/null 2>&1 &
killall -9 php8-fpm >/dev/null 2>&1 &
rm -f /var/run/php8-fpm.pid
rm -f /var/log/php8-fpm.log
rm -f /var/run/php8-fpm.sock
/etc/init.d/uhttpd stop
}

if [ $1 -eq 1 ]; then
        start
elif [ $1 -eq 0 ]; then
        stop
fi

如上配置完成后,给nginx.sh添加执行权限:
chmod +x nginx.sh
然后
./nginx.sh 0
./nginx.sh 1
即可重启nginx服务
效果:
浏览器访问lanip:8080访问到自定义的web服务器,
直接访问lanip则访问luci管理页面。



php8编译选项

php8编译选项
回复

使用道具 举报

3

主题

28

帖子

457

积分

中级会员

Rank: 3Rank: 3

积分
457
发表于 2023-2-27 10:13:34 | 显示全部楼层
能把编译好的包分享一下吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|gl-inet.cn ( 粤ICP备18130956号 )

GMT+8, 2026-1-28 04:21 , Processed in 0.026417 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表