PHP – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Mon, 02 Jan 2023 06:39:36 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 10 Simple Ways to Speed Up Your WordPress Website https://tecadmin.net/ways-to-speed-up-your-wordpress-website/ https://tecadmin.net/ways-to-speed-up-your-wordpress-website/#comments Thu, 03 Nov 2022 09:37:43 +0000 https://tecadmin.net/?p=11533 Did you know that the average user will abandon your website if it takes longer than 5 seconds to load? That’s right, if your website loads too slowly, users will get frustrated and leave. In fact, Statistica reports that 47% of online shoppers will abandon a website if it takes more than 3 seconds to [...]

The post 10 Simple Ways to Speed Up Your WordPress Website appeared first on TecAdmin.

]]>
Did you know that the average user will abandon your website if it takes longer than 5 seconds to load? That’s right, if your website loads too slowly, users will get frustrated and leave. In fact, Statistica reports that 47% of online shoppers will abandon a website if it takes more than 3 seconds to load. If you’ve ever spent time browsing the Internet, you’ll know how crucial speed is to keep users engaged. It doesn’t matter how great your content is or how good your site looks – if it doesn’t load fast enough, people won’t stick around long enough to find out. Luckily, there are lots of ways you can optimize your website so that it loads faster than ever before.

Your website is the first impression your potential customers will have of your business. Whether it’s a personal blog or an eCommerce store, you want your site to look great and load quickly. If you find yourself often frustrated by slow page loads and lagging performance, it’s time to consider speeding up your WordPress site. A fast website not only makes users happy but also helps search engines index your pages faster. With that in mind, let’s take a look at some easy ways to make your site faster than ever before.

In this blog post, we will discuss a few ways to speed up your WordPress website.

1. Select Correct Hosting Provider

Web hosting is essential to get space for your WordPress website over the web. There are many companies involved in web hosting services that can help you in this regard. One can find different types of web hosting plans that vary in terms of their time duration and charges. However, the website owner has a choice to opt the desired web hosting plan for the site for a specific time duration and pay accordingly.

Simple Ways to Speed Up Your WordPress Website

2. Install a WordPress Performance Plugin

A WordPress performance plugin is a simple software solution that can help you optimize your website for speed. These plugins can improve the way your website loads by caching content, compressing images, managing asset delivery, and more. You can find lots of WordPress performance plugins on the internet. We recommend WPRocket, which is trusted by over 1 million WordPress users.

WPRocket is easy to install and fully customizable. Once you install it, you can go into your website’s settings and choose how you want to optimize your site for speed. WPRocket also comes with a Site Audit tool that analyzes your site and tells you where you’re experiencing issues and how you can improve your website’s speed.

WP-Rocket: Speed Up Your WordPress Website
WP-Rocket: Speed Up Your WordPress Website

3. Select the Right Theme or Framework

Your website’s theme is one of the biggest factors that affect how fast it loads. If your theme is too heavy, it will slow down your site. If your theme is lightweight, however, it won’t cause as much of a delay. Unfortunately, many people don’t realize this and end up choosing a theme that is too heavy. If you want to speed up your website, you should choose a lightweight theme. To find a lightweight theme, check out this list of the top 20 fastest WordPress themes. You should also make sure that you’re not using too many plugins – each one can slow down your site.

Boost Your WordPress 1

4. Optimize Your Images

Images can make your website more attractive and engaging, but if they’re too large, they’ll slow down your site. If you want to speed up your website and keep your users happy, you need to optimize your images. This means you’ll need to find an image editing software that can help you change their size without compromising their quality.

You can use an image editing tool to reduce the size of your images without losing any quality by: When you optimize your images, you’ll make your website faster. This means that users will be less likely to get frustrated and leave – and they’ll be more likely to click through to the next page.

5. Define a Content Strategy

Ever noticed how some websites seem to constantly update their content, while others don’t update as often? The difference is likely in the content strategy. A content strategy is a blueprint you follow to create content on your website. With a content strategy, you can create a schedule and streamline your publishing process, which reduces the time it takes to create new content. This means you can create and publish new content more quickly, which speeds up your website.

A content strategy can also help you to focus on quality content rather than quantity. This means that you’ll create fewer posts but you’ll publish posts that contain more information. When you publish fewer posts but focus on quality, you can help your visitors. This means that your content will be more beneficial and your readers will benefit from it.

6. Combine Static and Dynamic Content

Static and dynamic content are two different types of content that websites often use. Static content is unchanging, while dynamic content is content that changes regularly. You might notice that some websites use more static content while others use more dynamic content. This difference can affect how quickly the site loads. When you combine static and dynamic content, you can help your website load faster. This is because some of your content will remain unchanged, while other content will change regularly.

Instead of creating one big post that changes everything on your website regularly, create a post that is static and another post that changes regularly. When you combine static and dynamic content, you can help your website load faster. This is because some of your content will remain unchanged, while other content will change regularly.

7. Content Deliver Network (CDN)

The Internet is constantly growing, and having a website that loads quickly is essential. A CDN is a network of servers across the world that can help speed up your WordPress website. This can be especially important if you have a large number of visitors. There are several types of CDN, but they all serve the same purpose: to cache pages and make them load more quickly. You should use a CDN if you’re worried about slow performance or high traffic.

There are several advantages to using a CDN. First, it can improve the overall speed of your WordPress site by reducing latency. Second, it can help reduce server strain because it reduces the number of requests on a given server. Third, it can also help with SEO because it adds a layer of content to your site.

8. Enable Gzip Compression

Gzip compression is a feature that some hosting providers include as part of their service. If you’re using shared hosting, you may already have to gzip compression. If you don’t, you can enable it in your website’s settings. Gzip is a type of compression that can help to reduce the size of your website’s assets. This means that your website will load faster. Gzip compression can help to speed up your website, especially if you’re using WordPress. If you enable gzip compression, it will reduce the size of your WordPress site and help to speed it up.

Boost Your WordPress 3

9. Keep the Database Optimized

The proper optimization of your website’s database may help you boost site’s speed. It can be done by using the plugin that optimizes the database of the site correctly. For instance, WP-Sweep is a significant database optimizer plugin that includes valuable functions which enable one to manage the database of the site easily. This may result in increasing the site’s online performance and speed too.

Boost Your WordPress 4

10. Resolve 404 Errors

Many times, you have encountered with 404 errors or not found an error while searching any web page online. If your WordPress site starts showing a 404 error, then it’s important to remove it immediately. This error shows disconnection of it from the server and can also lower the speed of the website. By resolving this issue, you can easily improve the speed of the site.

How to Redirect 404 Error Pages to Home Page in WordPress

Boost Your WordPress 2

Conclusion

If you want to speed up your WordPress website, you need to look at your site’s design, images, and content. You can also install a website performance plugin to help you optimize your site for speed. If your website takes too long to load, users will get frustrated and leave. Make sure that your website loads quickly by optimizing your images, using lightweight themes, and combining static and dynamic content. You can also enable gzip compression to help reduce the size of your site. If you follow these tips, you can speed up your WordPress website and keep your users happy.

The post 10 Simple Ways to Speed Up Your WordPress Website appeared first on TecAdmin.

]]>
https://tecadmin.net/ways-to-speed-up-your-wordpress-website/feed/ 8
How to Install Composer on Ubuntu 22.04 https://tecadmin.net/how-to-install-composer-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-composer-on-ubuntu-22-04/#respond Wed, 22 Jun 2022 17:13:44 +0000 https://tecadmin.net/?p=30277 Composer is a dependency management tool for PHP that allows you to declare the libraries your project depends on and installs them for you. In this article, we will cover the steps for installing Composer on Ubuntu 22.04. Prerequisites Shell access to a running Ubuntu system. Install PHP 5.3 or higher version. PHP’s package manager, [...]

The post How to Install Composer on Ubuntu 22.04 appeared first on TecAdmin.

]]>
Composer is a dependency management tool for PHP that allows you to declare the libraries your project depends on and installs them for you. In this article, we will cover the steps for installing Composer on Ubuntu 22.04.

Prerequisites

  • Shell access to a running Ubuntu system.
  • Install PHP 5.3 or higher version.
  • PHP’s package manager, `php-cli`, must be installed and available in your `PATH`

Installing PHP Composer on Ubuntu

The Composer’s official team provides a script to install PHP composer on Linux systems. You can download this script using the `curl` or `wget` command-line utility. Also, you can download it directly using the PHP script command line.

  1. To download the `composer-setup` script, run the following command in a terminal:
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 
    
  2. Then execute the downloaded PHP script to install the composer on your Ubuntu system at the desired location. Use --install-dir to set the binary location and --filename to set the binary name. You can choose one of the below option:
    • Installing PHP composer system-wide: This will install composer in /uer/local/bin directory, that is accessible to all users:
      sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
      sudo chmod +x /usr/local/bin/composer
      
    • Installing PHP composer for specific applicaiton: Sometimes you dont’ have permission to install it globally, like shared hosting account. Then you can configure this under you application as well. To install composer locally type:
      cd /path/to/php-application && mkdir -p bin 
      php composer-setup.php --install-dir=bin --filename=composer
      chmod +x bin/composer
      

      Make sure to replace /path/to/php-application with your application directory.

  3. To see the installed composer version execute binary with -v command parameter.
    composer --version
    
    Output:
    Composer version 2.3.7 2022-06-06 16:43:28

Upgrade PHP Composer

The PHP composer has the ability to self-upgrade to the latest versions. If the composer is already installed on your system, just type the below command to upgrade the PHP composer to the latest version.

composer self-update

In my case, I already have latest version of composer. So receive the following message on terminal:

Output:
You are already using the latest available Composer version 2.3.7 (stable channel).

Working with PHP Composer

You have already installed and configured the composer on your system. The composer will help you to manage modules for your application. For example, to install a new module for your application.

Switch to the PHP application.

cd /path/to/php-application 

Run the following command to install psr/log module in the application.

