- 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.
- 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.
- Update your Termux Repositorie.
pkg update or apt update- Update your Termux Packages.
pkg upgrade -y or apt upgrade -y- Install PHP Language and PHP-FPM (FastCGI Process Manager) for PHP.
pkg install php php-fpm -y or apt install php php-fpm -y- Install MariaDB Database Server.
pkg install mariadb -y or apt install mariadb -y- Install Nginx Web Server.
pkg install nginx -y or apt install nginx -y- Install PhpMyAdmin for Mariadb/MySQL Client.
pkg install phpmyadmin -y or apt install phpmyadmin -y- 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) - Install msmtp a lightweight SMTP (Simple Mail Transfer Protocol) client.
pkg install msmtp -y or apt install msmtp -y- Set your project path
cd $PREFIX/etc/nginxedit nginx.conf filenano 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
- Open php-fpm.d folder and edit www.conf file.
cd $PREFIX/etc/php-fpm.dand open www.conf file on nano text editornano www.conf.- Set your user name if you didn't know than run this command
whoamiand 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- Save www.conf file.
- 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.
- Go to etc directory
cd $PREFIX/etc/php. - Create
conf.ddirectory 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 # 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- 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.
- Create a index.php file.
nano index.php
<?php phpinfo(); ?>- Run this command
nginxandphp-fpm.
nginx && php-fpm- Open This URL “http://localhost:8080” on your Mobile Chrome Browser.
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!"; }
