How to install Apache, MySQL PHP, and phpMyAdmin on Ubuntu 22.04

Open PuTTY then enter your IP and port then click the Open Button Update your package index by running the following command:

How to install Apache, MySQL PHP, and phpMyAdmin on Ubuntu 22.04

sudo apt update

sudo apt upgrade

1.  Install apache2

Once the package index has been updated, install the Apache web server package by running the following command:

sudo apt install apache2

After the installation is complete, start the Apache service with the following command:

sudo systemctl start apache2

To check whether Apache is running properly, open a web browser and enter your server's IP address or hostname. You should see the default Apache "It works!" page.

2.  Check status

sudo systemctl status apache2

If you want to enable Apache to start automatically on system boot, you can run the following command:

sudo systemctl enable apache2

To stop the Apache service, you can run the following command:

sudo systemctl stop apache2

And to restart it, run:

sudo systemctl restart apache2

3.  NOW install the latest PHP

=======

Install Dependencies: "press ctrl"

sudo apt install software-properties-common apt-transport-https -y

Import PPA Repository of PHP

sudo add-apt-repository ppa:ondrej/php -y

 

Install Apache module/PHP-FPM

sudo apt install php8.3  libapache2-mod-php8.3

After this, you would require to start your Apache server again so that the new PHP module is loaded.

sudo systemctl restart apache2

now check PHP version

php -v

4.  Install Extensions

There are numerous extensions of PHP available so if you desire to install any one of these then you can use the following command.

sudo apt install php8.3-

However, if you want the list of all the extensions then use the following command.

php -m

5.  Installing MySQL

========

install the mysql-server package:

sudo apt install mysql-server

Ensure that the server is running using the systemctl start command:

sudo systemctl start mysql.service

mysql -u root

then

musql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '@Admin@123';

then

 exit

 

you can run the mysql_secure_installation script without issue.

Run the security script with sudo:

sudo mysql_secure_installation

enter your user root password: @ Admin@123

then press y

press 2 if need for password medium

then set new password like:#Admin@123

then all allow with enter "y"

you can show "All Done!"

then

mysql -u root -p

enter your new password:# Admin@123

now, mysql>show databases;

now enter mysql>exit

 

6.  Installing phpMyAdmin

=======

Run the following command to install these packages onto your system. Please note, though, that the installation process requires you to make some choices to configure phpMyAdmin correctly.

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

Hit enter button when coming popup apache2

Hit No when coming to another popup

 

The installation process adds the phpMyAdmin Apache configuration file into the /etc/apache2/conf-enabled/ directory, where it is read automatically. To finish configuring Apache and PHP to work with phpMyAdmin, the only remaining task in this section of the tutorial is to is explicitly enable the mbstring PHP extension, which you can do by typing:

sudo phpenmod mbstring

Afterwards, restart Apache for your changes to be recognized:

sudo systemctl restart apache2

Then try installing the phpmyadmin package again and it will work as expected:

sudo apt install phpmyadmin

7.  Configure phpMyAdmin

Now we are going to configure phpMyAdmin. Execute the following command on command prompt to configure phpmyadmin for Apache.

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

And add the following line to the apache2.conf file and save it.

=====

Alias /phpmyadmin /var/www/html/phpmyadminOptions Indexes FollowSymLinks

DirectoryIndex index.phpAddType application/x-httpd-php .phpphp_flag magic_quotes_gpc Off

php_flag track_vars On

php_flag register_globals Off

php_value include_path .# Authorize for setupAuthType Basic

AuthName "phpMyAdmin Setup"

AuthUserFile /etc/phpmyadmin/htpasswd.setupRequire valid-user# Disallow web access to directories that don't need itOrder Deny,Allow

Deny from AllOrder Deny,Allow

Deny from All

=====

use this command:ctrl+O then enter, ctrl+X

OR:Save your file. Press ESC key to switch to command more. Then type :wq (colon+w+q) and hit Enter button.

Using the following command to enable the configuration.

sudo a2enconf phpmyadmin.conf

Now open your filezila

enter your IP for host, root for username and password is your main password, 22 is your port

 

now go to this root /etc/apache2/conf-available/ and open phpmyadmin.conf file and paste below code and replace existing

==

Alias /phpmyadmin /usr/share/phpmyadmin

Alias /phpMyAdmin /usr/share/phpmyadmin

 

<Directory /usr/share/phpmyadmin/>

   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>

      <RequireAny>

      Require all granted

     </RequireAny>

   </IfModule>

</Directory>

<Directory /usr/share/phpmyadmin/setup/>

   <IfModule mod_authz_core.c>

     <RequireAny>

       Require all granted

     </RequireAny>

   </IfModule>

</Directory>

===

Now we are going to restart apache server. Use the following command command to restart apache web server on ubuntu 22.04

sudo service apache2 restart

now open your browser and enter your:  IP/phpmyadmin

Enter your new password:# Admin@123

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow