web Server installation in raspberry pi 3
Server
installation:
Apache
is a popular web server application you can install on the Raspberry
Pi to allow it to serve web pages.
On
its own, Apache can serve HTML files over HTTP, and with additional
modules can serve dynamic web pages using scripting languages such as
PHP.
INSTALL APACHE WEB SERVER:
First
install the
apache2
package
by typing the following command into the terminal:sudo apt
-
get install apache2
-
y
then
test the webserver using browser,put the following url in address bar
http://localhost or 127.0.0.1 or your ip address. Following page will be displayed
f
you see this page, this means apache server is installed succesfully
on your raspberry pi 3.
/var/www/html/ is the defualt root directory of the webpages.
INSTALL PHP:
php is the server side scripting language, which is used to create a website dynamically.issue the following command on the terminal to install the php.
sudo apt
-
get install php5 libapache2
-
mod
-
php5
-
y
now the php interpreter is installed successfully.
Now You can create a php file named index.php as
a first dynamic page of your website.
Copy the following php code and save as index.php
inside the server directory that means /var/www/html/index.php
<?php
echo "<center><h2>welcome to the raspberry pi world</h2></center>";
?>
then start the apahe2 webserver using the following command
service apache2 start
the open any web browser put the ip address or
domain name of your raspberry pi.
Your first php page is displayed in the above pic.
0 comments:
Post a Comment