Installing Apache2, PHP, and MySql in ubuntu 21.10
Installation of apache2, PHP, and MySQL in ubuntu 21.10 with simple commands. i don’t want to waste your time so follow these steps and get your server completely configured to host your website on ubuntu 21.10.
Step 1 — InstallApache
The Apache web server is among the most popular web servers in the world. It’s well documented, has an active community of users, and has been in wide use for much of the history of the web, which makes it a great choice for hosting a website.
Start by updating the package manager cache. If this is the first time you’re using
sudo within this session, you’ll be prompted to provide your user’s password to confirm you have the right privileges to manage system packages with
sudo apt update
Then, install Apache with:
sudo apt install apache2
Step 2 — Installing MySQL
Now that you have a web server up and running, you need to install the database system to be able to store and manage data for your site. MySQL is a popular database management system used within PHP environments.
apt to acquire and install this software:
sudo apt install mysql-server
Step 3 — Installing PHP
You have Apache installed to serve your content and MySQL installed to store and manage your data. PHP is the component of our setup that will process code to display dynamic content to the final user. In addition to the
php package, you’ll need, a PHP module that allows PHP to communicate with MySQL-based databases. You’ll also need
libapache2-mod-php to enable Apache to handle PHP files. Core PHP packages will automatically be installed as dependencies.
To install these packages, run:
sudo apt install php libapache2-mod-php php-mysql
Once the installation is finished, you can run the following command to confirm your PHP version:
Step 4 — install php 7.4 ubuntu all extensions
Installing all PHP extensions of 7.4 on ubuntu 21.04 run these commands
sudo apt update
sudo apt install php7.4
sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y
sudo apt update
sudo apt install php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath
install all PHP extensions ubuntu 21.04 PHP
sudo apt install openssl php-common php-curl php-json php-mbstring php-mysql php-xml php-zip
Switch From PHP
command to set the default PHP version.
sudo update-alternatives --config php
Select PHP version number as per your requirement. This will change the PHP CLI version only.
There are 4 choices for the alternative php (providing /usr/bin/php). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/php7.4 74 auto mode 1 /usr/bin/php5.6 56 manual mode 2 /usr/bin/php7.2 72 manual mode 3 /usr/bin/php7.3 73 manual mode 4 /usr/bin/php7.4 74 manual mode Press to keep the current choice[*], or type selection number: 4
Published By ElySpace