Generally, a Web server is a computer where the web content is stored which is used to host websites. A website is the collection of web pages while a web server is a software that responds to the request for web resources. In this tutorial, I’ll explain to you that how can you host your website on Raspberry Pi and use your Pi as Hosting Server. We will install Apache web server, PHP, and Mysql database

What Are We Covering Today?

1. Installation steps of PHP and Apache Web server

2. Installation steps of Mysql Server and create a user for phpMyAdmin

3. Step to Install phpMyAdmin

1. Steps to Install PHP and Apache Web server on Your Pi 

Step 1: SSH into your Raspberry Pi and run the following command to update and upgrade your Pi to Latest version of Raspbian

sudo apt-get update && sudo apt-get upgrade

Step 2: Now run the command to install Apache Web server on Your Pi

sudo apt-get install apache2

Step 3: To install the latest version of PHP, enter the following command

sudo apt-get install php

Step 4: Now to start the Apache web server, type the following command

service apache2 start

Step 5: To ensure that Installation was successful or not, open any web browser and type the IP Address of your Pi, in my case the IP address is 192.168.0.101

2. Steps to Install Mysql Server on Your Pi

Step 1: To install the Mysql Server, type the following command and hit enter

sudo apt-get install mysql-server

Step 2: Now type the following command to start the configuration of your Mysql Server

sudo mysql_secure_installation

root pass – 123
Remove anonymous users? [Y/n] – Y
Disallow root login remotely? [Y/n] – N
Remove test database and access to it? [Y/n] – N
Reload privilege tables now? [Y/n] – Y

In my case, I’ll keep my root password 123, You can keep your own. and for remaining configuration, you can select as shown above

Step 3: In this step, I’ll check whether my configuration was successful or not, to do that type the following command and enter the password 123

sudo mysql -u root -p

Now you should be logged in into Database, if not then repeat the Above Steps

Step 4: In this step, We will install python Mysql DB, for this type the following command

sudo apt-get install python-mysqldb

Step 5: Now in the last step, We’ll grant privileges to the username pi (in my case). for that, type the following command to login into Database

sudo mysql -u root -p

enter password 123 and now type this command to grant all privileges to user pi

GRANT ALL PRIVILEGES on mydb.* TO [email protected] IDENTIFIED BY '123';

now type quit and hit enter

3. Steps to Install phpMyAdmin on Your Pi

Step 1: Type the following command to install phpMyAdmin on your Pi

sudo apt-get install phpmyadmin
  • select server – apache2
  • click on yes for Configuring phpmyadmin
  • set password 123

Step 2: Now we have to link the /phpmyadmin folder with /html folder, for that type the following command

sudo ln -s /usr/share/phpmyadmin /var/www/html

Step 3: Now type the following address into your Web Browser to open phpmyadmin. in my case, it is 192.168.0.1/phpmyadmin

web server on the Raspberry Pi

 


Rajesh Ranjan

I'm a tech enthusiast currently pursuing B.Tech in Computer Science & Engineering. trying to make things as simple as possible

0 Comments

Leave a Reply