You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为我的Digital Ocean服务器部署cPanel并按项目配置PHP版本?

Hey there, let’s break down exactly how to get cPanel up and running on your DigitalOcean Droplet so you can manage PHP versions and other project-specific configs with ease.

Step 1: Prep Your Droplet for cPanel

First off, make sure your Droplet meets cPanel’s system requirements—this is non-negotiable for a smooth install:

  • Use a supported OS: AlmaLinux 8, CentOS 7, or CloudLinux 8 (cPanel doesn’t fully support Ubuntu/Debian, so stick to these).
  • Allocate at least 2GB of RAM (1GB works but might cause performance hiccups) and 20GB of disk space.
  • If you’re using an existing Droplet, stop and disable any pre-installed web servers (Apache/Nginx) since cPanel will deploy its own stack:
    systemctl stop httpd nginx
    systemctl disable httpd nginx
    
Step 2: Install cPanel & WHM

Log into your Droplet as root via SSH, then run the official installation script. Grab a coffee—this takes 15-30 minutes depending on your Droplet’s speed:

cd /home && curl -o latest -L https://securedownloads.cpanel.net/latest && sh latest

Once the script finishes, reboot your Droplet to lock in all changes:

reboot
Step 3: Configure WHM (Web Host Manager)

After rebooting, access WHM by navigating to https://your-droplet-ip:2087 (note the HTTPS and port 2087—you’ll see a security warning, just proceed since it’s your server).
Walk through the initial setup wizard:

  • Set a valid hostname (e.g., server.yourdomain.com) and make sure it points to your Droplet’s IP via DNS.
  • Configure nameservers (you can use DigitalOcean’s default ones or set up custom ones through WHM).
  • Enter an admin email to receive server alerts and updates.
Step 4: Manage Custom PHP Versions per Project

This is the part you care about—tweaking PHP versions for individual projects:

  1. In WHM, go to EasyApache 4 (under the Software section). Here, install all the PHP versions you need (e.g., 7.4, 8.1, 8.2).
  2. Create a cPanel account for each project (use Create a New Account in WHM).
  3. Log into the project’s cPanel dashboard, then head to Select PHP Version under Software:
    • Pick the exact PHP version for that project.
    • You can also customize php.ini settings (like memory limit, upload max size) directly from this interface.
  4. For even more control (per-directory PHP versions), add this line to your project’s .htaccess file:
    AddHandler application/x-httpd-php81 .php
    
    Just replace php81 with the version you want to use for that directory.
Step 5: Migrate Your Existing Website Code

Now get your site onto the cPanel server:

  • Use cPanel’s File Manager to upload files directly to the public_html folder of your project’s account.
  • Or enable FTP/SFTP access (via FTP Accounts in cPanel) to transfer files from your local machine.
  • Finally, update your domain’s DNS records to point to your Droplet’s IP so visitors can reach your site.
Quick Heads-Up
  • cPanel requires a license. You can grab a 15-day free trial from cPanel, or add a license directly through DigitalOcean when creating your Droplet.
  • Keep WHM/cPanel updated regularly (check Update Preferences in WHM) to stay secure and get new features.
  • If you hit snags during install, check the log file at /var/cpanel/logs/install_log for troubleshooting clues.

内容的提问来源于stack exchange,提问作者Vikas Ukani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:41:34