在iPhone/iPad中搭建web服务器和PHP开发环境:Lighttpd + PHP(with GD) + MySQL

1. Install the Package in Cydia Add the Cydia Source http://ios-webstack.tk/cydia, find and install the package ios-lighttpd-php-mysql. Your lighttpd web server is now running. You can test it in Safari. But you need to do some more work with php and mysql.
2. Mysql Configuration
Log in your IOS device and execute the following shell commands.
# bin/mysql_install_db –user=daemon
# /usr/local/bin/mysqladmin -u root password ‘new-password’
# /usr/local/bin/mysql_secure_installation
执行mysql_secure_installation
Change the root password? [Y/n]
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] n
# mysql -u root -p’yourpassword’
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection idis 8
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.
mysql>
mysql>
mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
+——————–+
2 rows in set (0.01 sec)
mysql>
3. PHP Configuration
Create File: /etc/php.ini
;This is an ‘EXAMPLE’ configuration file for PHP.
;Be careful with the socket path
mysql.default_socket = /tmp/mysql.sock
pdo_mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
;Limits
upload_max_filesize = 10M
post_max_size= 10M
;TimeZone
;You should simply replace ‘Europe/Berlin’ with the desired timezone.
;The full list of supported time zones is available here: http://www.php.net/manual/en/timezones.php
date.timezone = ‘UTC’
;I recommends to place following lines to /etc/php.d/security.ini (it will not be touched
;from a cydia packages update).
;========================================================================================
;Please have a look at http://www.cyberciti.biz/tips/php-security-best-practices-tutorial.html
;It is up to you to comment-out some directives.
;Make sure you log all php errors to a log file.
;Make sure that php and lighttpd have write permissions.
log_errors=Off
error_log=/var/log/lighttpd/php_scripts_error.log
;To restrict PHP information leakage disable expose_php.
;Have a check befor and after: curl -I http://your.iOS-Web.server/yourPHPsite.php
expose_php=Off
;Do not expose PHP error messages toall site visitors.
; display_errors=Off
;The allow_url_fopen option allows PHP’s file functions – such as file_get_contents() and the
;include and require statements – can retrieve data from remote locations using ftp or http
;protocols. Programmers frequently forget this and don’t do proper input filtering when passing
;user-provided data to these functions, opening them up to code injection vulnerabilities.
;A large number of code injection vulnerabilities reported in PHP-based web applications are
;caused by the combination of enabling allow_url_fopen and bad input filtering.
; allow_url_fopen=Off
;I also recommend to disable allow_url_include for security reasons:
; allow_url_include=Off
;If turned On, mysql_connect() and mysql_pconnect() ignore any arguments passed to them.
;Please note that you may have to make some changes to your code. Third party and open source
;application such as WordPress, and others may not work at all when sql.safe_mode enabled.
; sql.safe_mode=On
;It is also recommended that you turn off magic_quotes_gpc for all php 5.3.x installations
;as the filtering by it is ineffective and not very robust. mysql_escape_string() and
;custom filtering functions serve a better purpose (hat tip to Eric Hansen):
; magic_quotes_gpc=Off
;You can set maximum execution time of each php script, in seconds.
;Another recommend option is to set maximum amount of time each script
;may spend parsing request data, and maximum amount of memory a script may consume.
;GD picture converting needs a lot of memory. Be carefull with ‘memory_limit’
;Set in seconds:
; max_execution_time = 30
; max_input_time = 30
; memory_limit = 40M
The packages include configuration files for PHP in /etc/ and extension configuration files in /etc/php.d/
Create File: /etc/php.d/php.ini
;You can splite this file in separate INI files.
;If you do that, please remember the extension loading
;order of INI files (alphabetically).
extension=iconv.so
extension=mbstring.so
extension=curl.so
;The loading order is important
extension=sqlite3.so
extension=pdo_sqlite.so
;The loading order is important
extension=mysqlnd.so
extension=mysqli.so
extension=mysql.so
extension=pdo_mysql.so
;Must be loaded after mbstring.so
extension=exif.so
extension=gd.so
extension=zip.so
extension=bz2.so
extension=calendar.so
extension=mcrypt.so
extension=xsl.so
extension=openssl.so
Finally, input http://127.0.0.1/phpinfo.php in Safari, you’ll get a long PHP information page like this:
PHP Version 5.4.8 System
Darwin mengtaos-iPhone 10.4.0 Darwin Kernel Version 10.4.0: Wed Oct 20 20:08:31 PDT 2010; root:xnu-1504.58.28~3/RELEASE_ARM_S5L8920X iPhone2,1
Build Date
Nov 14 2012 17:33:08
Configure Command
‘./configure’
Server API
CGI/FastCGI
Virtual Directory Support
disabled
Configuration File (php.ini) Path
/etc
Loaded Configuration File
/etc/php.ini
Scan this dir for additional .ini files
/etc/php.d
Now, Enjoy this little web server!

SAE中使用TmpFS功能

