| api | ||
| assets | ||
| data | ||
| includes | ||
| .gitignore | ||
| admin_logs.php | ||
| admin_users.php | ||
| change_password.php | ||
| check_database.php | ||
| config.php | ||
| forgot_password.php | ||
| index.php | ||
| install.php | ||
| install.sh | ||
| LICENSE | ||
| login.php | ||
| migrate_database.php | ||
| migrate_db.php | ||
| README.md | ||
| register.php | ||
| reset_password.php | ||
| settings.php | ||
| setup_2fa.php | ||
| verify_2fa.php | ||
🤖 Ollama PHP WebUI Clone
A secure, feature-rich web interface for Ollama AI models built with PHP. No Node.js required - just pure PHP with SQLite database for easy deployment.
✨ Key Features
🔐 Advanced Security
- Two-Factor Authentication (2FA) with QR code setup
- Secure password management with strength requirements
- Password reset via email with token-based system
- Session timeout protection
- Login attempt logging with IP tracking and user agent
- User account status management (active/disabled)
- Role-based access control (Admin/User)
💬 Chat Management
- Multiple chat conversations with sidebar navigation
- Message history persistence in SQLite database
- File attachments support (documents, images, code files)
- Real-time streaming responses
- Markdown rendering with syntax highlighting
- Code block formatting with Highlight.js
🌐 Flexible Model Access
- Local Ollama server support with custom URL configuration
- Ollama Cloud integration for cloud-based models
- Dual-mode operation: Use local models OR cloud models
- API key management for cloud services
- Model selection interface with available models listing
👥 User Management (Admin)
- User creation and deletion
- Role assignment (User/Admin)
- Account activation/deactivation
- 2FA reset for users
- Email management
- User statistics dashboard
📊 Monitoring & Logging
- Access logs with timestamps, IP addresses, and status
- Login attempt tracking (success, failed, pending 2FA)
- Filtering and search capabilities
- Statistics dashboard with visual indicators
- User activity monitoring
🛠️ Administration Tools
- Database diagnostics page
- Migration system for database updates
- System information dashboard
- Connection testing for Ollama servers
- Configuration management interface
📋 Requirements
- PHP 7.4 or higher
- SQLite3 extension for PHP
- cURL extension for PHP
- JSON extension for PHP
- Web server (Apache, Nginx, or PHP built-in server)
Optional:
- Local Ollama installation (if not using cloud mode)
- Mail server for password reset functionality
🚀 Quick Installation
1. Clone or Download
git clone https://github.com/yourusername/ollama-php-webui.git
cd ollama-php-webui
2. Set Permissions
chmod 755 data/
chmod 755 uploads/
3. Initial Setup
Open your browser and navigate to:
http://localhost/ollama-php-webui/install.php
4. First Login
- Username:
admin - Password:
admin
⚠️ Important: Change the default password immediately after first login!
⚙️ Configuration
Local Ollama Server
- Navigate to Settings → General Configuration
- Enter your Ollama server URL (e.g.,
http://localhost:11434) - Click Test Connection to verify
- Save settings
Ollama Cloud Mode
- Get your API key from ollama.com
- Navigate to Settings → Ollama Cloud Setup
- Enable cloud mode
- Enter your API key
- Save settings
The system will automatically detect available cloud models.
📁 Project Structure
ollama-php-webui/
├── api/ # API endpoints
│ ├── auth.php # Authentication
│ ├── chat.php # Chat operations
│ ├── models.php # Model management
│ └── upload.php # File uploads
├── assets/
│ ├── css/
│ │ └── main.css # Styling
│ └── js/
│ └── app.js # Frontend logic
├── data/
│ ├── database.sqlite # SQLite database
│ └── ollama_url.json # Server configuration
├── includes/
│ ├── Auth.php # Authentication class
│ ├── Database.php # Database handler
│ ├── OllamaClient.php # Ollama API client
│ ├── TwoFactorAuth.php # 2FA implementation
│ └── CloudManager.php # Cloud integration
├── uploads/ # User-uploaded files
├── vendor/ # Dependencies
├── admin_logs.php # Access logs viewer
├── admin_users.php # User management
├── change_password.php # Password change
├── check_database.php # DB diagnostics
├── config.php # Configuration
├── forgot_password.php # Password recovery
├── index.php # Main chat interface
├── install.php # Installation wizard
├── login.php # Login page
├── register.php # User registration
├── reset_password.php # Password reset
├── settings.php # Settings page
├── setup_2fa.php # 2FA setup
└── verify_2fa.php # 2FA verification
🗄️ Database Structure
The application uses SQLite with the following main tables:
- users - User accounts with 2FA support
- chats - Chat conversations
- messages - Chat messages with file attachments
- message_files - File attachment metadata
- settings - Application settings
- login_logs - Authentication logging
- password_resets - Password reset tokens
- two_factor_sessions - Temporary 2FA sessions
Database Migration
If you're upgrading from an older version:
php migrate_database.php
Or visit: http://localhost/ollama-php-webui/migrate_database.php
🔒 Security Features
Password Requirements
- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one number
- Password strength indicator
Two-Factor Authentication
- Navigate to Settings → 2FA Authentication
- Scan QR code with authenticator app (Google Authenticator, Authy, etc.)
- Enter verification code
- 2FA is now active for your account
Session Management
- Automatic session timeout (configurable)
- Secure session handling
- CSRF protection
- Password verification for critical operations
👤 User Roles
Admin
- Full system access
- User management
- View all access logs
- System configuration
- Database diagnostics
User
- Personal chat access
- Own message history
- Personal settings
- Own access logs only
- Password change
- 2FA management
📊 Admin Dashboard Features
User Management
- Create/delete users
- Enable/disable accounts
- Assign admin roles
- Reset user 2FA
- View user statistics
Access Logs
- Filter by username, status, date range
- View IP addresses and user agents
- Track login attempts (successful, failed, pending 2FA)
- Export capabilities
- Real-time statistics
Database Diagnostics
- Table structure verification
- Missing column detection
- User count and role distribution
- 2FA adoption statistics
- System information display
🌐 API Endpoints
Authentication
POST /api/auth.php?action=login- User loginPOST /api/auth.php?action=logout- User logoutPOST /api/auth.php?action=verify_2fa- 2FA verification
Chat
GET /api/chat.php?action=list- List user chatsPOST /api/chat.php?action=create- Create new chatGET /api/chat.php?action=messages&chat_id=X- Get messagesPOST /api/chat.php?action=send- Send messageDELETE /api/chat.php?action=delete&chat_id=X- Delete chat
Models
GET /api/models.php- Get available modelsGET /api/models.php?cloud=1- Get cloud models
Files
POST /api/upload.php- Upload file attachmentGET /api/download.php?id=X- Download file
🔧 Advanced Configuration
Custom Ollama URL
Edit data/ollama_url.json:
{
"url": "http://your-ollama-server:11434"
}
Session Timeout
Edit config.php:
define('SESSION_TIMEOUT', 3600); // seconds
Cloud Configuration
Stored in database settings table:
cloud_enabled- Enable/disable cloud modeollama_api_key- Your Ollama cloud API key
🎨 Customization
Themes
The application uses CSS custom properties for easy theming. Edit assets/css/main.css:
:root {
--sidebar-bg: #171717;
--main-bg: #0d0d0d;
--message-text: #ffffff;
--accent-color: #10a37f;
/* ... more variables ... */
}
Branding
Change application name in config.php:
define('APP_NAME', 'Your Custom Name');
define('APP_VERSION', '1.0.0');
🐛 Troubleshooting
Database Issues
Visit the diagnostic page:
http://localhost/ollama-php-webui/check_database.php
Connection Problems
- Test local Ollama:
Settings→Test Local Connection - Check Ollama is running:
ollama serve - Verify URL configuration
- Check firewall settings
Permission Errors
chmod 755 data/
chmod 666 data/database.sqlite
chmod 755 uploads/
2FA Issues
Admins can reset user 2FA from the User Management page.
📝 Usage Tips
File Attachments
- Supported: Documents, images, code files
- Maximum size configurable in
upload.php - Files stored in
uploads/directory - Linked to specific messages
Chat Organization
- Create separate chats for different topics
- Rename chats for better organization
- Delete old chats to maintain performance
- Export/backup important conversations
Performance
- SQLite performs well for < 10 simultaneous users
- For larger deployments, consider MySQL migration
- Regular database maintenance recommended
- Monitor
uploads/directory size
🤝 Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Ollama team for the amazing AI platform
- PHP community for robust libraries
- Contributors and testers
📞 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@example.com
🗺️ Roadmap
- MySQL/PostgreSQL support
- Multi-language interface
- Advanced chat export (PDF, Markdown)
- Plugin system
- API rate limiting
- Conversation sharing
- Mobile app companion
- Docker container
- Kubernetes deployment guides
Made with ❤️ for the Ollama community
Last updated: November 2025