A few days ago, due to the chaos of gitee’s audit engine, Gitee Pages stopped providing services, and I had the idea of changing the server or hosting other pages. When I looked at the cloud server with impressive price and empty wallet, I had a strange idea that I should set up a server myself, and suddenly I thought, I had an old phone from Root that I just used for testing

preparation

What you’ll need: An old Android phone with root access, an Internet-connected computer with Git installed

Software to install: Linux Deploy, BusyBox, JuiceSSH (optional), KSWEB (optional)

JuiceSSH executes commands faster than a computer, though it is mobile and may require an external keyboard

The following operations are all on the computer and do not demonstrate the connection between JuiceSSH and Linux Deploy (see the third link at the end of this article for a tutorial)

Experience needed: Hexo blog deployment, git (or Linux) base, flexible use of keyword search, vim editor syntax

Basic information about an old cell phone

  • Model: Redmi 3
  • Android version: 5.1.1
  • CentOS 7 (AltArch) [running via Linux Deploy]
  • RAM: 2.0 GiB
  • CPU: 8-core 1.5ghz
  • Storage space: 10GiB, available 4GiB

Configuring the Linux Environment

First open BusyBox and click Install (root permission required)

Then open Linux Deploy and click configuration in the lower right corner to configure the system information. Select CHroot as the container type and CentOS as the distribution. If you choose another distribution, make sure you select the correct architecture, otherwise the installation will fail or it will not work. Suggestions for domestic source switch, the source address here on USTC image source mirrors.ustc.edu.cn/centos-alta… , there are other sources to choose from, such as Tsinghua source, Ali source and so on

The Settings here are important, be sure to enable SSH for later steps (the default SSH port is 22, which is used for JuiceSSH connections)

Then return to the main interface, click the upper left, open the Settings, it is recommended that the first three options tick, scroll down, see the PATH variable, enter /system/xbin, and then pull down, debug mode also tick

Go back to the home screen and click on the upper right corner to start the installation, which will take about half an hour

a few thousand years later……

When you see the output “deploy” of the mobile phone, the installation is complete. Click the stop button before starting. When you see “stop”, click “Start”.

Then open KSWEB and check the LAN IP of the current phone, for example, my phone’s IP is 192.168.101.10

Then open the PC terminal (CMD, git, WSL), enter SSH [email protected], and enter the password as required (the previous Linux Deploy configuration has the password option), as shown in the picture below, the phone is successfully connected

Deploy it on the server

Configure git

Install Git and Node.js on the server

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
yum install -y git
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
yum -y install nodejs
Copy the code

If no action is being done and the download ceases without intention and a Withdraw on user cancel appears, try entering

yum clean metadata
yum clean all
yum upgrade
Copy the code

If Failed to set locale, defaulting to C.UTF-8 occurs, the locale is not set correctly or the related language package is not installed. You can use either of the following methods to solve the problem

echo "export LC_ALL=en_US.UTF-8" >> /etc/profile
source /etc/profile
Copy the code

After executing, log in again and try installation. If this situation still occurs, install the corresponding language package

Yum install glibc-langpack-en install langpacks-en glibc-all-langpacks -yCopy the code

Create users and configure their repositories

Useradd git passwd git // set the password su git //cd/home/git/mkdir -p projects/blog // the actual directory where the project exists mkdir repos &&cdGit init --bare blog. Git // create a bare repositorycdBlogo.git /hooks vi post-receive // create the hook functionCopy the code
#! /bin/sh
git --work-tree=/home/git/projects/blog --git-dir=/home/git/repos/blog.git checkout -f
Copy the code

The modification permission is added

chmod +x post-receive
exitChown -r git:git /home/git/repos/blog.git // Add permissionCopy the code

To test whether the git repository is available, find another blank folder, right-click git bash here on your computer and type

git clone git@server_ip:/home/git/repos/blog.git
Copy the code

If you can clone an empty repository, the Git repository is successfully set up

To establish an SSH trust relationship, run the following command on the PC

SSH - copy - id - I C: / Users/yourname /. SSH/id_rsa pub git @ server_ip / / if there is a space user name, path in quotes SSH git @ server_ip / / test can log inCopy the code

Note: SSH login git users do not need a password! Otherwise, an error occurs. Repeat Steps 3-5 carefully

As shown, the trust is successfully added

For security reasons, disable the git user’s shell login permission and use git clone, git push only

Cat /etc/shell// Check whether git-shell is included in the login modewhichGit-shell // Check whether vi /etc/shells are installed add the steps displayed in /usr/bin/git-shellCopy the code

Example Change the permission of /etc/passwd

