找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 12396|回复: 174

Openwrt搭建php环境,玩转php源码(关贴)

 火... [复制链接]
本帖最后由 aming.ou 于 2024-4-24 07:47 编辑

Openwrt中自带有web服务uhttpd,添加php网页时只需要安装pgp-cgi,修改相应配置即可
本教程基于openwrt17.01.7版本,硬件是wr703n 硬改16M+ 64M
更多信息,建议论坛里搜索 "openwrt php"

1 安装php
由于涉及配置文件修改,推荐在ssh/telnet命令行模式下安装。更新软件库,根据当前Openwrt插件仓库支持的php版本,修改需要安装的php程序名
更新软件库

  1. opkg update
复制代码
查询php版本
  1. opkg find php*
复制代码
根据返回的php版本信息,执行下面其中一条命令,安装到默认目录(usr),后面跟自己想要安装的程序,所选程序/插件是最常用的,也可以根据自己的需要,参考opkg find php*返回的程序包进行增加
# php7

  1. opkg install php7 php7-cgi php7-mod-ctype php7-mod-hash php7-mod-pdo php7-mod-pdo-sqlite php7-mod-session php7-mod-sqlite3 php7-mod-json php7-mod-curl php7-mod-iconv php7-mod-sockets php7-mod-openssl php7-mod-simplexml
复制代码
# php8
  1. opkg install php8 php8-cgi php8-mod-ctype php8-mod-hash php8-mod-pdo php8-mod-pdo-sqlite php8-mod-session php8-mod-sqlite3 php8-mod-json php8-mod-curl php8-mod-iconv php8-mod-sockets php8-mod-openssl php8-mod-simplexml
复制代码

2 配置/etc/config/uhttpd

在config uhttpd 'main'这一项下增加几行
  1.         list index_page 'index.php'
  2.         list index_page 'index.html'
  3.         list index_page 'index.htm'
  4.         list interpreter '.php=/usr/bin/php-cgi'
复制代码
修改后完整的/etc/config/uhttpd的main项内容如下:
  1. config uhttpd 'main'
  2.         list listen_http '0.0.0.0:80'
  3.         list listen_http '[::]:80'
  4.         list listen_https '0.0.0.0:443'
  5.         list listen_https '[::]:443'
  6.         option redirect_https '1'
  7.         option home '/www'
  8.         option rfc1918_filter '1'
  9.         option max_requests '3'
  10.         option max_connections '100'
  11.         option cert '/etc/uhttpd.crt'
  12.         option key '/etc/uhttpd.key'
  13.         option cgi_prefix '/cgi-bin'
  14.         option script_timeout '60'
  15.         option network_timeout '30'
  16.         option http_keepalive '20'
  17.         option tcp_keepalive '1'
  18.         option ubus_prefix '/ubus'
  19.         list index_page 'index.php'
  20.         list index_page 'index.html'
  21.         list index_page 'index.htm'
  22.         list interpreter '.php=/usr/bin/php-cgi'
复制代码
其中0.0.0.0:80指定访问的ip和端口
/www为网页文件夹
index.php为主页文件
".php=/usr/bin/php-cgi" 为php-cgi路径,注意根据安装的版本修改正确,如php8则为”.php=/usr/bin/php8-cgi" (建议ls查看/usr/bin目录下的php程序名)

3 配置/etc/php.ini
安装完成后进入/etc,修改php.in文件,注释掉如下行即可
  1. 修改行:
  2. short_open_tag = On
  3. default_charset = "UTF-8"       //修改默认编码,且去掉全面的;
  4. memory_limit = 24M               //默认内存最大占有数,至少配置16M,最好更多
  5. ;doc_root = "/www"       //这个要注释了,否则会和uhttpd配置冲突
  6. 新增一行:
  7. date.timezone = Asia/Shanghai  //时区设置可能会有问题,Asia可能安不上
复制代码
如果是php5,程序/插件的配置在php.ini中。

4 修改完成后执行uhttpd服务重启
/etc/init.d/uhttpd restart

5 测试php
a.      在/www目录下新建一个文件夹diyp,然后新建index.php文件,内容如下:
<?php phpinfo(); ?>

b.      没有闪存空间,在/tmp目录下新建一个文件夹diyp,然后新建index.php文件,内容如下:
<?php phpinfo(); ?>
创建软链接到/www路径下:
ln –s /tmp/diyp /www/diyp



6 玩转php源码
测试成功显示php环境信息页面后,就可以畅快的玩转“iptv直播源、网络视频直播资源、直播代码”中的各种代理php源码
a、山上大神 guoma有很多代理php,详见大佬的主题
https://www.right.com.cn/forum/h ... w=me&from=space
b、搭建自己的频道接口服务,搭建自己的节目接口服务



我的恩山、我的无线 The best wifi forum is right here.
其实op搭php确实很方便,我搭了个php版的内网测速,speedtest-x
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

我来学习一下,还是不会抓包
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

看看隐藏
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

会写代码就是好,什么都懂玩
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

可惜学不会
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

openwrt php
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习一下,谢谢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

隐藏内容
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

看看隐藏
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

进来看看
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

我来学习一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-29 00:03

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

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