Apache, MySQL and PHP on iPhone, Complete Web Server

Apache, MySQL and PHP on iPhone, Complete Web Server
Reading time: 3 min read
Link copied!

iPhone really isn’t just a simple smartphone! With it we can have a complete web server, running apache, php and mysql.

Brief tutorial on how to turn your iPhone into a web server!

Required programs for installation:

Open Installer and add the repository: http://thebigboss.org/repo.xml

After refresh install the following packages through Installer: OpenSSH, BossPrefs and Apache.

Tip: Install and activate the Insomnia app when performing installations, so your iPhone will stay “awake”.

Changing SSH root password:

Changing the SSH root password is extremely important, however, unfortunately 90% of iPhone owners keep the default password: alpine. This could generate big problems, if someone funny wants to mess with your iPhone.

To change the password is quite simple. iPhone uses password encrypted with crypt system. For Linux or Mac OS X users just type the following command: openssl passwd -crypt -salt /s NewPassword

Windows users can generate their password from this site: iPhone Simbunch.

After generating your password, we need to access via SSH to change it. Unix users can type in terminal: ssh root@your-iphone-ip -p 22

Windows users can use the Putty program.

To change the password type: vim /etc/master.passwd

Put your new password for users: root and mobile.

Installing PHP:

Via SSH, create the directories opt, iphone and bin, inside /var/WebServer: mkdir -p /var/WebServer/opt/iphone/bin

After return to root: cd /

And create a hidden link to opt: ln -s /var/WebServer/opt/ ./opt

Now we need to send php into the iPhone. Unix users: scp PHP_FILE root@IPHONE_IP:/var/WebServer/opt/iphone/bin/

Windows users can use the Winscp program

Send the apache httpd.conf file to your iPhone: scp httpd.conf root@[iphone ip]:/etc/httpd/

Via SSH, modify your iPhone’s profile, putting the php PATH: PATH="/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/iphone/bin"

Installing MySQL:

Unzip the mysql.tgz file and send the directory to your iPhone: scp -r mysql root@IPHONE_IP:/var/root/

Via ssh type: cd /var/root/mysql/bin

Then: ./mysql_install_db

After installation, run: ./mysqld_safe --user=root &

To have access to MySQL via command line, being able to create, select, delete tables and much more type: ./mysql mysql

Conclusion:

With these programs installed, our capacity to produce iPhone applications became immense, we’ll have the possibility to produce web applications, such as:

  • Web Photos: We could take a photo with our iPhone, and automatically the photo album would be accessible to anyone connected to a computer network.

  • Music Browser: We can produce web application, that streams our music, in the future each iPhone user could have their Online radio with music directly from their device.

The possibilities are infinite, you just need creativity.

Questions? I’m available. []s