"I have an unused Android smartphone or tablet" "Can this be a server?"
That dream, ** can be fulfilled. ** **
It's a bit of a hassle, but if you do it, you can do it.
Android has an app called "Termux". You can use it to run Linux. The packages are also managed by APT and are abundant.
https://play.google.com/store/apps/details?id=com.termux&hl=ja
Also, you may find it inconvenient to use a keyboard such as GBoard. "Hacker's Keyboard" is recommended.
https://play.google.com/store/apps/details?id=org.pocketworkstation.pckeyboard&hl=ja
Those who have come into contact with Linux should be familiar with it.
First, you need to grant permissions to allow Termux to access files in your device.
$ termux-setup-storage
If you execute this, the permission dialog will appear on Android 8 or later, so please allow it.
Termux provides the "pkg" command as an alias for apt.
command | Description |
---|---|
pkg update | Perform apt upgrade after executing apt update |
pkg install <package...> | apt install <package...> |
pkg remove | apt remove <package...> |
There are other commands. You can get help by running only pkg
.
Immediately update the package.
$ pkg update
When the update is complete, the preparation is complete.
In Termux, the root directory is /data/data/com.termux/files/usr.
This can be represented by $ PREFIX
.
Here is an example.
Original directory path | Path in Termux |
---|---|
/etc | $PREFIX/etc |
/usr/share | $PREFIX/share |
/bin | $PREFIX/bin |
nano is included as standard.
$ nano filename
You can start it with.
Here are some frequently used keyboard operations.
Keyboard input | meaning |
---|---|
Ctrl + X | End |
Ctrl + O | Save |
Termux can be used in the range ** 1024 to 65535 **. Since 80 and 443 cannot be used, port conversion may be required when publishing to the Internet.
** Originally, Telnet should not be published on the net. Let's just use it locally. ** **
$ pkg install busybox
After installing busybox
$ busybox telnetd -p 5888
will do. `-p The number`
is the port number.
It can be accessed with TeraTerm etc.
Termux also has apache2 (httpd) and nginx packages, so you can install them.
If you also want to use PHP, you need php
and php-apache
for apache2.
For nginx you need php
and php-fpm
.
[For apache2]
$ pkg install apache2 php php-apache
[For nginx]
$ pkg install nginx php php-fpm
The configuration file is `` `$ PREFIX / etc / apache2 / httpd.conf```.
If you use PHP, you need to change the settings.
$ nano $PREFIX/etc/apache2/httpd.conf
Start the editor with.
First of all, I think there is an item `` ServerRoot" ... "```
at the beginning.
On the next line
HostnameLookups On
Is described. This is a setting to display the host name in the log.
next,
LoadModule mpm_worker_module xxxxxxxx
There should be a line that says. Comment it out. Instead, it's one above that line
#LoadModule mpm_prefork_module xxxxxxx
Uncomment (remove #)
Next, if you go down and down, you will see the line ``` DocumentRoot" ... "` ``. Around it
Options Indexes FollowSymLinks
Add ExecCGI
to the line. If you add
Options Indexes FollowSymLinks ExecCGI
It will be. Below that
DirectoryIndex index
Also
DirectoryIndex index.php index.html index.htm
Change to.
Finally, on the last line of the file
LoadModule php7_module libexec/apache2/libphp7.so
AddHandler php7-script .php
Has been added. ** Don't forget to save with Ctrl + O! ** **
It may be a little more troublesome than httpd.
The configuration file is `` `$ PREFIX / etc / nginx / nginx.conf```.
$ nano $PREFIX/etc/apache2/httpd.conf
Start the editor with.
First,
location / {
...
}
I think there is a line that says. In it
index index.html index.htm;
To
index index.php index.html index.htm;
To
next
#pass the PHP script Honyara
#
location ~ \.php$ {
...
}
I think there is a line that says. It should be commented out, so remove all that part.
Then replace that part with:
location ~ \.php$ {
root (Arbitrary directory);
fastcgi_pass unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Save with ** Ctrl + X ** and exit the editor.
Next, set up PHP.
$ nano $PREFIX/etc/php-fpm.d/www.conf
Start the editor with.
As you scroll, you will see the line `listen = ....`
.
There
listen = /data/data/com.termux/files/usr/var/run/php-fpm.sock
Rewrite to. Save with ** Ctrl + O ** and you're done.
To start httpd
$ httpd
Just do it. It spits out some logs, but you don't have to worry about it. When to stop
$ httpd -k stop
Or
$ killall httpd
is.
nginx is
$ nginx
Just do.
If you use PHP, before executing `` `nginx```
$ php-fpm
You need to do.
When to stop
$ killall nginx
is.
If you made a bot in Python, you can run it in Termux as well.
Python can install 3.8.
$ pkg install python make automake autoconf clang build-essential git
This installation work consumes about 500MB. Make sure you have ** 2GB or more of free space ** in your storage.
afterwards,
$ pip install wheel requests
$ pip install -U "discord.py[voice]"
To execute. PyNaCl will be built on the way. Depending on the performance of your smartphone / tablet, it may take 2 to 5 minutes to complete. Please go with plenty of time.
Since I installed git earlier, I can remove the program from the repository.
If you're used to using Git, you don't need to explain it. Therefore, write the command assuming that you know how to use it in advance.
$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"
$ git config --global crediential.helper "cache"
$ git clone https://github.com/xxxx/xxxx.git
In the directory where the program to start is located
$ python filename.py
will do.
How, Termux can run Java.
Let's install it now. Here, we will use the ones of volunteers. It will be OpenJDK 8.
$ pkg install wget && wget https://raw.githubusercontent.com/MasterDevX/java/master/installjava && bash installjava
It may take some time for the download to finish. I patiently wait.
After that, type java
to get help and you're done.
You can download the server from https://mcversions.net/. I will omit the usage. Download the server program that matches the version you want to build.
version | URL |
---|---|
1.15.1 | https://launcher.mojang.com/v1/objects/4d1826eebac84847c71a77f9349cc22afd0cf0a1/server.jar |
1.15.2 | https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar |
1.16 | https://launcher.mojang.com/v1/objects/a0d03225615ba897619220e256a266cb33a44b6b/server.jar |
1.16.1 | https://launcher.mojang.com/v1/objects/a412fd69db1f81db3f511c1463fd304675244077/server.jar |
Copy the URL above and
$ cd ~
$ mkdir mcserver
$ cd mcserver
$wget copied URL
To execute. You can paste by pressing and holding anywhere on the screen and pressing "PASTE". If you can download
$ echo "eula=true" > eula.txt
$ java -jar server.jar
will do. Various logs are output and the world is generated. Please note that if the performance is too low, it may crash.
Also, on Android 8 or later, this is the case.
$ java -jar server.jar
Bad system call
$
Before executing this command,
$ proot -0
Please run the.
How was it? There was something I could do quite a bit. More details are written on the net, so please try it. Have a good Termux life!