termux build wordpress

Reprinted: https://www.sqlsec.com/2018/05/termux.html#toc-heading-115
Guoguang termux tutorial

If a worker wants to do his job well, he must first sharpen his tools.

One, install openssh

Since it is not easy to operate on the mobile phone, we first need to install the openssh tool on termux, this step can also be ignored.

Install openssh, please move to my other blog:
Use the ssh tool to connect to termux on the computer

2. Replacement of domestic sources

Just copy and run:

sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@' $PREFIX/etc/apt/sources.list
sed -i 's@^\(deb.*games stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable@' $PREFIX/etc/apt/sources.list.d/game.list
sed -i 's@^\(deb.*science stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable@' $PREFIX/etc/apt/sources.list.d/science.list
apt update && apt upgrade

In addition, an unzip is installed, which will be used later

pkg install unzip

Three, install mysql

Because mysql was acquired by Oracle, there was a risk of closed source, so the community developed MariaDB

pkg install mariadb

Initialize the database

mysql_install_db

Note that the early termux needed to initialize the database, which is now automatically initialized.

Start the database

nohup mysqld &

Nohup will prompt after running, this is normal, don't worry:

nohup: ignoring input and appending output to `nohup.out'

Stop mysql

Because mysql is always on like debug after it is started, we use the method of killing the process to stop mysql

1. First get the process PID number

ps aux | grep mysql

Parameter usage
2. Then kill the process

kill -9 [PID]

Searching for the pid number is more troublesome, in addition to the above method, you can also terminate the process like this

kill -9 `pgrep mysql`

Log in to mysql

Note, start the mysql service before logging in.
Two users, a user with a termux user name (password is empty), and a root user.

Log in as a normal user

mysql -u $(whoami)

Change the password of another account root

# 登录 Termux 用户
mysql -u $(whoami)

# 修改 root 密码的 SQL语句
use mysql;
set password for 'root'@'localhost' = password('你设置的密码');

# 刷新权限 并退出
flush privileges;
quit; 

Log in as root user

mysql -u root -p

Fourth, install nginx

pkg install nginx

Check whether the configuration file is normal

nginx -t

Because it was just installed, it must be no problem to check now. When we finish modifying the configuration file, we will go back and check it again.

Start nginx

nginx

The default port number that Termux runs on Nginx is 8080

You can use pgrep to view the process pid number of nginx:

pgrep nginx

If it is this machine, directly open the browser to visit:

http://127.0.0.1:8080

If it is ssh connection, visit

http://[ip地址]:8080

You can use to ifconfig -aview the ip address

Restart nginx

nginx -s reload

Stop nginx

1. Native methods provided by nginx:

nginx -s stop #直接停止

nginx -s quit #完成已经接受的请求,然后退出。

2. Kill the process:

kill -9 `pgrep nginx`

or

# 查询 nginx 进程相关的 PID 号
pgrep nginx

# 杀掉 查询出的 PID号进程
kill -9 PID

Configure nginx

vim $PREFIX/etc/nginx/nginx.conf

1. Add index.php to the default home page of rules inside
Insert picture description here
2. cancel location ~ \.php$these comments, changed the picture above looks like:
Insert picture description here
Termux inside Nginx default website root directory is:/data/data/com.termux/files/usr/share/nginx/html

If you want to modify the default path, you only need to replace the path that appears at 2 in the configuration file above.

Five, install php-fpm

Since nginx is just a web server and cannot handle php requests, php-fpm must be installed

Install php before testing php parsing

pkg install php
pkg install php-fpm

Edit the configuration file of php-fpmwww.conf

vim $PREFIX/etc/php-fpm.d/www.conf

Location Search listen =find

listen = /data/data/com.termux/files/usr/var/run/php-fpm.sock

To:

listen = 127.0.0.1:9000

Test php parsing

Need to complete the installation and configuration of nginx and php-fpm first

In the root directory of this website:

/data/data/com.termux/files/usr/share/nginx/html

The content of the new info.php is:<?php phpinfo(); ?>

First start php-fpm, then start nginx, if you Nginx has started, then use the nginx -s reloadrestart Nginx.

Local access: Click here
If it is connected via ssh:

http://[ip地址]:8080/info.php

Okay, it's done above:

  1. mysql installation and configuration
  2. Installation and configuration of nginx
  3. php installation
  4. Installation and configuration of php-fpm
  5. Tested php parsing
  6. Tested the normal operation of the nginx server

Officially started building wordpress

One, create a new database

mysql -uroot -p[密码] -e"create database wordpress;show databases;"

Second, download WordPress

#  wget 下载
wget https://cn.wordpress.org/wordpress-5.4-zh_CN.zip

# unzip 解压 没有安装unzip请自行安装
unzip wordpress-4.9.4-zh_CN.zip

# 将解压的文件夹移动到 nginx 网站根目录下
mv wordpress/ $PREFIX/share/nginx/html

Download is too slow, you can use Thunder

Check start:

  1. mysql
  2. php-fpm
  3. nginx

It is recommended to exit termux first, and then restart

nohup mysqld &
php-fpm
nginx

Install wordpress

Browser access: http://127/.0.0.1/wordpress/install WordPress

If you are not using this machine to access, but use ssh to connect like me, you need to change the ip address of the above link to the ip address of the mobile office network, ifconfig -acheck the ip

At last:
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_17802895/article/details/113788855