System Documentation
Lightweight PHP CMS — Fast, Secure, Elegant
Welcome to Lighttp — the lightweight content management system.
Lighttp is a high-performance, secure, and elegant CMS built with PHP, MySQL, and Redis. It is designed for developers and content creators who value speed, code quality, and simplicity.
| Component | Version |
|---|---|
| Web Server | Nginx 1.18+ / Apache 2.4+ |
| PHP | 7.4, 8.0, 8.1, 8.2, 8.3 |
| MySQL | 5.7+ / MariaDB 10.3+ |
| Redis | 5.0+ |
| Memory | 512MB minimum, 1GB recommended |
| Disk Space | 100MB minimum |
php-mysql — PDO MySQL driverphp-redis — Redis extensionphp-mbstring — Multibyte string supportphp-json — JSON handlingphp-curl — HTTP requests (recommended)php-gd — Image processing (optional)php-opcache — Performance optimization# Check installed PHP extensions
php -m | grep -E "mysql|redis|mbstring|json|curl"
# Step 1: Create project via Composer composer create-project lighttp/cms my-site # Step 2: Navigate to project directory cd my-site # Step 3: Run installation script php lighttp install # Step 4: Follow interactive prompts # - Enter database credentials # - Set admin username and password # - Configure Redis settings # Step 5: Start development server php -S localhost:8080 -t public
# Step 1: Clone the source code git clone https://github.com/Drliehuo/inetpub.github.io/tree/main/lighttp/src my-site cd my-site # Step 2: Install dependencies composer install --no-dev # Step 3: Configure environment cp .env.example .env nano .env # Edit database and Redis settings # Step 4: Run database migration php lighttp migrate # Step 5: Create admin user php lighttp user:create admin admin@example.com password123 # Step 6: Set file permissions chmod -R 755 var/ chmod -R 755 public/uploads/
server {
listen 80;
server_name your-domain.com;
root /var/www/lighttp/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
<VirtualHost *:80>
ServerName your-domain.com
DocumentRoot /var/www/lighttp/public
<Directory /var/www/lighttp/public>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
APP_DEBUG=false in your .env file.
Lighttp follows a clean and organized directory structure:
/ ├── app/ │ ├── core/ # Core framework classes │ │ ├── Application.php │ │ ├── Database.php │ │ └── RedisCache.php │ ├── controllers/ # Application controllers │ │ ├── HomeController.php │ │ ├── AdminController.php │ │ └── AuthController.php │ ├── models/ # Data models │ │ ├── Article.php │ │ ├── Category.php │ │ └── User.php │ ├── config/ # Configuration files │ │ └── config.php │ └── routes.php # Route definitions ├── public/ # Web root directory │ ├── index.php # Entry point │ ├── .htaccess # Apache rewrite rules │ ├── css/ # Stylesheets │ ├── js/ # JavaScript files │ └── uploads/ # User uploaded files ├── var/ # Runtime data │ ├── cache/ # Cache storage │ ├── logs/ # Application logs │ └── sessions/ # Session storage ├── .env # Environment configuration └── composer.json # Composer dependencies
All configuration is managed through the .env file and app/config/config.php.
# Database Configuration DB_HOST=localhost DB_PORT=3306 DB_NAME=lighttp DB_USER=root DB_PASS=your_password # Redis Configuration REDIS_HOST=127.0.0.1 REDIS_PORT=6379 REDIS_PASSWORD= REDIS_DATABASE=0 # Application Settings APP_NAME=Lighttp APP_DEBUG=true APP_TIMEZONE=Asia/Shanghai APP_PER_PAGE=10
return [ 'database' => [ 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', 3306), 'database' => env('DB_NAME', 'lighttp'), 'username' => env('DB_USER', 'root'), 'password' => env('DB_PASS', ''), 'charset' => 'utf8mb4', ], 'cache' => [ 'enabled' => true, 'host' => env('REDIS_HOST', '127.0.0.1'), 'port' => env('REDIS_PORT', 6379), 'prefix' => 'lighttp:', 'default_ttl' => 3600, ], 'app' => [ 'name' => env('APP_NAME', 'Lighttp'), 'debug' => env('APP_DEBUG', false), 'timezone' => env('APP_TIMEZONE', 'UTC'), 'per_page' => env('APP_PER_PAGE', 10), ], ];
env() helper function to access environment variables throughout your application.
Lighttp uses MySQL/MariaDB with PDO for database operations. The system includes 12 core tables:
| Table | Description |
|---|---|
articles | Content articles and posts |
categories | Content categories |
users | User accounts |
comments | User comments |
pages | Static pages |
links | Friend links |
settings | System settings |
cache | Database cache (fallback) |
logs | Audit logs |
sessions | User sessions |
tags | Content tags |
article_tags | Article-tag relationships |
# Run all migrations php lighttp migrate # Rollback last migration php lighttp migrate:rollback # Check migration status php lighttp migrate:status
The admin dashboard provides a comprehensive interface for managing your content and system settings.
https://your-domain.com/admin
| Field | Value |
|---|---|
| Username | admin |
| Password | admin123 |
Articles are the primary content type in Lighttp. Each article includes:
# Via command line php lighttp article:create "My First Article" --content="Full content here" --category=1 # Via web interface # Navigate to /admin/article/create
Categories help organize articles. Features include:
Static pages for content like About, Contact, and Privacy Policy.
Lighttp includes a complete user management system with role-based permissions.
| Role | Permissions |
|---|---|
admin | Full system access, user management, settings |
editor | Create and manage all content |
author | Create and manage own content |
subscriber | Read-only access |
# Create a new user php lighttp user:create username email password # Change user password php lighttp user:password username newpassword # List all users php lighttp user:list # Delete a user php lighttp user:delete username
Lighttp uses Redis for powerful multi-level caching.
# Clear all cache php lighttp cache:clear # Clear page cache only php lighttp cache:clear --type=page # Clear data cache only php lighttp cache:clear --type=data # Check cache status php lighttp cache:status
return [ 'cache' => [ 'enabled' => true, 'host' => '127.0.0.1', 'port' => 6379, 'prefix' => 'lighttp:', 'default_ttl' => 3600, // 1 hour ], ];
Lighttp implements multiple security layers to protect your content and users.
# Always set APP_DEBUG=false in production APP_DEBUG=false # Use strong passwords (min 12 characters, mixed case) # Keep system and PHP updated # Use HTTPS/SSL in production # Regularly backup database # Monitor access logs
Lighttp provides a RESTful API for content management and integration.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/articles | List all articles |
| GET | /api/articles/{id} | Get article by ID |
| POST | /api/articles | Create new article |
| PUT | /api/articles/{id} | Update article |
| DELETE | /api/articles/{id} | Delete article |
| GET | /api/categories | List all categories |
| GET | /api/users | List users (admin only) |
API uses Bearer token authentication:
# Example request curl -X GET https://your-domain.com/api/articles \ -H "Authorization: Bearer your_api_token"
{
"status": "success",
"data": {
"id": 1,
"title": "Sample Article",
"content": "Full article content...",
"created_at": "2026-06-22 10:00:00"
}
}
sudo systemctl status mysql.env filemysql -u user -p -h hostredis-cli ping.envphp -m | grep redispublic/ is set as document root.htaccess or Nginx rewrite ruleschown -R www-data:www-data var/chmod -R 755 var/chmod -R 777 var/sessions/composer dump-autoloadvar/logs/ directory for detailed error information.
| Item | Details |
|---|---|
| Developer | Dr.liehuo (烈火帝君) |
| webmaster@inetpub.cn | |
| License | MIT Open Source |
| Repository | https://github.com/Drliehuo/inetpub.github.io/tree/main/lighttp/src |
We welcome contributions from the community! Please read our contributing guidelines before submitting pull requests.