composer require psr/log
Output:
Using version ^3.0 for psr/log ./composer.json has been created Running composer update psr/log Loading composer repositories with package information Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals - Locking psr/log (3.0.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Downloading psr/log (3.0.0) - Installing psr/log (3.0.0): Extracting archive Generating autoload files

Composer will automatically create or update composer.json file at application root directory. Now, the application can use the functionality provided by the module.

The above command will install the latest version of the module. You can also define the module version you want to install for your application. If the module is already installed, it will automatically downgrade/upgrade the package to the specified version.

composer require psr/log=1.0

The module no longer required can be removed with the following command.

composer remove psr/log

All the above commands also update composer.json file accordingly.

Conclusion

In this article, we have covered the steps for installing Composer on Ubuntu 22.04. By using Composer, you can easily manage the dependencies of your PHP projects and ensure that all necessary libraries are installed and up to date. Whether you are new to PHP development or an experienced developer, Composer can help you streamline your workflow and improve the quality of your projects.

The post How to Install Composer on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-composer-on-ubuntu-22-04/feed/ 0
How To Install PHP (8.1, 7.4) on Ubuntu 22.04 https://tecadmin.net/how-to-install-php-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-php-on-ubuntu-22-04/#comments Fri, 06 May 2022 17:07:11 +0000 https://tecadmin.net/?p=29291 PHP is a programming language used for developing web applications. You must install PHP packages on a Ubuntu system to run the application written on it. Generally, it is used to create e-commerce websites, blogs, and API applications. If you’re looking for an easy way to install PHP on Ubuntu 22.04, look no further. In [...]

The post How To Install PHP (8.1, 7.4) on Ubuntu 22.04 appeared first on TecAdmin.

]]>
PHP is a programming language used for developing web applications. You must install PHP packages on a Ubuntu system to run the application written on it. Generally, it is used to create e-commerce websites, blogs, and API applications. If you’re looking for an easy way to install PHP on Ubuntu 22.04, look no further. In this blog post, we’ll show you how to do it quickly and easily.

We will use the Ondrej PPA for installing PHP on Ubuntu 22.04 LTS system. Which contains PHP 8.1, 8.0, 7.4, 7.3, 7.2. 7.1, 7.0 & PHP 5.6 packages. You can install any of the versions as required for your application. The new application developers are suggested to use the latest PHP version ie PHP 8.1.
In this tutorial, you will learn how to install PHP on Ubuntu 22.04 LTS system. This tutorial is also compatible with Ubuntu 20.04, and 18.04 systems.

Before We Begin

First, login to the Ubuntu 22.04 via console. Then update the Apt cache and upgrade the current packages of system using the following command:

sudo apt update && sudo apt upgrade 

When prompted, press ‘y’ to confirm the installation.

Installing PHP on Ubuntu 22.04

PHP installation on Ubuntu systems is pretty straightforward. You just need to add the required PPA and you can install any PHP version on the Ubuntu system.

Follow these steps to complete PHP installation on Ubuntu:

  1. Install few dependencies required by this tutorial with the below-mentioned command:
    sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https 
    
  2. Add the Ondrej PPA to your system, which contains all versions of PHP packages for the Ubuntu systems.
    LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php 
    
  3. Now, update the Apt package manager cache.
    sudo apt update 
    
  4. The SURY repository contains PHP 8.1, 8.0, 7.4, 7.3, 7.2. 7.1, 7.0 & PHP 5.6. As the latest stable version of PHP is 8.0, but a large number of websites still required PHP 7. You can install any of the required PHP versions on your system.
    • Install PHP 8.1:
      sudo apt install php8.1 
      
    • Install PHP 7.4:
      sudo apt install php7.4 
      
    • Install PHP 5.6 (EOL):
      sudo apt install php5.6 
      

    Replace version 8.1, 7.4, or 5.6 with the required PHP version to install on Ubuntu. Even you can install multiple PHP versions on a single Ubuntu system.

  5. Some applications required other PHP extensions, that can also be added using below-mentioned syntax:
    sudo apt install php8.1-[extension]
    

    Replace [extension] with the extension you want to install, if you want to add multiple extensions then include them in braces, I am going to install “php-mbstring, php-mysql, php-xml, and php-curl” by running the below-mentioned command:

    sudo apt install php8.1-mysql php8.1-mbstring php8.1-xml php8.1-curl 
    

    Users have installed different PHP version, need to replace 8.1 with required PHP versions.

Check Active PHP Version

Now after installation verify that the correct version of PHP is installed by checking the version number by the below-mentioned command:

php -v 
Output:
PHP 8.1.5 (cli) (built: Apr 21 2022 10:32:13) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.5, Copyright (c) Zend Technologies with Zend OPcache v8.1.5, Copyright (c), by Zend Technologies

About PHP Configuration Files

Configuration files are stored under a directory with version number under /etc/php directory. For example PHP 8.1 configuration files located as below:

  1. Main PHP configuration file location:
    • PHP CLI: /etc/php/8.1/cli/php.ini
    • Apache: /etc/php/8.1/apache2/php.ini
    • PHP FPM: /etc/php/8.1/fpm/php.ini
  2. All the installed PHP modules are stored under /etc/php/8.1/mods-available directory.
  3. PHP Active modules configuration directory location:
    • PHP CLI: /etc/php/8.1/cli/conf.d/
    • Apache: /etc/php/8.1/apache2/conf.d/
    • PHP FPM: /etc/php/8.1/fpm/conf.d/

To check files for the other PHP versions, just change the PHP version number (8.1 in the above example) in the files and directory path.

Switch Default PHP Version for CLI

You can use update-alternatives command to set the default PHP version. Use this tutorial to read more details about switching PHP version for CLI and Apache.

