Category Archive Knowledgebase

ByJUJU-dev

How to – PHP Loaders

How to – PHP Loaders

What are PHP Loaders and what is their role?

PHP Loaders are a type of library or framework that allows you to load data into a PHP application. They play a crucial role in separating the data from the application logic, making it easier to manage, maintain, and scale your codebase.

What is a PHP Loader?

A PHP Loader is a PHP class or module that loads data into your application. It’s responsible for reading data from various sources, such as databases, files, or APIs, and providing it to your application in a structured and organized manner.

Role of a PHP Loader:

  1. Data Retrieval: Loaders retrieve data from various sources, such as databases, files, or APIs.
  2. Data Transformation: Loaders transform the retrieved data into a format that can be easily consumed by your application.
  3. Data Filtering: Loaders can filter the data to only include relevant information, reducing the amount of data that needs to be processed.
  4. Data Caching: Loaders can cache frequently accessed data to improve performance and reduce the load on your application.
  5. Data Validation: Loaders can validate the retrieved data to ensure it meets certain criteria or conforms to specific formats.
  6. Data Processing: Loaders can perform complex data processing tasks, such as data aggregation, calculations, or transformations.

Types of PHP Loaders:

  1. Database Loaders: Load data from relational databases like MySQL or PostgreSQL.
  2. File Loaders: Load data from files, such as CSV, JSON, or XML files.
  3. API Loaders: Load data from APIs, such as RESTful APIs or SOAP web services.
  4. Cache Loaders: Load data from caching mechanisms like Redis or Memcached.
  5. Filesystem Loaders: Load data from file systems, such as loading files or directories.

Benefits of using PHP Loaders:

  1. Separation of Concerns: Separate data retrieval and processing from application logic.
  2. Reusability: Reuse loaders across multiple applications or projects.
  3. Flexibility: Easily switch between different data sources or formats.
  4. Scalability: Improve performance by offloading data processing and caching.
  5. Maintenance: Simplify maintenance and updates by separating concerns.

Popular PHP Loaders:

  1. Doctrine DBAL (Database Abstraction Layer)
  2. Symfony’s Doctrine Bundle
  3. Laravel’s Eloquent ORM (Object-Relational Mapping)
  4. PDO (PHP Data Objects)
  5. PHP-CSV (CSV File Loader)

In summary, PHP Loaders play a vital role in loading data into your PHP application by providing a flexible and reusable way to separate concerns, improve performance, and simplify maintenance.

How can I enable PHP loaders:

Enabling PHP Loaders involves a few steps, depending on the type of loader you want to use and the PHP version you’re running. Here’s a general guide:

1. Install a PHP Loader:

You can install a PHP Loader using various methods:

  • PEAR: PHP Extension and Application Repository (PEAR) is a package manager for PHP. You can install PEAR using the command pear install php_loader and then enable the loader by adding extension=php_loader.so (or .dll on Windows) to your php.ini file.
  • Composer: Composer is a popular package manager for PHP. You can install a PHP Loader using Composer by running the command composer require php-loader/php-loader.
  • PECL: PECL (PHP Extension Community Library) is a package manager for PHP extensions. You can install PECL using the command pecl install php_loader and then enable the loader by adding extension=php_loader.so (or .dll on Windows) to your php.ini file.

2. Enable the Loader in Your PHP Configuration File:

Once you’ve installed the loader, you need to enable it in your PHP configuration file (php.ini). Open the file and add the following line:

extension=php_loader.so

or

extension=php_loader.dll

Save the changes to the file and restart your web server or PHP-FPM service.

3. Configure the Loader:

After enabling the loader, you’ll need to configure it. The configuration options vary depending on the loader you’re using. Here are some common options:

  • PHP Loaders: You can configure the loader using environment variables or an INI file. For example, you can set the loader.cache_dir variable to specify the directory where cached files will be stored.
  • Symfony’s Doctrine ORM: If you’re using Symfony’s Doctrine ORM, you’ll need to configure it in your doctrine.yml file.

4. Test Your Loader:

Once you’ve enabled and configured the loader, test it by creating a new PHP script that uses the loader. For example:

<?php

require_once 'autoload.php';

echo 'Hello, World!';

This script should output “Hello, World!” if the loader is working correctly.

Remember to check your PHP version compatibility before installing and configuring a PHP Loader. Some loaders may only work with specific versions of PHP.

 

 

ByJUJU-dev

How to change PHP version on Business servers

Changing the PHP version on a business server can be a bit more complex than on a shared hosting environment, as it requires manually editing configuration files and restarting services. Here’s a step-by-step guide on how to change the PHP version on a business server:

