Setting up a LEMP stack (Linux, Nginx, Ma
riaDB/MySQL, and PHP) on Puppy Linux is a bit different than on Ubuntu or Debian because Puppy is designed to be lightweight and often runs as root by default.
Since you mentioned you create web pages in HTML and PHP, having a local LEMP stack on Puppy is a great way to test your code in a fast, minimal environment.
- Update the Package Manager
Before installing anything, ensure your package database is current. Open the terminal and run:
pkg update
(Note: Depending on your version of Puppy, you might use ppm (Puppy Package Manager) via the GUI, but the terminal is often more reliable for server setups.)
- Install Nginx (The Web Server)
Nginx is the “E” in LEMP (pronounced Engine-X).
- Search for and install Nginx via the Package Manager or terminal.
- Start the service:
nginx - Verify: Open your browser and go to http://localhost. You should see the “Welcome to nginx” page.
- Install MariaDB (The Database)
Puppy usually favors MariaDB over MySQL because it’s open-source and efficient.
- Install mariadb and mariadb-client.
- Initialize the system tables:
mysql_install_db –user=mysql - Start the daemon:
/etc/init.d/rc.mysql start - Secure your installation (set a password):
mysql_secure_installation
- Install PHP (The Processor)
For Nginx to handle your PHP files, you need PHP-FPM (FastCGI Process Manager).
- Install php, php-fpm, and php-mysql.
- Locate your php-fpm.conf or http://www.conf (usually in /etc/php/). Ensure it is set to listen on a socket or 127.0.0.1:9000.
- Start PHP-FPM:
php-fpm
- Configure Nginx to use PHP
This is the most critical step for your web development workflow. You need to edit the Nginx configuration file (usually found at /etc/nginx/nginx.conf).
Find the server block and ensure it looks like this:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html; # This is where your PHP/HTML files go
index index.php index.html index.htm; location / {
try_files $uri $uri/ =404;
} Pass PHP scripts to FastCGI server location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
} - Testing Your Stack
To confirm everything is working for your PHP projects:
- Create a test file in your root directory:
echo “” > /usr/share/nginx/html/info.php - Visit http://localhost/info.php in your browser.
Important Puppy Linux Tips - Save Sessions: Since Puppy often runs in RAM, ensure you perform a “Save” to your pup_save file so your LEMP configurations aren’t lost on reboot.
- Permissions: Since Puppy usually runs as root, be careful when deploying these files to a live production server later, where permissions (like www-data) are much stricter.
Would you like me to help you write a script to automatically start Nginx, MariaDB, and PHP-FPM every time you boot Puppy Linux?
Since Puppy Linux uses a unique init system, the easiest way to ensure your LEMP stack starts automatically is by adding a small script to your Startup directory. This directory executes everything inside it once the desktop environment loads.
Step 1: Create the Startup Script
Open your terminal and create a new script file:
geany /root/Startup/start-lemp.sh
Step 2: Add the Commands
Copy and paste the following code into the file. This script checks if the services are running and starts them if they aren’t:
#!/bin/sh
# Start MariaDB/MySQL
if [ -f /etc/init.d/rc.mysql ]; then
/etc/init.d/rc.mysql start
fi
# Start PHP-FPM
# Note: Path may vary based on PHP version (e.g., /usr/sbin/php-fpm)
php-fpm &
# Start Nginx
nginx
Step 3: Make it Executable
For Puppy to run this file on boot, you must change its permissions. Run this in the terminal:
chmod +x /root/Startup/start-lemp.sh
Managing Your Workflow
Now, every time you boot into your Puppy Linux save session, your environment for creating HTML and PHP pages will be ready immediately.
| Component | Default Configuration Path | Default Web Root |
|—|—|—|
| Nginx | /etc/nginx/nginx.conf | /usr/share/nginx/html |
| PHP | /etc/php/php.ini | N/A |
| MariaDB | /etc/my.cnf | /var/lib/mysql |
A Quick Tip for PHP Development
Since you create informational web pages, you might find it helpful to see errors immediately while coding. You can enable this by editing your php.ini file:
* Search for display_errors = Off.
* Change it to display_errors = On.
* Restart PHP-FPM by running killall php-fpm && php-fpm.
Would you like a template for a PHP database connection script to quickly link your new pages to MariaDB?
Since Puppy Linux uses a unique init system, the easiest way to ensure your LEMP stack starts automatically is by adding a small script to your Startup directory. This directory executes everything inside it once the desktop environment loads.
Step 1: Create the Startup Script
Open your terminal and create a new script file:
geany /root/Startup/start-lemp.sh
Step 2: Add the Commands
Copy and paste the following code into the file. This script checks if the services are running and starts them if they aren’t:
!/bin/sh
Start MariaDB/MySQL
if [ -f /etc/init.d/rc.mysql ]; then
/etc/init.d/rc.mysql start
fi
Start PHP-FPM
Note: Path may vary based on PHP version (e.g., /usr/sbin/php-fpm)
php-fpm &
Start Nginx
nginx
Step 3: Make it Executable
For Puppy to run this file on boot, you must change its permissions. Run this in the terminal:
chmod +x /root/Startup/start-lemp.sh
Managing Your Workflow
Now, every time you boot into your Puppy Linux save session, your environment for creating HTML and PHP pages will be ready immediately. Component Default Configuration Path Default Web Root Nginx /etc/nginx/nginx.conf /usr/share/nginx/html PHP /etc/php/php.ini N/A MariaDB /etc/my.cnf /var/lib/mysql A Quick Tip for PHP Development Since you create informational web pages, you might find it helpful to see errors immediately while coding. You can enable this by editing your php.ini file:
- Search for display_errors = Off.
- Change it to display_errors = On.
- Restart PHP-FPM by running killall php-fpm && php-fpm.
Would you like a template for a PHP database connection script to quickly link your new pages to MariaDB
Leave a Reply