sudo update-alternatives --config php
There are 4 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php8.1   81        auto mode
  1            /usr/bin/php5.6   56        manual mode
  2            /usr/bin/php7.4   74        manual mode
  3            /usr/bin/php8.0   80        manual mode
  4            /usr/bin/php8.1   81        manual mode

Press  to keep the current choice[*], or type selection number: 2

The above output shows all the installed PHP versions on your system. Selection number 2 set PHP 7.4 as the default PHP version for the command line.

Uninstalling PHP

If any PHP version is no more required, can be removed from the system. That will free the disk space as well as system security.

To uninstall any PHP version just type:

sudo apt remove php5.6 

Also uninstall all the modules for that version with the following command:

sudo apt remove php5.6-* 

Conclusion

This tutorial provides you with the instructions to install PHP on Ubuntu 22.04. The Ondrej PPA allows us to quickly install PHP on Ubuntu systems. It also allows us to install multiple PHP versions on a single system. You can switch to any PHP version as default anytime with the update-alternative utility.

The post How To Install PHP (8.1, 7.4) on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-php-on-ubuntu-22-04/feed/ 6
How to Install Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04 https://tecadmin.net/how-to-install-lamp-stack-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-lamp-stack-on-ubuntu-22-04/#comments Tue, 05 Apr 2022 05:09:41 +0000 https://tecadmin.net/?p=9382 Have you ever wondered how websites like WordPress, Drupal, and other content management systems even exist? How can software developers build and maintain such websites without being technical experts in website hosting technologies? The answer is LAMP. LAMP is an acronym for Linux, Apache, MySQL, and PHP. This article describes in detail how to set [...]

The post How to Install Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04 appeared first on TecAdmin.

]]>
Have you ever wondered how websites like WordPress, Drupal, and other content management systems even exist? How can software developers build and maintain such websites without being technical experts in website hosting technologies? The answer is LAMP. LAMP is an acronym for Linux, Apache, MySQL, and PHP. This article describes in detail how to set up LAMP on the Ubuntu server. If you are a website developer or intend to become one, then you’ll find this guide useful.

You will learn how to install the LAMP stack on your Ubuntu VPS server and begin developing dynamic websites that can be hosted on a stable, fast, and secure server environment. Let’s get started…

Pre-Requisities

Assuming that you have a running Ubuntu 22.04 Linux system with sudo (or root) privileged access.

Access your system and open a terminal. It will be good to update the package manager cache and upgrade currently installed packages. To do this execute:

sudo apt update && sudo apt upgrade 

Let’s begin the LAMP (Linux, Apache, MySQL, and PHP) stack installation on Ubuntu 22.04 Jammy Jellyfish Linux system.

Step 1: Install PHP (Programming Languege)

First, you need to decide on the PHP version to install on your system. You can also install multiple PHP versions on a single system. Currently the repository contains PHP 5.6, PHP 7.1, 7.2, 7.3, 7.4 and PHP 8.0, 8.1. The below instruction will install PHP 8.1. Please change the version as per your requirements.

The ondrej/php PPA contains all PHP version’s for Ubuntu systems. So add this repository in your system with command below:

sudo add-apt-repository ppa:ondrej/php 

Now update the apt cache and install PHP 8.1.

sudo apt update 
sudo apt install php8.1 

This will install PHP on your Ubuntu system along with some useful PHP extensions.

Step 2: Install Apache (Web Server)

Generally, the PHP installation also installs Apache and its module on your system. Still, you can run the following commands to confirm the installations.

sudo apt install apache2 libapache2-mod-php8.1 -y 

This will install Apache and start the service.

Now, you need to allow web server ports in the firewall. To allow ports 80 and 443 in the UFW firewall, execute the following commands.

sudo ufw allow 80/tcp 
sudo ufw allow 443/tcp 

Open a web browser on your system and type the server’s IP in the address bar. You will get the default Apache server page

How to Install LAMP Stack on Ubuntu 22.04
Apache default page

Step 3: Install MySQL (Database Server)

The default Ubuntu repositories contain MySQL 8.0. Which can be directly installed using the package manager. To install the available MySQL server version, execute the following command.

sudo apt-get install mysql-server 

Once the installation is finished, you can secure the MySQL server by executing the following command.

sudo mysql_secure_installation 

This will ask for a few questions to secure the MySQL server.

  1. Press ‘y’ to enable validate password plugin. This will allow you to set a strict password policy for user accounts.
    VALIDATE PASSWORD COMPONENT can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD component?
    
    Press y|Y for Yes, any other key for No: y
    
  2. Chose the password complexity level. Read the all 3 options and choose one:
    LOW    Length >= 8
    MEDIUM Length >= 8, numeric, mixed case, and special characters
    STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
    
    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
    
  3. Enter a new password and re-enter it. Make sure it matches the complexity level as described above.
    New password: *************
    Re-enter new password: *************
    
  4. Press ‘y’ to continue with provided password.
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    
  5. Remove default anonymous users from MySQL server:
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    
  6. Disable root login from remote systems
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    
  7. Remove test database form MySQL created by default during installation.
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    
  8. Reload all privileges to apply the above changes immediately.
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    

You have secured the MySQL server in the LAMP stack on Ubuntu 22.04 Linux system.

