0% found this document useful (0 votes)
16 views

PHP Configuration Step by Step

The document provides instructions for installing Apache, MySQL, PHP, and additional tools on Ubuntu. It includes commands for installing different PHP versions, configuring Apache and PHP, setting up a MySQL user, and completely removing MySQL.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

PHP Configuration Step by Step

The document provides instructions for installing Apache, MySQL, PHP, and additional tools on Ubuntu. It includes commands for installing different PHP versions, configuring Apache and PHP, setting up a MySQL user, and completely removing MySQL.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Apache Installation

sudo add-apt-repository ppa:ondrej/apache2


sudo apt update
sudo apt install -y apache2
sudo vim /etc/apache2/apache2.conf
AllowOverride All (Replace the all none word to All)
Require all granted (Replace the word denied to Granted)
Set your Projects path from /var/www/ to /home/username/htdocs/
sudo vim /etc/apache2/sites-available/000-default.conf
Set Your Projects path DocumentRoot /home/username/htdocs/
usermod -a -G username www-data
sudo usermod –a –G www-data username
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl restart apache2
sudo systemctl status apache2
sudo a2enmod rewrite

-----------------------------------------------------------------------------------

MySQL 8 Installation

sudo apt-get install mysql-server


sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
CREATE USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY
'Admin@123';
GRANT ALL ON . TO 'admin'@'localhost';
sudo mysql_secure_installation

Note:- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <PUBKEY>

-----------------------------------------------------------------------------------
-

Php 7.4

sudo add-apt-repository ppa:ondrej/php


sudo apt-get update
sudo apt install php7.4 (any version)

sudo apt install php7.4-fpm (any version for Nginx web server)

(7.4 php extensions)

sudo apt install php7.4-bcmath


sudo apt install php7.4-bz2
sudo apt install php7.4-cli
sudo apt install php7.4-dba
sudo apt install php7.4-dev
sudo apt install php7.4-mbstring
sudo apt install php7.4-gd
sudo apt install php7.4-imap
sudo apt install php7.4-mysql
sudo apt install php7.4-soap
sudo apt install php7.4-xml
sudo apt install php7.4-zip
sudo apt install php7.4-intl
sudo apt install php7.4-curl
sudo apt-get install php7.4-mcrypt

php 7.3

sudo apt install software-properties-common


sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php7.3
sudo apt install php7.3-fpm

(7.3 php extensions)

sudo apt install php7.3-bcmath


sudo apt install php7.3-bz2
sudo apt install php7.3-cli
sudo apt install php7.3-dba
sudo apt install php7.3-dev
sudo apt install php7.3-mbstring
sudo apt install php7.3-gd
sudo apt install php7.3-imap
sudo apt install php7.3-mysql
sudo apt install php7.3-soap
sudo apt install php7.3-xml
sudo apt install php7.3-zip
sudo apt install php7.3-intl
sudo apt install php7.3-curl
sudo apt-get install php7.3-mcrypt

-----------------------------------------------------------------------------------
-----------

(htdocs setup for PHP)

(Make the user account and run htdocs commands)


sudo mkdir htdocs
chown -R username:(username) htdocs/ --------- in /home/
chmod -R 775 htdocs/ --------- in /home/
-----------------------------------------------------------------------------------
-------------

(PhpMyAdmin Installation (only user profile in htdocs))

wget https://files.phpmyadmin.net/phpMyAdmin/5.1.2/phpMyAdmin-5.1.2-all-
languages.zip
unzip phpMyAdmin-5.1.2-all-languages.zip
rm -rf phpMyAdmin-5.1.2-all-languages.zip
mv phpMyAdmin-5.1.2-all-languages/ phpmyadmin
cd phpmyadmin
sudo cp config.sample.inc.php config.inc.php
vi config.inc.php

-----------------------------------------------------------------------------------
-----------------------------------------
Elasticsearch Installation (for magento)

sudo wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-


7.16.0-amd64.deb
sudo dpkg -i elasticsearch-7.10.0-amd64.deb
sudo systemctl daemon-reload
sudo systemctl restart elasticsearch
curl -XGET "http://localhost:9200"
sudo systemctl stop elasticsearch

---------------------------------------------------------------
* To Find Multiple php version

php (tab) --list php

----------------------------------------------------------------
vim /etc/php/7.4/apache2/php.ini for editing extensions

-----------------------------------------------------------------------------------
--------------

Compelety Removed MySQL from Ubuntu

sudo systemctl status mysql


sudo systemctl stop mysql
sudo apt purge mysql-server*
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-
client-core-*
ls /etc/mysql
sudo ls /var/lib/mysql
sudo rm -r /etc/mysql /var/lib/mysql
sudo rm -r /var/log/mysql
sudo apt autoremove
sudo apt autoremove --purge
sudo apt autoclean
sudo apt update

-----------------------------------------------------------------------------------
-----------------

I was facing the same problem but solved it through the below command

sudo apt install libapache2-mod-php8.1

sudo systemctl restart apache2

-----------------------------------------------------------------------------------
------------------

You might also like