Skip to content

Instantly share code, notes, and snippets.

@ankit1057
Created July 4, 2023 01:21
Show Gist options
  • Select an option

  • Save ankit1057/d46ff1bbe19117d2830e65c6ca4da9b3 to your computer and use it in GitHub Desktop.

Select an option

Save ankit1057/d46ff1bbe19117d2830e65c6ca4da9b3 to your computer and use it in GitHub Desktop.
Install Lampp on termux
#!/bin/bash
# Update packages
apt update
apt upgrade -y
# Install Apache and PHP
apt install php-apache -y
# Install MySQL
apt install mariadb -y
# Install nano text editor
apt install nano -y
# Load PHP module in Apache configuration file
sed -i 's/#LoadModule mpm_prefork_module libexec\/apache2\/mod_mpm_prefork.so/LoadModule mpm_prefork_module libexec\/apache2\/mod_mpm_prefork.so\nLoadModule php7_module libexec\/apache2\/libphp7.so/' /data/data/com.termux/files/usr/etc/apache2/httpd.conf
# Set handler for PHP files in Apache configuration file
sed -i 's/#LoadModule mpm_prefork_module libexec\/apache2\/mod_mpm_prefork.so/LoadModule mpm_prefork_module libexec\/apache2\/mod_mpm_prefork.so\nLoadModule php7_module libexec\/apache2\/libphp7.so\nAddHandler php7-script .php/' /data/data/com.termux/files/usr/etc/apache2/httpd.conf
# Restart Apache
apachectl restart
# CLI menu for configuring the server
while true; do
echo "Server Configuration Menu:"
echo "1. Set PHP project path"
echo "2. Edit Apache configuration file"
echo "3. Edit PHP configuration file"
echo "4. Restart Apache"
echo "5. Exit"
read -p "Enter your choice: " choice
case $choice in
1)
read -p "Enter the absolute path to your PHP project: " project_path
sed -i "s|DocumentRoot \"/data/data/com.termux/files/usr/share/apache2/default-site/htdocs\"|DocumentRoot \"$project_path\"|" /data/data/com.termux/files/usr/etc/apache2/httpd.conf
apachectl restart
;;
2)
nano /data/data/com.termux/files/usr/etc/apache2/httpd.conf
apachectl restart
;;
3)
nano /data/data/com.termux/files/usr/etc/php.ini
apachectl restart
;;
4)
apachectl restart
;;
5)
break
;;
*)
echo "Invalid choice"
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment