Step 1: Install Apache
- Updating for Installing Apache
-> sudo apt update - than after install apache using blow command
->sudo apt install apache2
- than after check the the status
->sudo systemctl status apache2
- Open your browser and check http://localhost it will show a page
Step 2: Install mysql database and configuration
- install mysql database using blow command
->sudo apt install mysql-server
- After install mysql run blow commmand for set username or password
-> sudo mysql
->ALTER USER 'your username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your password';
Note: change your username or password according to you after these changes write ‘exit’ and then press enter
Note: By running ‘sudo mysql_secure_installation’ you can quickly configure some basic security settings for your “MySQL/MariaDB” server, helping to protect it against common vulnerabilities and ensuring that it's set up in a more secure manner for production use.
- For testing that you mysql is proper working or not you can run the blow command
-> sudo mysql -u root -p
-> after you see this type you can write ‘exit’ and then enter
Step 3: Install Php
-
For install php you run blow command
-> sudo apt install php libapache2-mod-php php-mysql - check your php version run the blow command
-> php -v
- then after run the blow the command
->sudo nano /etc/apache2/mods-enabled/dir.conf
Note: command it will open a file in terminal like this -
“<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>”
Note: Here simply change - at the first ‘index.html’ replace with ‘index.php’ and ‘index.php’ replace with ‘index.html’ after changing the code should looks like this -
-> Then save and close with ctrl + x
- After this, restart the Apache web server like blow command
-> sudo systemctl restart apache2 - You can also check on the status of the apache2 service using\ systemctl
-> sudo systemctl status apache2
- then run the php cli command
->sudo apt install php-cli
Note : when you run "sudo apt install php-cli" it installs the PHP CLI package, which includes the PHP interpreter and other necessary files for running PHP scripts from the command line. This is useful for various tasks, such as running PHP scripts, executing PHP commands and interacting with PHP applications without the need for a web server or browser
- Now we are recursively changing the ownership of the directory and all its contents to the current user and group. Using command
-> sudo chown -R $USER:$USER /var/www/html - To make sure your configuration file doesn’t contain syntax errors, run the following command
-> sudo apache2ctl configtest - Finally, reload Apache so these changes take effect
-> sudo systemctl reload apache2
Step 4: Install Phpmyadmin
- Updating for Installing phpmyadmin
-> sudo apt update
- Run the following command to install these packages onto your system
->sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
Note: If the above command open a popup in terminal then select apache2 then ok and configure in last you will see abort in the popup so just select that and enter with ok
- run this command and then enter your password
-> mysql -u root -p
- From the prompt, run the following command to disable the Validate Password component
->UNINSTALL COMPONENT "file://component_validate_password"; - Following that, you can close the MySQL
-> exit - Now go to the browser and locate to the phpmyadmin
http://localhost/phpmyadmin
NOTE : if phpmyadmin show not found then just go to this path in your system directory
-> “/etc/apache2”
-> Open " apache2.conf " file in your editor and paste the below code in end
of the file
“ Include /etc/phpmyadmin/apache.conf ”
- Then use this command to restart apache server
-> sudo service apache2 restart
“Now it should work”