Step 1: Identify the current PHP version

  • Log in to your business server using SSH or your preferred method.
  • Check the current PHP version by running the command php -v or php --version.
  • Note down the current PHP version, as you’ll need it later.

Step 2: Update the package manager

  • If you’re using an RPM-based distribution like CentOS or RHEL, update the package manager (Yum) by running the command sudo yum update.
  • If you’re using a DEB-based distribution like Ubuntu or Debian, update the package manager (Apt) by running the command sudo apt-get update.

Step 3: Install the new PHP version

  • Use your package manager to install the desired PHP version. For example:
    • RPM-based distributions: sudo yum install php71w-fpm (for PHP 7.1) or sudo yum install php73-fpm (for PHP 7.3).
    • DEB-based distributions: sudo apt-get install php7.1-fpm (for PHP 7.1) or sudo apt-get install php7.3-fpm (for PHP 7.3).

Step 4: Enable the new PHP version

  • Create a symbolic link to the new PHP version:
    • RPM-based distributions: sudo ln -s /opt/rh/php71/root/usr/bin/php /usr/bin/php71 (for PHP 7.1) or sudo ln -s /opt/rh/php73/root/usr/bin/php /usr/bin/php73 (for PHP 7.3).
    • DEB-based distributions: sudo update-alternatives --install /usr/bin/php php /usr/lib/php/7.1/bin/php 1 (for PHP 7.1) or sudo update-alternatives --install /usr/bin/php php /usr/lib/php/7.3/bin/php 1 (for PHP 7.3).

Step 5: Set the default PHP version

  • Update the default PHP version by running:
    • RPM-based distributions: sudo alternatives --set php /usr/bin/php71 (for PHP 7.1) or sudo alternatives --set php /usr/bin/php73 (for PHP 7.3).
    • DEB-based distributions: sudo update-alternatives --set php /usr/lib/php/7.1/bin/php (for PHP 7.1) or sudo update-alternatives --set php /usr/lib/php/7.3/bin/php (for PHP 7.3).

Step 6: Restart services

  • Restart the Apache or Nginx service to apply the changes:
    • RPM-based distributions: sudo systemctl restart httpd
    • DEB-based distributions: sudo service apache2 restart

Step 7: Verify the new PHP version

  • Run the command php -v or php --version again to verify that the new PHP version is active.

That’s it! You’ve successfully changed the PHP version on your business server.

Remember to test your website and applications after changing the PHP version to ensure everything is working as expected.

ByJUJU-dev

Telnet Definition

Telnet Definition

Telnet Definition

Telnet Definition

What is Telnet?
Telnet is a user command and an underlying TCP/IP protocol for accessing remote computers. Through Telnet, an administrator or another user can access someone else’s computer remotely. On the Web, HTTP and FTP protocols allow you to request specific files from remote computers, but not to actually be logged on as a user of that computer. With Telnet, you log on as a regular user with whatever privileges you may have been granted to the specific application and data on that computer.A Telnet command request looks like this (the computer name is made-up):

telnet library.jujuhost.com

The result of this request would be an invitation to log on with a userid and a prompt for a password. If accepted, you would be logged on like any user who used this computer every day.

Telnet is most likely to be used by program developers and anyone who has a need to use specific applications or data located at a particular host computer.

ByJUJU-dev

How to get an SSH client

How to get an SSH client

How to get an SSH client
To access your account via SSH, you should download and install one of available SSH clients. You can find the list of free SSH clients in the table below. If you have Windows, we recommend to use PuTTY as your SSH client.

SSH Client Operating Systems Supported Download
PuTTY Windows and Unix
WinSCP Windows (SCP and SFTP, no SSH)
Fugu Macintosh

 

ByJUJU-dev

How to connect via SSH using keys

Connecting to a server via SSH using keys is a secure and convenient way to access your server without having to remember a password. Here’s a step-by-step guide on how to connect to a server via SSH using keys:

Prerequisites:

  • You have a Unix-based operating system (such as Linux or macOS) or a tool that allows you to use SSH, such as PuTTY on Windows.
  • You have generated a pair of SSH keys using a tool like OpenSSL or Git Bash.
  • You have the public key saved on your local machine and the private key saved on your server.

Step 1: Generate a pair of SSH keys