Remember that the above password set for the root accounts is used for remote users only. To log in from the same system, just type mysql on terminal.

sudo mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.28-0ubuntu4 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Step 4: Installing Other Required Packages

You may also need to install modules like MySQL and other extensions for PHP based on the application requirements. Use the following command to find our available PHP extensions.

sudo apt search php8.1-* 

The above command will list all available PHP7 modules for installation, Let’s begin the installation of modules.

sudo apt install php8.1-mysql php8.1-curl php8.1-xml 

Step 5: Test LAMP Setup

You have successfully completed the installation of Apache, MySQL, and PHP on the Ubuntu 22.04 Linux system. To verify the PHP integration with Apache, create a PHP script (example: info.php) on the website document root and write the below content.

<?php
   phpinfo();
?>

Now access this file in the web browser. It will so all the details about versions and installation.

http://server-ip-address/info.php 
How to Setup LAMP Stack on Ubuntu 22.04
PHP details by phpinfo() function.

Conclusion

This tutorial helped you to set up the LAMP stack on Ubuntu 22.04 LTS system. Now, you can host PHP-based web applications on your server.

The post How to Install Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-lamp-stack-on-ubuntu-22-04/feed/ 32
How To Setup Apache, PHP & MongoDB in Ubuntu & Debian https://tecadmin.net/how-to-setup-apache-php-mongodb-in-ubuntu/ https://tecadmin.net/how-to-setup-apache-php-mongodb-in-ubuntu/#respond Fri, 08 Oct 2021 01:44:41 +0000 https://tecadmin.net/?p=28067 MongoDB is a free open-source, schema-free, NoSQL database which is getting more popular day by day among web developers. It is a document-oriented database and is known for its processing speed. In order to use MongoDB for our projects, we will first need to install it on our system along with its dependencies and some [...]

The post How To Setup Apache, PHP & MongoDB in Ubuntu & Debian appeared first on TecAdmin.

]]>
MongoDB is a free open-source, schema-free, NoSQL database which is getting more popular day by day among web developers. It is a document-oriented database and is known for its processing speed.

In order to use MongoDB for our projects, we will first need to install it on our system along with its dependencies and some other tools. In this post, we will learn to install and set up Apache, PHP, and MongoDB on Ubuntu and Debian operating systems.

Installing Apache

First of all, we will install Apache on our system. Apache is a web server software and a popular HTTP client; it helps in creating virtual hosts. To install Apache on our system we will use the below-given command:

sudo apt update 
sudo apt install apache2 -y 

Note: The commands given in this article will work on both Ubuntu and Debian as both of them use the same package manager.

Installing PHP

To install PHP along with its common modules on our system we just need to run a simple command:

sudo apt install -y php7.4 libapache2-mod-php7.4 

We have installed PHP 7.4 on our system. You can install the version and the modules that you require for your project.

Installing MongoDB

Unfortunately, MongoDB is not available in the default repositories of Ubuntu and Debian. So we will have to first import the public key which will be used by the package management system:

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - 

If the terminal gives an error while executing the above-given command then you will have to install GnuPG on your system before executing this command again.

The next step is to create a list file for your version of the operating system. As I am running Ubuntu 20.04, I will run the following command:

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list 

For Debian 10:

echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list 

Next, we need to reload the local package database and then install the latest stable release of Mongodb:

sudo apt update 
sudo apt install -y mongodb-org 

This will install the MongoDB server on your system.

Installing MongoDB PHP Module

For the last step, we need to install the MongoDB PHP module which is required for connecting PHP with MongoDB.

sudo apt install php7.4-mongodb 

Make sure to install the MongoDB module for the same version of PHP.

Run the following command to check the MongoDB module is enabled for the PHP CLI environment.

php -m | grep mongo 
Output
mongodb

Next, restart the Apache server to apply changes.

sudo systemctl restart apache2 

You can also create a phpinfo() file at the Apache document root. When you access this file in web broser,

Mongodb Module with PHP & Apache2
Mongodb Module with PHP & Apache2

Conclusion

MongoDB is a well-known, high-performance, NoSQL database. It is highly scalable and is different from Relational Database Systems such as MySQL and PostgreSQL. In this post, we learned how to install it along with its dependencies and other related tools.

The post How To Setup Apache, PHP & MongoDB in Ubuntu & Debian appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-setup-apache-php-mongodb-in-ubuntu/feed/ 0
How To Install and Use PHP Composer on Debian 11 https://tecadmin.net/how-to-install-and-use-php-composer-on-debian-11/ https://tecadmin.net/how-to-install-and-use-php-composer-on-debian-11/#respond Tue, 28 Sep 2021 06:22:13 +0000 https://tecadmin.net/?p=27897 PHP Composer is basically a dependency management tool for PHP applications. It provides hassle-free installation of PHP modules for the applications. The composer keeps track of all the modules required for the application and installs them with a single command. It also allows users to keep modules updated. You can easily install all the required [...]

The post How To Install and Use PHP Composer on Debian 11 appeared first on TecAdmin.

]]>
PHP Composer is basically a dependency management tool for PHP applications. It provides hassle-free installation of PHP modules for the applications. The composer keeps track of all the modules required for the application and installs them with a single command. It also allows users to keep modules updated. You can easily install all the required packages using Composer. The composer maintains a list of required packages in a JSON file called composer.json.

