Setting Up Cockpit on a VPS Print

  • 0

While simple, cheap shared webhosting is recommended for most Cockpit installations due to easier management and pre-configured environments, this guide covers setup instructions for different VPS types. Choose the section relevant to your specific VPS environment.

Before You Begin

For all VPS types, ensure you have:

  • Root or sudo access to your server
  • Basic command line knowledge
  • A domain or subdomain pointing to your server's IP (optional but recommended)

Ubuntu/Debian VPS Setup

1. Update Your System

sudo apt update
sudo apt upgrade -y

2. Install Apache, PHP, and Required Extensions

# Install Apache
sudo apt install apache2 -y

# Install PHP and common extensions
sudo apt install php libapache2-mod-php php-cli php-common php-curl php-json php-mbstring php-xml php-zip php-sqlite3 -y

# Check PHP version
php -v

3. Install ionCube Loader

# Create directory for ionCube
mkdir ~/ioncube
cd ~/ioncube

# Download ionCube Loaders
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

# Extract the archive
tar -xvzf ioncube_loaders_lin_x86-64.tar.gz

# Find PHP extension directory
php -i | grep extension_dir

# Copy the appropriate loader (adjust for your PHP version)
# For PHP 7.4 example:
sudo cp ioncube/ioncube_loader_lin_7.4.so /usr/lib/php/20190902/

# Create configuration file
sudo bash -c 'echo "zend_extension = /usr/lib/php/20190902/ioncube_loader_lin_7.4.so" > /etc/php/7.4/apache2/conf.d/00-ioncube.ini'
sudo bash -c 'echo "zend_extension = /usr/lib/php/20190902/ioncube_loader_lin_7.4.so" > /etc/php/7.4/cli/conf.d/00-ioncube.ini'

4. Configure Apache

# Enable required modules
sudo a2enmod rewrite
sudo a2enmod headers

# Edit Apache configuration
sudo nano /etc/apache2/apache2.conf

Find the <Directory /var/www/html> section and change AllowOverride None to AllowOverride All

# Restart Apache
sudo systemctl restart apache2

5. Set Up Cockpit

# Navigate to web directory
cd /var/www/html

# Create directory for Cockpit
sudo mkdir cockpit
sudo chown www-data:www-data cockpit
cd cockpit

# Upload Cockpit files (via FTP or SCP)
# Then set proper permissions
sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;

CentOS/RHEL VPS Setup

1. Update Your System

sudo yum update -y

2. Install Apache, PHP, and Required Extensions

# Install Apache
sudo yum install httpd -y

# Install EPEL repository
sudo yum install epel-release -y

# For CentOS/RHEL 8:
# Install Remi repository for PHP 7.4+
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
sudo yum module enable php:remi-7.4 -y

# For CentOS/RHEL 7:
# Install Remi repository for PHP 7.4+
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum-config-manager --enable remi-php74

# Install PHP and extensions
sudo yum install php php-cli php-common php-curl php-json php-mbstring php-xml php-zip php-sqlite3 -y

# Start and enable Apache
sudo systemctl start httpd
sudo systemctl enable httpd

3. Install ionCube Loader

# Create directory for ionCube
mkdir ~/ioncube
cd ~/ioncube

# Download ionCube Loaders
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

# Extract the archive
tar -xvzf ioncube_loaders_lin_x86-64.tar.gz

# Find PHP extension directory
php -i | grep extension_dir

# Copy the loader (adjust for your PHP version)
sudo cp ioncube/ioncube_loader_lin_7.4.so /usr/lib64/php/modules/

# Create configuration file
sudo echo "zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_7.4.so" > /etc/php.d/00-ioncube.ini

4. Configure Apache

# Configure firewall
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

# Edit Apache configuration
sudo nano /etc/httpd/conf/httpd.conf

Find all <Directory> sections and change AllowOverride None to AllowOverride All

# Restart Apache
sudo systemctl restart httpd

Common Steps for All VPS Types

Setting Up Cockpit

# Navigate to web directory (Linux paths shown)
cd /var/www/html  # For Ubuntu/Debian/CentOS
# or
cd /var/www/localhost/htdocs  # For Alpine

# Create directory for Cockpit
sudo mkdir cockpit
sudo chown www-data:www-data cockpit  # For Ubuntu/Debian
# or
sudo chown apache:apache cockpit  # For CentOS/RHEL

cd cockpit

# Upload Cockpit files (via FTP, SCP, or wget from your download URL)
# Then set proper permissions
sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;

Verify Installation

  1. Visit your domain or server IP in a browser: http://your-server-ip/cockpit or https://yourdomain.com/cockpit
  2. Complete the initial setup process
  3. Verify that ionCube Loader is working properly by checking the PHP info page or Cockpit's system information

Important Notes and Best Practices

  • Security: Configure a firewall (UFW for Ubuntu, firewalld for CentOS)
  • Updates: Keep your server updated with security patches
  • Backups: Regularly backup your Cockpit installation and SQLite database
  • Monitoring: Consider setting up server monitoring to track performance and uptime
  • Alternative Option: If VPS setup seems complicated, consider using shared hosting which typically has all required components pre-installed

Remember, while a VPS offers more control, it also requires more technical expertise to manage properly. For many users, shared hosting remains the simpler and recommended option for running Cockpit.


Was this answer helpful?

« Back