前一段时间做的项目需要提供导出CSV报表的功能,我用php直接拼出csv的文件流输出到页面,以提供csv文件的下载,功能在wamp环境中运行很正常,但是到了SAE平台却怎么都不好使。不管是改请求的响应头content-type 还是修改输出的文件格式,每次SAE都是把内容直接输出在了页面。因为SAE不支持通用方式的本地IO,于是想到了使用SAE提供的tmpFS功能。
TmpFS
因为平台安全性的考虑,SAE限制了用户对于本地IO的使用,但这样对于一些传统的PHP项目,也许带来了很多不便,因为它们都或多或少的有对本地 IO的操作,像Smarty的编译模板。为了解决这个问题,SAE提供了TmpFS功能。TmpFS允许开发者通过标准的IO函数临时读写本地IO,这样 方便了很多非SAE项目的移植。
特别注意:
临时文件的生存周期等同于PHP请求,也就是当该PHP请求完成执行时,所有写入TmpFS的临时文件都会被销毁
TmpFS是本地临时文件,不是共享存储,而SAE是全分布式环境,所以不同请求之间无法通过TmpFS共享操作文件
TmpFS操作的文件限于SAETMPPATH目录内,而不同App的SAETMPPATH是不同的
TmpFS的文件为纯内存存储
应用场景
用户的可持久化存储,请使用Storage或者MySQL存储,而缓存存储请使用Memcache服务存储,TmpFS是满足用户的一个请求的临时 文件的读写需求。比如抓取一个URL的图片,判断一下大小,再决定是否写入Storage。需要在本地生成文件的情况大致分以下几种:
缓存
配置文件
静态文件
临时文件
例子:
appname: saetest
appversion: 1
在一个php文件中:
file_put_contents( SAE_TMP_PATH . ‘/mycode.txt’ , ‘dummy test’ );
echo file_get_contents( SAE_TMP_PATH . ‘/mycode.txt’ ); // will echo dummy test;
如果是两个独立的php文件:
a.php
file_put_contents( SAE_TMP_PATH . ‘/mycode.txt’ , ‘dummy test’ );
b.php
echo file_get_contents( SAE_TMP_PATH . ‘/mycode.txt’ ); // 出错啦,文件已经不存在了…
说到这里,大家应该明白了, tmpFS中的文件在后台PHP代码执行完后就已经不存在了,囧。最后只好用了个折中的办法,临时把文件放在了SAE的永久化存储的Storage里面。不知看到这里的朋友有无更好的办法解决SAE中导出文件的问题,欢迎联系告知~

Discuz! x 3.2 移植SAE 记录(完结)

因为SAE禁止IO写操作,代码目录不能写入。

在本地安装了一个discuz,然后比较了一下安装前和安装后的差别,

1 安装后在config文件夹下生成两个文件config_global.php和config_ucenter.php

2 data/cache下生成一些cache文件

3 生成data/diy文件夹

4 生成data/sysdata文件夹,并生成一些文件

5 data/template文件夹下生成一些模版文件

6 data文件夹生成两个文件install.lock, sendmail.lock

7 uc_client/data/cache下生成cache文件

8 uc_server/data下生成文件config.inc.php install.lock, upgrade.lock

 

 

 

 

2014-08-02

1:03:47 AM 开始,预料之内的问题

1:11:10 AM 简单修改install_function.php 使其能够安装向导通过写入测试进入下一步的

 

阅读剩余部分 –

HTML的超链接

先看两个示例

建立一个超链接

这个示例演示了如何在HTML文件里创建超链接。

<html>
<body>
<p>
<a href="../asdocs/html_tutorials/humor02.html">这是一个链接</a>
</p>
<p>
<a href="http://www.dammit.hk/category/programming/html" target=_blank>HTML Wiki 站点链接</a>
</p>
</body>
</html>

 

将一个图片作为一个超链接

这个示例演示了如何将一个图片作为一个超链接,即点击一个图片,可以连接到其它文件。

<html>
<body>
<p>
你可以将一张图片作为一个链接,点击这个图片。
<a href="../asdocs/html_tutorials/humor03.html"><img  src="../images/html_tutorials/smile.jpg" ></a>
</p>
</body>
</html>

 

ahref属性

HTML用<a>来表示超链接,英文叫anchor。

<a>可以指向任何一个文件源:一个HTML网页,一个图片,一个影视文件等。用法如下:

<a href=”url”>链接的显示文字</a>

点击<a></a>当中的内容,即可打开一个链接文件,href属性则表示这个链接文件的路径。

比如链接到dammit.hk/category/programming/html站点首页,就可以这样表示:

<a href="http://www.dammit.hk/category/programming/html">HTML Wiki 首页</a>

 

target属性

使用target属性,可以在一个新窗口里打开链接文件。

<a href="http://www.dammit.hk/category/programming/html" target=_blank>HTML Wiki 首页</a>

 

实例:

<html>
<body>
<a href="../asdocs/html_tutorials/humor01.html" target="_blank">一则笑话</a>
<p>
如果你将target的属性值设成_blank,你点击这个链接的时候,网页就会在一个新窗口出现。
</p>
</body>
</html>

 

title属性

使用 title 属性,可以让鼠标悬停在超链接上的时候,显示该超链接的文字注释。