Composer is a similar tool to npm for Node.js, pip for Python, and bundler for ROR. Composer 2 is the latest available version for your system with enhanced performance. We will use that version to install on our system.

This tutorial helps you to install and use PHP composer on Debian 11 Bullseye Linux system.

Prerequisites

Installing PHP Composer on Debian

A PHP script is provided by the official team to configure the composer on your system. You can download it with curl or wget command-line utility. Also, you can download it with the PHP script.

Open a terminal and run:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 

A composer-setup.php file will be created in current directory. Now execute this PHP script to install the composer at the desired location. Use --install-dir to set the binary location and --filename to set the binary name. You can install composer globally accessible for all users and projects or install locally for a specific project.

  • To install composer globally, type:
    php composer-setup.php --install-dir=/usr/local/bin --filename=composer
    chmod +x /usr/local/bin/composer
    
  • You can also install composer under the specific application. This is helpful for shared hosting environments, where you don’t have sudo or root access. To install composer locally for a specific project, type:
    cd /path/to/php-application && mkdir -p bin 
    php composer-setup.php --install-dir=bin --filename=composer
    chmod +x bin/composer
    

    Change /path/to/php-application with the actually application directory.

To see the installed composer version execute binary with -v command parameter.

composer --version
Output:
Composer version 2.2.6 2022-02-04 17:00:38

Upgrade PHP Composer

The PHP composer has the ability to self-upgrade to the latest versions. If the composer is already installed on your system, just type the below command to upgrade PHP composer to the latest version.

composer self-update

In my case, I already have latest version of composer. So receive the following message on terminal:

Output:
You are already using the latest available Composer version 2.2.6 (stable channel).

Working with PHP Composer

You have already installed and configured the composer on your system. Composer will help you to manage modules for your application. For example, to install a new module for your application.

Switch to the PHP application.

cd /path/to/php-application 

Run the following command to install psr/log module in the application.

composer require psr/log
Output:
Using version ^1.1 for psr/log ./composer.json has been created Running composer update psr/log Loading composer repositories with package information Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals - Locking psr/log (1.1.4) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Downloading psr/log (1.1.4) - Installing psr/log (1.1.4): Extracting archive Generating autoload files

Composer will automatically create or update composer.json file at application root directory. Now, the application can use the functionality provided by the module.

The above command will install the latest version of the module. You can also define the module version you want to install for your application. If the module is already installed, it will automatically downgrade/upgrade package to the specified version.

composer require psr/log=1.0

The module no longer required can be removed with the following command.

composer remove psr/log

All the above commands also update composer.json file accordingly.

Conclusion

In this tutorial, you have found instructions to install composer on a Debian Linux system. You can install composer globally to allow access to all users and applications. Also, you can install composer for a specific directory.

The post How To Install and Use PHP Composer on Debian 11 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-and-use-php-composer-on-debian-11/feed/ 0
How To Install PHP (8.1, 7.4 & 5.6) on Debian 11 https://tecadmin.net/how-to-install-php-on-debian-11/ https://tecadmin.net/how-to-install-php-on-debian-11/#comments Mon, 13 Sep 2021 12:54:40 +0000 https://tecadmin.net/?p=27619 PHP abbreviated as “HyperText Processor”, is the open-source programming language used for Web application development. It is a scripting language, mostly used for the front end with HTML. It can be used to create e-commerce websites, manage databases, and do session monitoring. It is available for all OS. The latest version of PHP is version [...]

The post How To Install PHP (8.1, 7.4 & 5.6) on Debian 11 appeared first on TecAdmin.

]]>
PHP abbreviated as “HyperText Processor”, is the open-source programming language used for Web application development. It is a scripting language, mostly used for the front end with HTML. It can be used to create e-commerce websites, manage databases, and do session monitoring.

It is available for all OS. The latest version of PHP is version 8 and in this article, we will discuss the installation of PHP on the Debian 11 (Bullseye) Linux system.

Prerequisites

First, update all the packages of the system by below-mentioned command:

sudo apt update 

After updating packages, now install the dependencies required by the below-mentioned command:

sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https 

Step 1 – Enable SURY Repository

The following step is to integrate the SURY repository into our system. SURY is a Debian-based third-party PHP repository that bundles PHP software, run the following command to add SURY repository:

sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' 

Importing the GPG key for the repository by the below-mentioned command:

wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add - 

Step 2 – Installing PHP on Debian 11

Now again update packages for syncing them with the recently added SURY repository before installing php:

sudo apt update 

The SURY repository contains PHP 8.1, 8.0, 7.4, 7.3, 7.2. 7.1, 7.0 & PHP 5.6. As the latest stable version of PHP is 8.0, but a large number of websites still required PHP 7. You can install any of the required PHP versions on your system.

  • Install PHP 8.1 on Debian
    sudo apt install php8.1 
    
  • Install PHP 7.4 on Debian
    sudo apt install php7.4 
    
  • Install PHP 5.6 on Debian
    sudo apt install php5.6 
    

Replace version 8.1, 7.4 or 5.6 with the required PHP version to install on your Debian system. Even you can install multiple PHP versions on a single Debian system.

