Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Building a Personal Server Using an Android Device

Tech 3

Android devices, with their Linux-based kernel, can be repurposed as personal servers. This guide covers setting up a server environment, enabling remote access, connecting a MySQL database, and deploying a simple blog.

Setting Up the Server Environment

Download and install KSWEB from your browser. After installation, add two ports: 8080 for local access and another for external connections. Access the server locally via http://localhost:8080 on your device, and from a computer using http://[device-ip]:8080.

Note: Ensure both devices are on the same local network for initial acess.

Enabling Remote Access via Tunneling

To allow access from different networks, use an internal network tunneling service like Sunny-Ngrok. Register on their site, complete real-name verification (costs 2 yuan), and create a tunnel. Select HTTP protocol, set a custom subdomain, and note the tunnel ID and provided public domain.

Installing Python on Android

Download Termux from its GitHub releases page (e.g., arm64 version). Install it, then run:

pkg install python

If downloads are slow, try switching mirrors by searching for "python mirror Termux."

Granting File Access Permissions

Run:

termux-setup-storage

Follow prompts to allow Termux access to device storage.

Running the Tunneling Client

Download the Python client from Sunny-Ngrok. Move sunny.py to /storage/emulated/0/Download. In Termux, navigate to that directory:

cd /storage/emulated/0/Download

Execute:

python sunny.py

When prompted, enter the tunnel ID. Refer to Sunny-Ngrok's Android documentation for details.

Troubleshooting Common Issues

  • If cd commands fail, navigate step-by-step using cd .. to reach the root directory, then proceed.
  • For errors like ImportError: dlopen failed: library "libssl.so.3" not found, install OpenSSL:
pkg install openssl-tool

Then rerun sunny.py.

Connecting a MySQL Database

Use phpMyAdmin for database management. Download it from the official site or a mirror if slow. Extract the files, locate config.sample.inc.php, copy it, and rename to config.inc.php. Modify the following sections:

$cfg['blowfish_secret'] = 'random_32_character_string_here';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

Transfer the folder to /ksweb/tools on your device. In KSWEB, create a new host in LIGHTTPD, set the port (e.g., 8001), and point the host address to the phpMyAdmin folder location. Access via http://[device-ip]:8001 from a computer.

Deploying a Simple Personal Blog

Download Typecho from its official site. Extract the files and move them to the htdocs directory on your device, which serves content on port 8080. Access http://[device-ip]:8080 and follow the setup instructions to configure the blog. After completion, you can customize the blog by adding personal pages to the Typecho directory.

Self-built servers may lack the robustness of commercial solutions like Alibaba Cloud in handling attacks or high traffic. Performance depends on the old device's capabilities. For issues not covered, search online for solutions—learning to find answers efficiently is key in tech.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.