<a href="http://www.dammit.hk/category/programming/html/" title = "HTML Wiki">HTML Wiki</a>

 

如果希望注释多行显示,可以使用&#10;作为换行符。

<a href="http://www.dammit.hk/category/programming/html/" title = "HTML&#10;Wiki">HTML Wiki</a>

 

实例:

<html>
<body>
<p>
<a href="http://www.dammit.hk/category/programming/html/" title = "HTML Wiki">HTML Wiki</a>
</p>
<p>
<a href="http://www.dammit.hk/category/programming/html/" title = "HTML&#10;Wiki">HTML Wiki</a>
</p>
</body>
</html>

 

name属性

使用name属性,可以跳转到一个文件的指定部位。

使用name属性,要设置一对。一是设定name的名称,二是设定一个href指向这个name:

<a href="#C1">参见第一章</a>
<a name="C1">第一章</a>

 

实例:

<html>
<body>
<p>
<a href="#C9">参见第六章</a>
</p><p>
<a name="C1"><h2>第1章</h2></a>
<p>这是html- 网页教程与代码的中文站点。</p>
<a name="C2"><h2>第2章</h2></a>
<p>这是html- 网页教程与代码的中文站点。</p>
<a name="C3"><h2>第3章</h2></a>
<p>这是html- 网页教程与代码的中文站点。</p>
<a name="C4"><h2>第4章</h2></a>
<p>这是html- 网页教程与代码的中文站点。</p>
<a name="C5"><h2>第5章</h2></a>
<p>这是html- 网页教程与代码的中文站点。</p>
<a name="C6"><h2>第6章</h2></a>
<p>这是html- 网页教程与代码的中文站点。</p>
<a name="C7"><h2>第7章</h2></a>
<p>这是html- 网页教程与代码的中文站点。</p>
<a name="C8"><h2>第8章</h2></a>
<p>这是html- 网页教程与代码的中文站点。</p>
<a name="C9"><h2>第9章</h2></a>
<p>这是html- 网页教程与代码的中文站点。</p>
</body>
</html>

 

name属性通常用于创建一个大文件的章节目录(table of contents)。每个章节都建立一个链接,放在文件的开始处,每个章节的开头都设置Name属性。当用户点击某个章节的链接时,这个章节的内容就显示在最上面。

如果浏览器不能找到Name指定的部分,则显示文章开头,不报错

链接到email地址

在网站中,你经常会看到“联系我们”的链接,一点击这个链接,就会触发你的邮件客户端,比如Outlook Express,然后显示一个新建mail的窗口。用<a>可以实现这样的功能。

<a href = “mailto:even@dammit.hk”>联系Even</a>

实例:

<html>
<body>
<p>
这是一个最简单的邮箱地址的链接:
<a href="mailto:even@dammit.hk">给Even发信</a>
</p>
<p>
这个邮箱地址的链接写了subject内容:
<a href="mailto:even@dammit.hk?subject=Hello">给Even发信</a>
</p>
<p>
这个邮箱地址链接写了to, cc, bcc, subject, body的内容:
<a href="mailto:even@dammit.hk?cc=even@dammit.hk&bcc=even@dammit.hk&subject=I%20like%20your%20site&body=真是个好站点!">写信给新浪</a>
</p>
<p>
<b>注:</b>空格请用%20表示。
</p>
</body>
</html>

 

Html特殊字符显示

HTML字符实体(Character Entities)

有些字符在HTML里有特别的含义,比如小于号<就表示HTML Tag的开始,这个小于号是不显示在我们最终看到的网页里的。那如果我们希望在网页中显示一个小于号,该怎么办呢?

这就要说到HTML字符实体(HTML Character Entities)了。

一个字符实体(Character Entity)分成三部分:第一部分是一个&符号,英文叫ampersand;第二部分是实体(Entity)名字或者是#加上实体(Entity)编号;第三部分是一个分号。

比如,要显示小于号,就可以写&lt;或者&#60;。

用实体(Entity)名字的好处是比较好理解,一看lt,大概就猜出是less than的意思,但是其劣势在于并不是所有的浏览器都支持最新的Entity名字。而实体(Entity)编号,各种浏览器都能处理。

注意:Entity是区分大小写的。

如何显示空格

通常情况下,HTML会自动截去多余的空格。不管你加多少空格,都被看做一个空格。比如你在两个字之间加了10个空格,HTML会截去9个空格,只保留一个。为了在网页中增加空格,你可以使用&nbsp;表示空格。

最常用的字符实体(Character Entities)

显示结果 说明 Entity Name Entity Number
显示一个空格 &nbsp; &#160;
< 小于 &lt; &#60;
> 大于 &gt; &#62;
& &符号 &amp; &#38;
双引号 &quot; &#34;

其他常用的字符实体(Character Entities)

显示结果 说明 Entity Name Entity Number
© 版权 &copy; &#169;
® 注册商标 &reg; &#174;
× 乘号 &times; &#215;
÷ 除号 &divide; &#247;

ISO Latin-1字符集

2025 年 7 月
 123456
78910111213
14151617181920
21222324252627
28293031  

广告

分类

近期评论

标签

历史上的今天

    历史上的今天没有存档

归档