Step 3 – Installing PHP Extension

Moreover, we can also add the php extension by below-mentioned syntax:

sudo apt install php8.1-[extension]

Replace [extension] with the extension you want to install, if you want to add multiple extensions then include them in braces, I am going to install “php-mbstring, php-cli, php-xml, php-common, and php-curl” by running the below-mentioned command:

sudo apt install php8.1-cli php8.1-mbstring php8.1-xml php8.1-common php8.1-curl 

Users have installed different PHP version, need to replace 8.1 with required PHP versions.

Step 4 – Checking PHP Version

Now after installation verify that the correct version of PHP is installed by checking the version number by the below-mentioned command:

php -v 
Output:
PHP 8.1.2 (cli) (built: Jan 27 2022 12:22:31) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.2, Copyright (c) Zend Technologies with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

Step 5 – Switch Between PHP Versions

You can use update-alternatives command to set the default PHP version. Use this tutorial to read more details about switching PHP version for CLI and Apache.

sudo update-alternatives --config php
There are 4 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php8.1   81        auto mode
  1            /usr/bin/php5.6   56        manual mode
  2            /usr/bin/php7.2   72        manual mode
  3            /usr/bin/php7.4   74        manual mode
  4            /usr/bin/php8.1   81        manual mode

Press  to keep the current choice[*], or type selection number: 4

The above output shows all the installed PHP versions on your system. Input a selection number to set default PHP version for command line.

Conclusion

PHP is a free, server-side programming language also used with HTML programming language for creating dynamic websites. It is available for all operating systems but in this article, we discuss its installation on Debian 11 (Linux OS) Bullseye. You will successfully install PHP on Debian 11 after going through this guide.

The post How To Install PHP (8.1, 7.4 & 5.6) on Debian 11 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-php-on-debian-11/feed/ 1
How to Enable Debug Mode in Laravel https://tecadmin.net/laravel-debug-mode/ https://tecadmin.net/laravel-debug-mode/#respond Thu, 20 May 2021 02:08:05 +0000 https://tecadmin.net/?p=25329 Debugging is a helpful feature for developers to identify the causes of issues. Most of the modern application frameworks provides you the option to enable debug mode including Laravel. It is an good idea to keep enable debug mode in your development environment. In your production environment, this value should always be false. This tutorial [...]

The post How to Enable Debug Mode in Laravel appeared first on TecAdmin.

]]>
Debugging is a helpful feature for developers to identify the causes of issues. Most of the modern application frameworks provides you the option to enable debug mode including Laravel. It is an good idea to keep enable debug mode in your development environment. In your production environment, this value should always be false.

This tutorial help to enable/disable debug more in a Laravel application.

Enable Debug in Laravel

To enable the debug mode, edit “.env” file in the root directory of your Laravel application. Set the APP_DEBUG environment variable value to “true”.

Enable Debug in Laravel

Disable Debug in Laravel

Set the APP_DEBUG environment variable value to “false” in “.env” environment configuration file.

Laravel disable debug

The users needs details messages in log files need to adjust LOG_LEVEL environment variables. Read this to know more about logging in Laravel.

The post How to Enable Debug Mode in Laravel appeared first on TecAdmin.

]]>
https://tecadmin.net/laravel-debug-mode/feed/ 0
How To Install PHP 8 on Debian 10 https://tecadmin.net/how-to-install-php-8-on-debian-10/ https://tecadmin.net/how-to-install-php-8-on-debian-10/#respond Wed, 17 Feb 2021 17:30:12 +0000 https://tecadmin.net/?p=24670 PHP is a scripting language, and a powerful tool for developing dynamic and interactive Web pages. It was originally created in 1994 by Danish-Canadian programmer Rasmus Lerdorf. According to W3Techs’ data, PHP is used by 78.9% websites running in public network. So almost 8 out of every 10 websites on the Internet are using PHP [...]

The post How To Install PHP 8 on Debian 10 appeared first on TecAdmin.

]]>
PHP is a scripting language, and a powerful tool for developing dynamic and interactive Web pages. It was originally created in 1994 by Danish-Canadian programmer Rasmus Lerdorf. According to W3Techs’ data, PHP is used by 78.9% websites running in public network. So almost 8 out of every 10 websites on the Internet are using PHP in some way.

PHP 8.0 is the latest available version for the web development. It is the most advanced and secure version released by the PHP Team.

This tutorial will help you to install PHP 8.0 on Debain 10 Buster Linux system.

Step 1 – Setup Apt Repository

Ondrej Sury is maintaining the PPA that contains the latest PHP packages for the Debian systems.

  1. Let’s start with the installation of some required packages on your system. Open a terminal and execute following commands:
    sudo apt update 
    sudo apt install -y gnupg2 ca-certificates apt-transport-https software-properties-common 
    
  2. Next, add the GPG key to your system to verify the packages before installation.
    wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add - 
    
  3. Create a PPA file to your system with php repository on your buster Linux system.
    echo "deb https://packages.sury.org/php/ buster main" | sudo tee /etc/apt/sources.list.d/php.list 
    

Step 2 – Installing PHP 8 on Debian

Your system is ready for the PHP installation. Use following commands to install PHP 8 on Debian system.

sudo apt update  
sudo apt install php8.0 