If you haven’t already, generate a pair of SSH keys using a tool like OpenSSL or Git Bash. The process is as follows:

  • Open Terminal or Git Bash.
  • Run the command ssh-keygen -t rsa -b 4096 (or ssh-keygen -t ed25519 for newer versions of OpenSSH).
  • Follow the prompts to create a new key pair.
  • Save the private key in a secure location, such as ~/.ssh/id_rsa (or ~/.ssh/id_ed25519 for newer versions of OpenSSH).
  • Save the public key in a file, such as ~/.ssh/id_rsa.pub (or ~/.ssh/id_ed25519.pub for newer versions of OpenSSH).

Step 2: Copy the public key to your server

Copy the contents of the public key file (id_rsa.pub or id_ed25519.pub) and add it to the authorized_keys file on your server. You can do this using SFTP, SCP, or by pasting it directly into the file using SSH.

Step 3: Configure SSH client

To connect to your server using SSH, you’ll need to configure your SSH client. The process is as follows:

  • On Linux/macOS, open Terminal and run the command ssh-add ~/.ssh/id_rsa (or ssh-add ~/.ssh/id_ed25519 for newer versions of OpenSSH).
  • On Windows, open PuTTY and load the private key file by clicking “File” > “Load private key” and selecting your private key file.

Step 4: Connect to your server

Use your configured SSH client to connect to your server. The command would be:

ssh user@your-server-ip-or-hostname

Replace user with your username and your-server-ip-or-hostname with your server’s IP address or hostname.

Tips and Variations:

  • Make sure to set the correct permissions on the authorized_keys file and ensure it’s only readable by the owner.
  • If you’re using a non-standard port for SSH, specify it in the connection command: ssh -p 2222 user@your-server-ip-or-hostname.
  • If you’re connecting from a corporate network or behind a firewall, you may need to configure your firewall rules or ask your network administrator for assistance.

By following these steps, you should be able to connect to your server via SSH using keys. This method provides an additional layer of security compared to traditional password-based authentication.

ByJUJU-dev

What is SSH?

What is SSH?

What is SSH?

Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices. The two major versions of the protocol are SSH-1 and SSH-2.

Shell is a program to log into another computer over a network to execute commands on a remote machine and to move files from one machine to another. It provides strong authentication and secure communications over insecure channels.

SSH was designed as a replacement for Telnet and other insecure remote shells (rlogin, rsh, rcp, and rdist), which send information, notably passwords, in plain text, rendering them susceptible to packet analysis. The encryption used by SSH is intended to provide confidentiality and integrity of data over an unsecured network, such as the Internet.

ByJUJU-dev

How to create and maintain MySQL Databases in cPanel

cPanel is a popular web hosting control panel that provides an intuitive interface for managing various aspects of your website, including MySQL databases. Here’s a step-by-step guide on how to create and maintain MySQL databases in cPanel:

Creating a MySQL Database:

  1. Log in to your cPanel account.
  2. In the “Databases” section, click on the “MySQL Databases” icon.
  3. Click on the “Create a New Database” button.
  4. Enter a name for your database in the “Database Name” field.
  5. Choose a prefix for the database (optional, but recommended for organization).
  6. Set a password for the database (or choose to use a randomly generated one).
  7. Click the “Create Database” button.

Managing Existing Databases:

  1. In the “Databases” section, click on the “MySQL Databases” icon.
  2. You will see a list of existing databases on your account.
  3. Click on the name of the database you want to manage.
  4. You can view detailed information about the database, including its size, owner, and creation date.
  5. Use the buttons at the top of the page to perform actions such as:
    • “Edit Privileges”: Change the database user password or add/remove users.
    • “Backup”: Create a backup of the database.
    • “Drop”: Delete the database.

Managing Users and Privileges:

  1. In the “Databases” section, click on the “MySQL Users” icon.
  2. You will see a list of existing MySQL users on your account.
  3. Click on the name of the user you want to manage.
  4. Use the buttons at the top of the page to perform actions such as:
    • “Reset Password”: Change the user’s password.
    • “Grant Privileges”: Grant or revoke privileges for specific databases or tables.
    • “Revoke Privileges”: Revoke all privileges for the user.

Backing Up and Restoring Databases:

  1. In the “Databases” section, click on the “Backups” icon.
  2. Click on the “Download” button next to your desired backup date to download a copy of your database.
  3. To restore a backup, click on the “Restore” button and select the backup file you want to restore.

Additional Tips:

  • cPanel provides a built-in tool called phpMyAdmin, which allows you to manage your databases using a web-based interface. You can access phpMyAdmin by clicking on the “phpMyAdmin” icon in your cPanel dashboard.
  • It’s essential to regularly back up your databases to prevent data loss in case of unexpected issues or security breaches.
  • Be cautious when granting privileges to MySQL users, as this can compromise your database security.

