Skip to content

CodeWithSushil/TEMP-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TEMP Server

What is TEMP Server:-

  • This TEMP Server only for Android users or Termux users.
  • If you didn't know what is termux than you read here.
  • T for Termux App.
  • E for Nginx Web Server.
  • M for MariaDB Database Server.
  • P for PHP Language.

Termux Installation

  • If you install Termux app from Google Play Store maybe faced many problem in installation time.
  • So you go to download termux App from F-Droid or Github (Recommended).
  • After install termux app than you follow this commands.

TEMP Server Installation Commands:-

  1. Update your Termux Repositorie.
 pkg update or apt update
  1. Update your Termux Packages.
pkg upgrade -y or apt upgrade -y
  1. Install PHP Language and PHP-FPM (FastCGI Process Manager) for PHP.
pkg install php php-fpm -y or apt install php php-fpm -y
  1. Install MariaDB Database Server.
pkg install mariadb -y or apt install mariadb -y
  1. Install Nginx Web Server.
pkg install nginx -y or apt install nginx -y
  1. Install PhpMyAdmin for Mariadb/MySQL Client.
pkg install phpmyadmin -y or apt install phpmyadmin -y
  1. Composer is a Dependency Manager for PHP programming language so if you need composer than go to this command.
pkg install composer -y or apt install composer -y # (Optional) 
  1. Install msmtp a lightweight SMTP (Simple Mail Transfer Protocol) client.
pkg install msmtp -y or apt install msmtp -y

PHP and Nginx Configuration

  • Set your project path
  • cd $PREFIX/etc/nginx edit nginx.conf file nano nginx.conf.
root /data/data/com.termux/files/usr/share/nginx/html; #Default Set # root /sdcard/your_project_path index index.php index.html index.htm; # Set index
  • Configuration PHP Script and PHP-FPM.
location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock; # Set PHP-FPM for php script fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; }
  • Save nginx.conf file

PHP-FPM Configuration

  • Open php-fpm.d folder and edit www.conf file.
  • cd $PREFIX/etc/php-fpm.d and open www.conf file on nano text editor nano www.conf.
  • Set your user name if you didn't know than run this command whoami and copy your termux user name.
28 user = www-data # Set your termux user name 29 group = www-data # Set your termux user name 41 listen = /data/data/com.termux/files/usr/var/run/php-fpm.sock 53 listen.owner = www-data # Set your termux user name 54 listen.owner = www-data # Set your termux user name 116 pm = dynamic

PHP.ini Configuration

  • Go to etc directory cd $PREFIX/etc/php.
  • Create a php.ini file run this command touch php.ini.
  • Open php.ini file on your vim Editor or Nano Editor.
  • nano php.ini.
sendmail_path = "/data/data/com.termux/files/usr/bin/msmtp -t"
  • Save your php.ini file.

My.ini

  • Go to etc directory cd $PREFIX/etc/php.
  • Create conf.d directory inside of php directory.
  • Run this command mkdir conf.d
  • Go to conf.d directory cd conf.d
  • Create my.ini file for MySQL or Mariadb configuration.
  • Run this command touch my.ini && vi my.ini
error_reporting = E_ALL display_errors = on date.timezone = "Asia/Kolkata" # Replace with your timezone memory_limit = 128M upload_max_filesize = 10M post_max_size = 20M 

MySQL's my.cnf file

# my.cnf [mysqld] port=3306 socket=/data/data/com.termux/files/usr/tmp/mysql.sock datadir=/data/data/com.termux/files/usr/var/lib/mysql log-error=/data/data/com.termux/files/usr/var/log/mysql.err pid-file=/data/data/com.termux/files/usr/var/run/mysqld/mysqld.pid skip-external-locking [client] port=3306 socket=/data/data/com.termux/files/usr/tmp/mysql.sock [mysqldump] quick quote-names max_allowed_packet=16M innodb_buffer_pool_size=256M key_buffer_size=64M max_connections=200

MSMTP Configuration

  • First Create a .msmtprc file.
  • touch .msmtprc
  • Open .msmtprc file on your Nano Editor.
  • nano .msmtprc
account default host smtp.mail.com port 587 from # Your Email id auth on user # Your Email id password # Your Email Password tls on tls_starttls on tls_trust_file /data/data/com.termux/files/usr/etc/tls/cert.pem 
  • Save your .msmtprc file.

Check Configuration Status

  • Create a index.php file.
  • nano index.php
<?php phpinfo(); ?>
  • Run this command nginx and php-fpm.
nginx && php-fpm

TEMP Result


MariaDB Config with PDO (socket)

If you getting error when you try to a connection with mariadb database. So you try this socket connection with MariaDB because MariaDB provide us socket for better experience and fast and secure connection. Before the established a connection with MariaDB, please config your php.ini file.

; php.ini mysqli.default_socket="/usr/var/run/mysqld.sock" pdo_mysql.default_socket="/usr/var/run/mysqld.sock"
// MySQL way $pdo = new PDO("mysql:host=localhost;dbname=test;",'root',''); if($pdo){ echo "Database connection success!"; } // MariaDB's socket way $mariadb = ini_get('pdo_mysql.default_socket'); $pdo = new PDO("mysql:unix_socket=$mariadb;dbname=test", 'root', ''); if($pdo){ echo "Database connection success!"; }