How to Set Up a Raspberry Pi Web Server

1. Navigate to the command prompt / terminal. You can get there by hitting CTRL+ALT+T from the Raspbian desktop or connecting remotely via SSH if you have that configured. Some users also configure the Raspberry Pi to boot directly to the command prompt.

2. Update your packages by typing

sudo apt-get update

3. Install apache2 with the command:

sudo apt-get install apache2 -y

4. Install php for your sever by typing:

sudo apt-get install php libapache2-mod-php -y

5. Install mariadb so you can use a mysql database with your website. You start by typing:

sudo apt-get install mariadb-server

Then, after the download is finished. You must do the formal install by typing:

sudo mysql_secure_installation

6. Install the php-mysql connector so php pages can access the DB.

sudo apt install php-mysql

8. Test your server. On the Raspberry Pi itself, you should be able to go to http://localhost and see a test page. From another computer on the same network, you should be able to get there by visiting http://raspberrypi.local or http://raspberrypi, provided that your Raspberry Pi's hostname is raspberrypi. 

9. Build your website by putting html or PHP files in the /var/www/html directory.


Comments

Popular Posts