/ / the original git: x: 1000-1000: : / home/git: / bin/bash / / modified to git: x: 1000-1000:,,,, / home/git: / usr/bin/git - shellCopy the code

The content to be modified is usually in the last line. You only need to add a semicolon comma and change the path

Setup the Nginx server

Download and install nginx

cd /usr/localhttp://nginx.org/download/nginx-1.15.2.tar.gz/SRC wget tar XZVF nginx - 1.15.2. Tar. GzcdGCC GDB GCC -c++ make wget GCC GDB GCC -c++ make wget Execute the next sentence! ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module
make && make install
alias nginx='/usr/local/nginx/sbin/nginx'// Create an alias for nginxCopy the code

Configure the nginx file

Check whether the installation is successful

Nginx // come directly! View server_IP in the browser. The default is port 80Copy the code

Modifying a Configuration File

Nginx -s stop // Stop nginxcd /usr/local/nginx/conf vi nginx.conf: /nginx/conf: /nginx/conf: /nginx/conf: /nginx/conf: /nginx/conf: /nginx/confCopy the code

The first arrow points to nobody, and the second arrow points to buggy files

If you want to change the root path to the blog location, for example, /home/git/projects/blog, replace this path with a semicolon

Visual has a pit in modifying configuration files here, there will be/usr/local/nginx/logs/nginx pid failed words like, open/usr/local/nginx/logs, input the ls – al, didn’t see a nginx. Pid, My solution is to enter the/usr/local/nginx/sbin/nginx – c/usr/local/nginx/conf/nginx. Conf, then enter the ls – al, found nginx. Pid is present, Run nginx -s reload again, no error.

Here, you can test the web page deployed on the server, but can only achieve LAN search. Listen 80 is a port set to localhost. You can try to open the preview in the browser. However, it is recommended to change the port to another port to avoid the port being occupied and unable to preview

:warning:

Don’t forget to start nginx or you won’t be able to preview the page

To preview, enter 127.0.0.1:800 or 192.168.101.10:800 in the mobile browser

Computer input on the same LAN192.168.101.10:800You can preview

release

configuration_config.ymlfile

Edit the Deploy property

The repO is the destination address pushed to

Push to server

Use hexo D-G or hexo G-d, as shown in the figure

Intranet through

There are many tools for Intranet penetration, common ones are peanut shell, FRP, and NGORK. Because the price of peanut shell is too touching, FRP needs another server with public IP, and natApp based on Ngork is used here

Official website: natapp.cn (Come and make money doge)

Wget + Linux installation package is used for installation. Since I don’t know where wget will be saved, I add a specified path after wget

wget -P /home/git/ https://cdn.natapp.cn/assets/downloads/clients/2_3_9/natapp_linux_arm64/natapp?version=20190730
Copy the code

Rename the installation package after downloading

mv natapp? version=20190730 natappCopy the code

Under root, grant the execute permission before executing

chmod a+x natapp
./natapp
Copy the code

/ NatApp can’t run the program yet, you need to add the authToken parameter of the created tunnel to open it

./natapp -authtoken=<your token>
Copy the code

After running the program, the url in the picture has penetrated the Intranet and can be accessed externally (this is a temporary link)

At this point, a Web private server is set up.

In addition, as for the penetrating url, Natapp has a paid tunnel that can bind to the self-defined domain name at 9 RMB per month, while the price of peanut shell is quite touching (it also cost 6 RMB to open HTTPS penetrating authentication, but I found there was no luan to use, I *&%@), so I chose Natapp finally

However, I chose GitHub Pages + Netlify to configure my website. I need to keep the private server running for 24 hours (it feels like it doesn’t cost much electricity). After all, the speed of accessing the website through the tunnel is similar to that of hosting directly on GitHub Pages. Use GitHub Pages instead

In addition to a web server, the old phone could theoretically build a private web disk.

Refer to the link

Originally published old cell phone into a web server and network through | Jayden ‘s Blog

Old mobile phone build website and Intranet penetration – Dark’s blog (ii.do)

Take you to skip the various pits and deploy Hexo blog to your own server at once

Use Linux Deploy to transform idle Android phones into simple servers.

Hexo+Github Page – SegmentFault

[solve nginx: [error] open () “/ usr/local/nginx/logs/nginx pid” failed error _ three also Mr Blog – CSDN]

Centos 7 update yum Install appears no longer part on User Cancel – Aliyun.com

Failed to set locale, defaulting to C.UTF-8 – 天 jun-bloggarden (cnblogs.com)

The hexo blog | MX deployed to the server (mx142. Cn)