Fist command will update the apt cache on your system and second command will install PHP packages.

Once the installation finished, verify the PHP version on terminal.

php -v 

PHP 8.0.2 (cli) (built: Feb 12 2021 14:51:01) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies

Step 3 – Installing PHP Extensions

PHP comes with multiple extensions (also known as modules) to preform specific tasks. You can install these extensions on your system as per your requirements.

First, search for available modules in repository:

sudo apt search php8.0-* 

Then install required php modules on your system. The following command will install some frequently used PHP modules on your system.

sudo apt install php8.0-{mysql,imap,ldap,xml,curl,mbstring,zip} 

You can check for currently installed and active PHP modules on your system by running following command.

php -m 

You can visit another article about enable or disable PHP modules on a Debian system systems.

Step 4 – Setup Apache with PHP 8

Generally the above commands also install Apache PHP extension on your system. But incase not installed, execute below command to install Apache with PHP 8 module.

sudo apt install apache2 libapache2-mod-php8.0 

After successful installation, restart Apache service to reload newly installed modules.

sudo systemctl restart apache2 

Next, verify thta PHP modules is loaded with Apache. Create a php script with phpinfo() function under the default document root.

echo "<?php phpinfo(); ?>" > /var/www/html/info.php 

Access this file in browser using server ip address. For example: http://server-ip/info.php

Install PHP 8 on Debian 10

You will see the detailed PHP information on the web page.

Conclusion

This tutorial helped you to install PHP 8.0 on Debian 10 system.

The post How To Install PHP 8 on Debian 10 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-php-8-on-debian-10/feed/ 0
How to Install PHP 8 on CentOS/RHEL 8 https://tecadmin.net/how-to-install-php-8-on-centos-rhel-8/ https://tecadmin.net/how-to-install-php-8-on-centos-rhel-8/#respond Mon, 15 Feb 2021 15:50:01 +0000 https://tecadmin.net/?p=24627 PHP 8.0 is a major update released by the PHP team on Nov 26, 2020. It contains a large number of new features and optimizations over previous versions. To read more about read the PHP 8 change log. REMI and EPEL are the most popular repositories contains latest RPM packages for installation. It also contains [...]

The post How to Install PHP 8 on CentOS/RHEL 8 appeared first on TecAdmin.

]]>
PHP 8.0 is a major update released by the PHP team on Nov 26, 2020. It contains a large number of new features and optimizations over previous versions. To read more about read the PHP 8 change log.

REMI and EPEL are the most popular repositories contains latest RPM packages for installation. It also contains the PHP 8 RPM packages to be install on CentOS/RHEL 8 systems.

This article will describe you to how to install PHP 8 on CentOS 8 or RHEL 8 Linux system.

Before we Begin

Login to the CentOS 8 system with sudo privileged account.

Optionally, you can upgrade the current packages on your system by executing command.

dnf upgrade  

Step 1 – Enable PHP Repository

The CentOS/RHEL default repositories don’t contain latest PHP 8 packages. In order to install PHP 8 on CentOS 8 system, enable EPEL and REMI yum repositories on your system.

Open a terminal and execute below commands to configure REMI and EPEL repositories:

sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm  

Once you installed both the above packages, Use dnf command line tool to active php:remi-8.0 repository, which contains PHP 8 packages.

sudo dnf module enable php:remi-8.0 -y  

Verify the active repository for the php packages on your system.

sudo dnf module list php  

Make sure the remi-8.0 steam is active for the php packages. It will have [e] just after the repository name. See the below screenshot:

Enable PHP 8 Repository on CentOS/RHEL 8

Step 2 – Installing PHP 8 on CentOS

Your system is ready for the PHP 8 installation. Run the following command from terminal.

sudo dnf install php php-cli php-common  

Press ‘y’ for any confirmation prompted during installation.

Once the installation succeeded, execute the below command to view installed PHP version on your syste.

php -v  

Install PHP 8 on CentOS 8

At this stage, you have successfully install PHP 8 on CentOS 8 and RHEL 8 systems.

Step 3 – Install Apache with PHP 8 on CentOS

This is the optional step for you, if you just need PHP CLI to running php scripts.

But in most cases, we use Apache for deploying PHP based web application. Just execute the following command to Apache web server on your system.

sudo dnf install httpd -y  

Now, verity that Apache is read to serve php files over the web. Lets create php info file on your CentOS server. The default virtulhost uses /var/www/html as document root. So create a file under this directory:

echo "<?php phpinfo(); ?>" >  /var/www/html/info.php  

Next access info.php file using the server ip address as below:

Installing PHP 8 on CentOS/RHEL 8

Step 4 – Installing PHP Extension

Generally the web application depends on multiple PHP extension. A PHP extension is a specially formed library for the specific tasks.

View the available PHP extensions, type:

sudo dnf search php-* 

Now, install all the required PHP extension for your application.

sudo dnf install php-gd php-mbstring php-mysqlnd 

Use -m option to view currently enabled php extensions.

php -m 
php -m | grep extension-name 

Conclusion

This tutorial helped you to install PHP 8.0 including the required extension on CentOS/RHEL 8 Linux system.

The post How to Install PHP 8 on CentOS/RHEL 8 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-php-8-on-centos-rhel-8/feed/ 0