O'Brien Labs

  • Home
  • Portfolio
  • WordPress
    • Plugins
    • WordPress Tips
  • Random Post
  • About

Keyboard Shortcuts

R - Load a random post.
? - Open this dialog window.
O'Brien Labs > Raspberry Pi > Raspberry Pi – Install Apache, PHP & MySQL Keyboard Shortcuts

Raspberry Pi – Install Apache, PHP & MySQL

December 26, 2014 by Pat Leave a Comment

Share this post:

I always install Apache and PHP on my Raspberry Pi’s so that I can write and deploy small web applications. Once they’re setup, they’re good to go. There are times where I’ll get a new Raspberry Pi and/or have to reformat mine (typically because of boredom). This usually involves me having to remember how to install Apache, PHP, MySQL and phpMyAdmin from scratch. So I’m throwing together this small tutorial so that I can remember how to do this in the future. Hopefully it helps you out, too.

First we want to make sure our hostname is correct on the Raspberry Pi.

cat /etc/hostname

If it matches what you want it to match, then you’re good to go. If not, you’ll need to update it.

sudo nano /etc/hostname

Then reboot by running

sudo reboot

Once it’s back up, log back in and we’ll begin to install our packages. First step is to update the package list.

sudo apt-get update

When it’s done, install Apache first:

sudo apt-get install apache2 apache2-utils

Once that’s finished, install PHP:

sudo apt-get install libapache2-mod-php5 php5

And when it’s complete, install MySQL Server and Client

sudo apt-get install mysql-server mysql-client php5-mysql

Finally, phpMyAdmin which is a web front-end for MySQL

sudo apt-get install phpmyadmin

Lastly, phpMyAdmin is known to be a hotspot for attackers, so what I like to do is rename it to something random so it’s not easily found by attackers on the internet. I do this even if the Raspberry Pi is behind a firewall and not directly connected to the internet. Why? Because why not.

To hide phpMyAdmin we just need to make 1 change to the Apache config file for phpMyAdmin, then restart Apache. For safe measure you could even restart your Raspberry Pi.

sudo nano /etc/apache2/conf.d/phpmyadmin.conf

Where it says Alias /phpmyadmin /usr/share/phpmyadmin, we’ll want to change the /phpmyadmin portion to something random and something you’ll remember.

Alias /supersecretphpadmin012014 /usr/share/phpmyadmin

Last but not least, we need to restart Apache so it picks up the new config settings.

sudo service apache2 restart

That should do it! To verify everything is working, just browse to http://yourpi.ip.address/supersecretphpadmin012014 and you should see phpMyAdmin’s login prompt.

Share this post:

About Pat

I'm a sysadmin, WordPress Core Contributor, plugin & theme developer. I've also developed a few non-WordPress websites. I'm a technologist at heart. I enjoy tinkering on many projects. Here on my site you will find some of the projects I've worked on. Whether it's the WordPress plugins I've made, some WordPress tips, various tech tips, or even a couple Halloween props.

View all posts by Pat

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

About

The purpose of this site is for me to share my DIY technical experiences as a place to document them publicly. Hopefully somewhere along the way they are helpful for you.

Recent Posts

  • BelchertownWeather.com website theme for weewx
  • How to setup your own MQTT Broker
  • Nest Thermostat Push Notifications
  • mailx – Send automated Linux email with gmail
  • simplemonitor – who watches the Nagios watchman?

Tags

ad adblock amp Asterisk AutoHotKey battery block Camera car code codesnips database developer Emergency halloween Heat Home Inverter Linux load Nagios night plugins portfolio Power Project Raspberry Pi simplemonitor snippets Tech Tips Timelapse tips Tutorial ublock vision Weather Station webcam website weewx WordPress

Copyright © 2010–2019 O'Brien Labs – All Rights Reserved – Use without permission is illegal.

Please support this website by adding us to your whitelist in your ad blocker. Ads are what helps us bring you premium content! Thank you!