raspberry_pi:projects:lamp_server
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| raspberry_pi:projects:lamp_server [2025/02/06 08:13] – created jmbargallo | raspberry_pi:projects:lamp_server [2025/02/07 08:41] (current) – jmbargallo | ||
|---|---|---|---|
| Line 11: | Line 11: | ||
| sudo apt install apache2 -y | sudo apt install apache2 -y | ||
| + | | ||
| + | ===== Install PHP ===== | ||
| + | |||
| + | PHP is a preprocessor: | ||
| + | |||
| + | Type the following command in the terminal to install PHP: | ||
| + | |||
| + | sudo apt install php -y | ||
| + | |||
| + | ==== Test PHP ==== | ||
| + | |||
| + | Type this command to delete the index.html file from earlier: | ||
| + | |||
| + | sudo rm index.html | ||
| + | |||
| + | Create a new file called index.php: | ||
| + | |||
| + | sudo nano index.php | ||
| + | |||
| + | In the nano code editor, type this PHP code into the file and save it. | ||
| + | |||
| + | <?php echo "hello world"; | ||
| + | |||
| + | Refresh your browser. You should see “hello world”. This page is not dynamic, but it is still served by PHP. | ||
| + | |||
| + | ==== Priority PHP Apache’s Configuration File ==== | ||
| + | |||
| + | |||
| + | On Debian/ | ||
| + | |||
| + | sudo nano / | ||
| + | |||
| + | On CentOS/ | ||
| + | |||
| + | sudo nano / | ||
| + | |||
| + | If you're using virtual host configurations, | ||
| + | |||
| + | Modify the DirectoryIndex Directive | ||
| + | |||
| + | Look for a line like this: | ||
| + | |||
| + | DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm | ||
| + | |||
| + | Change it so that index.php comes first: | ||
| + | |||
| + | DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm | ||
| + | |||
| + | Save and Exit | ||
| + | |||
| + | If using nano, press CTRL + X, then Y, and hit Enter to save. | ||
| + | |||
| + | Restart Apache to Apply the Changes | ||
| + | |||
| + | On Debian/ | ||
| + | |||
| + | sudo systemctl restart apache2 | ||
| + | |||
| + | On CentOS/ | ||
| + | |||
| + | sudo systemctl restart httpd | ||
| + | |||
| + | |||
| + | ===== Install MariaDB ===== | ||
| + | |||
| + | |||
| + | MariaDB is a popular database engine. Like PHP, it’s widely used on web servers, which is why projects like WordPress use it, and why those projects are so popular. | ||
| + | |||
| + | Type this command to install the MariaDB Server and PHP-MySQL packages: | ||
| + | |||
| + | sudo apt install mariadb-server php-mysql -y | ||
| + | |||
| + | Now restart Apache: | ||
| + | |||
| + | sudo service apache2 restart | ||
| + | |||
| + | ==== Set up ==== | ||
| + | |||
| + | |||
| + | Run the MySQL secure installation command in the terminal window. | ||
| + | |||
| + | sudo mysql_secure_installation | ||
| + | |||
| + | Go through the setup wizard : | ||
| + | |||
| + | |||
| + | |||
| + | * Enter current password for root (enter for none): — press Enter. | ||
| + | * | ||
| + | * Switch to unix_socket authentication [Y/n] - Type in N and press Enter | ||
| + | * | ||
| + | * Change the root password? - Type in Y and press Enter | ||
| + | * | ||
| + | * New password: - Type in a password and press Enter, then repeat a second time. Important: remember this root password, as you will need it later to set up WordPress. | ||
| + | * | ||
| + | * | ||
| + | * | ||
| + | * | ||
| + | * | ||
| + | * | ||
| + | * | ||
| + | * | ||
| + | |||
| + | |||
| + | |||
| + | | ||
raspberry_pi/projects/lamp_server.1738829626.txt.gz · Last modified: 2025/02/06 08:13 by jmbargallo