By following these steps, you should be able to create and manage your MySQL databases efficiently using cPanel.

ByJUJU-dev

How to access a hosting account via SSH

How to access a hosting account via SSH

To access your hosting account via SSH, you should:

1. Enable SSH access for your account in your web hosting panel.

2. Open your SSH client, put your domain name or the IP address of the server into the Host Name field (you can also use server name here, you can check it using this tutorial), enter 21098 into the Port field (22 for a VPS/Dedicated server), choose SSH as your connection type and press the Open button:

How to access a hosting account via SSH

3. You will receive the Putty Security Alert. Press OK:

How to access a hosting account via SSH

4. When prompted, enter your cPanel username and password (when you enter the password, it is automatically hidden for the security purposes):

That’s it!

ByJUJU-dev

How to use Manage Shell in cPanel

How to use Manage Shell in cPanel

Secure Shell (SSH) is a cryptographic network protocol that is used to log into the system via a secure channel. With the help of SSH, you can safely exchange data between two devices. For more detailed information, visit here.

Enabling SSH access allows for:

  • Remote hosting control
  • The ability to add, remove, edit, backup and restore hosting files and directories
  • The easy import and export of your database
  • An established connection between 2 different servers

However, there are some downsides with enabling SSH:

  • More difficult to use than a web interface
  • Increased security risks

 

The Manage Shell plugin provided by Namecheap allows you to enable or disable SSH access for your respective hosting accounts with just a few clicks.

For cPanel Basic Theme:

Firstly, locate the Manage Shell plugin from your cPanel:
cPanel >> the Exclusive for Namecheap Customers section >> Manage Shell:

How to use Manage Shell in cPanel - Cheap VPS

By default, SSH access is disabled for hosting accounts.

How to use Manage Shell in cPanel - Cheap VPS

There are 3 options related to enabling SSH keys:

  • Managing SSH keys
  • Generating a new key
  • Importing a key

All these options will take you to the SSH Access menu in your cPanel. Detailed instructions can be found in this guide.

To enable SSH, turn the toggle button on. After it has been enabled, you will then see how you can manage your SSH.

How to use Manage Shell in cPanel - Cheap VPS

Feel free to explore more about SSH clients here.

For cPanel Retro Theme:

Firstly, locate the Manage Shell plugin from your cPanel:
cPanel >> the Exclusive for Namecheap Customers section >> Manage Shell:

How to use Manage Shell in cPanel - Cheap VPS

By default, SSH access is disabled for hosting accounts.

How to use Manage Shell in cPanel - Cheap VPS

There are 3 options related to enabling SSH keys:

  • Managing SSH keys
  • Generating a new key
  • Importing a key

All these options will take you to the SSH Access menu in your cPanel. Detailed instructions can be found in this guide.

To enable SSH, turn the toggle button on. After it has been enabled, you will then see how you can manage your SSH.

How to use Manage Shell in cPanel - Cheap VPS

Feel free to explore more about SSH clients here.
ByJUJU-dev

How to import and export a database via phpMyAdmin (‘Access denied create database db_name’ error)

How to import and export a database via phpMyAdmin (‘Access denied create database db_name’ error)

In cPanel you can import and export databases using the phpMyAdmin menu which you can find in the Databases section. Note, that only databases of 50MB maximum can be imported/exported in phpMyAdmin. Larger databases have to be imported/exported via SSH. To do this, follow the instructions here or simply submit a ticket to our HelpDesk.

Database import

1. Log into your cPanel
2. Navigate to phpMyAdmin menu:

3. Select the database that you will need import to:

4. In the upper bar, click the tab Import:

5. Click Browse and locate the .sql file from your computer. Once done, click Go:

6. And you will see a notification that your database was successfully imported:

Database export

1. Log into your cPanel
2. Navigate to phpMyAdmin menu:

3. Select the database that you will need import to:

4. Choose the tables that you need to export or click Check All. Click Export to proceed:

5. Select the required file from the drop-down menu in Format and click the Go button:

Access denied create database db_name error. How to fix it?

If you received this error message, you can resolve the issue by following the next steps:

1. Open the dump of your database using any text editor on your computer (for instance, Notepad or WordPad).
2. Find the line: CREATE DATABASE db_name (it can usually be found at the beginning) and remove it.
*db_name – your database name:

how_to_import_and_export_database_in_cpanel_access_denied_create_database_db_name_error_and_how_to_fix it(10).jpg

3. Save it and import it using the instructions provided above.

That’s it!