Introduction
This page describes how I setup the web server Apache, specifically Apache2, along with PHP and MariaDB.Note I use MariaDB in preference to the original MySQL database.
hostname -I
sudo apt-get install apache2 apache2-doc apache2-utils
sudo apt-get install php libapache2-mod-php php-pear -y
sudo apt-get install mariadb-server mariadb-client php-mysql
sudo service apache2 restart
Apache is run via the binary apache2
To start / stop Apache use:
/etc/init.d/apache2
or
apache2ctl
but not /usr/bin/apache2 directly as it will not work on Raspbian Linux as it is Debian based.
sudo apache2ctl stop
sudo apache2ctl start
sudo apache2ctl restart
Important Files Location
Put your website into:/var/www/html/
It will be necessary to rename the default Apache index.html file via
mv index.html oldindex.html
You can then copy your website into /var/www/html/
- Apache 2 Configuration files
/etc/apache2/apache2.confapache2.conf is the main Apache configuration file.
This file is used by Debian instead of the more common httpd.conf
If you have PHP installed then you probably want Apache to serve index.php as the default page instead of index.html
To do this :
sudo nano /etc/apache2/mods-enabled/dir.conf
and put index.php before index.html so that it looks like :
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Debian, on which Raspbian is based, uses apache2.conf and dir.conf for some of the configurations.
Further Help
INSTALL APACHE, PHP 7.0 AND MYSQL/MARIADB ON A RASPBERRY PI (LAMP) WITH PHPMYADMIN
How to install a web server on the Raspberry Pi (Apache + PHP + MySQL)
How to setup a Raspberry Pi web server with Raspbian Stretch Lite, Nginx, MariaDB and PHP as the LEMP stack
No comments:
Post a Comment