DEV Community

Cover image for PHP - Installation on Linux Based Operating System
Shrikant Dhayje
Shrikant Dhayje

Posted on • Originally published at codewithshriekdj.netlify.app on

PHP - Installation on Linux Based Operating System

So I Will Try to Make Series About the PHP.

PHP is an Scripting language Majorly Used for Back-end Web Development and also more than 50 % websites on internet use PHP as back-end.

Development Environment on Linux

One of the most common server configuration for linux is LAMP stack (Linux, Apache, MYSQL, PHP).

For Linux we will try to install apache, MySQL separately and try not to install third party applications.

You can still install XAMPP if you prefer, but remember in production you should not try third party applications.


Check System updates of Linux

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist -upgrade
Enter fullscreen mode Exit fullscreen mode
  • Here sudo is for superuser ( as a linux user you may already know it ).
  • Here all packages and whole operating system is being updated and upgraded.

Installing Apache Server On Linux

sudo apt-get install Apache2
Enter fullscreen mode Exit fullscreen mode
  • We Use apache server for running our site under localhost

Installing MySQL on Linux Based Operating System

sudo apt-get install mysql-server

sudo my_sql_secure_installation.
Enter fullscreen mode Exit fullscreen mode
  • It will ask to create database password so Create an Secure Password.

Start an Apache Server On Linux

sudo service apache2 start
Enter fullscreen mode Exit fullscreen mode

You will get the below image on screen.

apache2-ubuntu-default-page.png


Start MySQL through another terminal simultaneously

sudo mysql -u root
Enter fullscreen mode Exit fullscreen mode

Image Given Below

MySql Starting Command In Ubuntu Terminal


Now Actually Installing PHP on Linux Lol 😂

sudo apt-get install PHP
Enter fullscreen mode Exit fullscreen mode

This command will install PHP with it's default settings, so you will need to locate the PHP.ini file which can be located at /etc/PHP/8.1/apache2 and also in etc/PHP/8.1/cli.


Installing and Configuring phpmyadmin in Ubuntu / Linux

if you want PhpMyAdmin for setting up and making or altering your database in much more flexible way, you can use following commands.

sudo apt-get install PHPmyadmin
Enter fullscreen mode Exit fullscreen mode

You Will also need to Configure apache to include phpmyadmin with following command.

sudo echo -e "\include etc/PHPmyadmin/apache.conf" >>/etc/apache2/apache2.conf
Enter fullscreen mode Exit fullscreen mode

This is how you are ready to execute and run PHP programs on Linux.


Conclusion

If you found this useful then please share this and follow me! Also check out Buy Me A Coffee if you want to support me on a new level!

Buy me a coffee

Thanks for reading give your thoughts in the comments.

Bye 👋.

Top comments (0)