Saturday, September 6, 2025

Steps to setup phpmyAdmin after LAMPP stack setup using ubuntu

 You’re using Ubuntu with a LAMPP stack (Linux + Apache + MySQL + PHP). Let’s walk through installing and securing phpMyAdmin step by step:


🔹 1. Update system

sudo apt update && sudo apt upgrade -y

🔹 2. Install phpMyAdmin

sudo apt install phpmyadmin -y

👉 During installation, it will ask:

  • Web server to configure automatically → choose apache2

  • Configure database for phpMyAdmin → select Yes

  • Set a phpMyAdmin application password (this is for phpMyAdmin’s own database user, not MySQL root).


🔹 3. Enable Apache configuration

If it didn’t auto-enable, manually link phpMyAdmin to Apache:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo systemctl reload apache2

🔹 4. Enable required PHP extensions (LAMPP often needs this)

Make sure these are enabled:

sudo apt install php-mbstring php-zip php-gd php-json php-curl -y
sudo phpenmod mbstring
sudo systemctl restart apache2

🔹 5. Access phpMyAdmin

Now open in your browser:

http://your-server-ip/phpmyadmin

Example:

http://34.199.91.21/phpmyadmin

Login using your MySQL root (or another MySQL user you created).


🔹 6. (Optional) Enable root login if blocked

By default, MySQL root may be set to auth_socket instead of a password. Fix:

sudo mysql -u root

Inside MySQL shell:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_strong_password';
FLUSH PRIVILEGES;
EXIT;

Now login in phpMyAdmin with root / your_strong_password.


🔹 7. Secure phpMyAdmin

Since phpMyAdmin is a common attack target:

  • Change the URL alias (instead of /phpmyadmin/dbadmin123):

    sudo nano /etc/apache2/conf-available/phpmyadmin.conf
    

    Replace /phpmyadmin with /dbadmin123, then:

    sudo systemctl reload apache2
    
  • Restrict access by IP (allow only your IP).


✅ Done! You now have phpMyAdmin running on your LAMPP server.



Set up a permanent system user access token for WhatsApp Cloud API

To set up a permanent system user access token for WhatsApp Cloud API in Meta Business Manager, here’s the step-by-step process:


🔹 Step 1. Go to Business Settings


🔹 Step 2. Create a System User

  1. Under Users → System Users.

  2. Click Add.

  3. Give it a name (example: MedicalSupplierz_API_User).

  4. Choose Role = Admin (so it has full permissions).

  5. Save.


🔹 Step 3. Assign Assets to the System User

  1. After creating the system user, select it.

  2. Click Add Assets.

  3. Assign your WhatsApp Business Account (WABA).

  4. Give it permissions:

    • whatsapp_business_messaging

    • whatsapp_business_management.


🔹 Step 4. Generate a Permanent Access Token

  1. Still inside the system user, click Generate New Token.

  2. Choose your app (the one connected to WhatsApp Cloud API).

  3. Select permissions:

    • whatsapp_business_messaging

    • whatsapp_business_management.

  4. Generate token → it will look like:

    EAAG...long-string...ZDZD
    

⚠️ Copy it immediately — Meta only shows it once.


🔹 Step 5. Use the Token in Your Code

In your .env file:

WHATSAPP_ACCESS_TOKEN=EAAG...long-string...ZDZD

Use it in your API calls:

curl -i -X POST \
  https://graph.facebook.com/v20.0/{{PHONE_NUMBER_ID}}/messages \
  -H "Authorization: Bearer $WHATSAPP_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
        "messaging_product": "whatsapp",
        "to": "965XXXXXXXX",
        "text": { "body": "Hello from MedicalSupplierz!" }
      }'

🔹 Step 6. Token Lifetime & Refresh

  • System user tokens are long-lived (permanent), but they can be invalidated if:

    • You remove the system user.

    • You change business security settings.

  • Best practice: Store the token securely and rotate it periodically.


✅ After this, you’ll have a permanent token that won’t expire every 24 hours, unlike the test tokens.