Setup Raspbian
Once you have your Raspberry Pi setup and plugged in, turn the power switch on via wall socket (there is no on/off switch for the Pi) and look for the boot up screen which resembles a Debian-like boot up process. Debian will automatically expand the filesystem and reboot. After the reboot sequence has finished, you should now be looking at the login prompt
Let’s login with the default username pi and password raspberry (use the Enter key after each command):
1 2 | pi raspberry |
Now let’s setup your Pi, enter the following command (type raspberry
if Debian requests a password for sudo
):
1 | sudo raspi-config |
…then change the following settings (or follow the slideshow further below):
- Note* Use the Arrow keys to move up and down, use Enter key to select/confirm, use Tab key to select Cancel or Finish
- Select Change User Password then Enter, type a strong password, then confirm
- Select Hostname, Ok to alert prompt, then type lamp for hostname (or anything you want) then Ok
- Select Interfacing Options, select SSH, then Yes to enable, then Ok
- On Home Screen, hit Tab key until the <Finish> item is selected, hit Enter to reboot
- You Raspberry Pi is now configured
Now we can move on to the next section Install LAMP Server Packages, Setup FTP
Kenneth H says
awesome tutorial !
everything worked perfect, untill i installed wordpress.
after i Enter database details and then click Submit, i get this error
Error establishing a database connection
This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.
Are you sure you have the correct username and password?
Are you sure that you have typed the correct hostname?
Are you sure that the database server is running?
If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.
i am 100% sure i enter the right username and password.
what could the problem be, and how can i fix it ?
Richie says
Hi Kenneth, thanks mate. This error means that either one or more of the following is incorrect: db username, db password, db host (which should be localhost). When you entered the code to create the database user:
create user 'wordpress'@'localhost' identified by '[enter password]';
did you enter password without the brackets? like this:create user 'wordpress'@'localhost' identified by 'abc123';
? If you’re unsure, create a new database and user as follows:Then enter username: wordpress2, password: abc123, database name: wordpress2, host: localhost, db prefix: wp_ and see if that works mate.
Let me know how you go.
cheers
Richie
Kenneth H says
that did the trick 🙂
thank you ! and sorry for my noob mistake
Richie says
No worries at all mate, cheers, Richie
Richie says
Please Note* This guide has been fully updated (2018-01-30) to reflect the changes to MySQL in Raspbian “Stretch” version 9.x, which has caused a lot of the code to break. There are a few different aspects to how we create databases in that we run MySQL with the sudo prefix instead of logging in as root. Also, all code is now written to conform to the Linux sudo system which greatly increases security.
Let me know if you have any issues with the new code and instructions, but I think you’ll find it all works far better now.
Cheers!
Richie
Angelo says
Thanks alot for the guide. Please note that default phpmyadmin login details are: phpmyadmin with the password that you provided in the setup prompt.
orthodoxcumbriawebmaster says
I think something has changed in the way phpmyadmin is set up, I have tried several tutorials without success. I can log in as phpmyadmin, but then can’t create a new database (no privileges), and root access is denied:
#1698 – Access denied for user ‘root’@’localhost’
mysqli_real_connect(): (HY000/1698): Access denied for user ‘root’@’localhost’
Googling for a solution offers many, but there is no trace of AllowRootLogin in any of the configuration files……
I’ve done this many times on other machines, but this has be stumped.
Richie says
Hi Richard, yes it’s actually MySQL that has changed and now does not allow root login via phpmyadmin interface. But you can fix this issue by following this guide: https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7
Let me know how you go mate.
cheers!
Richie
Joshua says
Hi Richie,
Thanks for putting this tutorial together! I was going through the steps using Raspbian 9.3 and encountered a problem with http:///phpmyadmin/ similar to Michu after completing the phpmyadmin install instructions above. I corrected the 404 not found by including an extra step:
nano /etc/apache2/apache2.conf
At the bottom of the file append:
Include /etc/phpmyadmin/apache.conf
Save and quit, then restart the service:
service apache2 restart
These steps made the phpmyadmin web interface login available.
Richie says
Hi Joshua, thanks for the info. The issue is due to Debian changing the default MySQL engine from MySQL to MariaDB in version 9.x which is why I link directly to version 8.x Jessie in the guide. I will have to update the guide to reflect these change as soon as I can.
cheers
Richie
Michu says
Hi Richie
Thanks for the great tutorial!
I can’t access the phpmyadmin site… how can I delete it on the raspberry to install it again?
Richie says
Hi Michu, are you sure you put in the right web address? Remember you need to find the Raspberry Pi IP address with
ifconfig
ORip address
to find your IP address, then enter http://[ip-address]/phpmyadmin/ so be sure you try that first.If you still want to uninstall PHPMyAdmin, login as root and enter the following code on line at a time:
dpkg -P phpmyadmin
rm -f /etc/apache2/conf.d/phpmyadmin.conf
service apache2 restart
Cheers!
Richie
Angel says
Thank you very much for this tutorial.
During the Install MySQL you mention “note* that you will be asked to enter and confirm a root password during the installation process”, this is not my case the process it doesn’t request MySQL password.
Late in the Setup WordPress Database request the above password, but I don’t know.
“Login to MySQL as root using the same MySQL root password we entered when installing it earlier”
Could you please tell me how to get the root MySQL password in your installation process?
Richie says
Hi Angel, apparently Debian/Raspbian now has MariaDB as the default database instead of MySQL engine. This has made the setup slightly different in that no root password is given. Basically, instead of using the old
-u root -p
command you simply usesudo mysql
or if you’re already logged in as root just typemysql
to bring up the interface. AFAIK MariaDB has no root password making it impossible to actually login as root as a security measure, you need to login with a user that has lower permissions (ie. user of a particular database) or follow this guide on how to give root as password.Let me know how you go.
cheers!
Richie
Tevis C says
I think a great addition to this would be to include a web IDE like Codiad into the tutorial. It allows a new user to get into the web development without getting too deep into setting up an IDE in Linux. This also allows allows the user to code their web page from other devices. I built a WAMP + Codiad + phpMyAdmin and will try to build the same on my R-Pi.
Richie says
I would love to do many more RPi tutorials, time is the factor 😉 cheers, Richie
Scott J says
My bad…. I missed it…. you have a link to FileZilla in the section just above where I jumped to…. thank you!
Scott J says
I think this tutorial is great, and I’m using it this evening to learn about LAMP servers and about my RPi 3. I’m basically new to Linux and while not “new car smell” new, I’m wondering how exactly you envision connecting SFTP? Just since i’m playing around, I figure the SSH-FTP route would be the way to go, but not sure how I’m supposed to use connection data. Are you suggesting using WinSCP or similar which takes the IP address, port, protocol, login, and password? I’m just not clear how that login process is supposed to happen. I’ll dig around on your site some more, but how you’re intending us to apply that information is unclear (I have a guess on some options, but your intention might be easier than what else I might try). Still, I greatly appreciate the post!
Richie says
Hi Scott, thanks for your question and feedback. In this tutorial I give two ways to connect to your RPi; (1) via SSH-FTP (SFTP) which is a bit dangerous as you’ll login as root and have access to entire filesystem or (2) install and setup VSFTPD then login using FTPS which is the better option. The client for both connection types is PuTTY, but any FTP client should do. FTPS is FTP over a secure SSL or TLS encrypted connection, whereas SFTP or SSH-FTP is data transfer over the SSH connection. The reason I recommend FTPS is you can lock-down the folder access to just the
/var/www
folder, whereas the SSH-FTP gives access to the entire filesystem, I realize I could have created a separate Linux user, but it’s difficult to lock down to the/var/www
folder, and permissions are a nightmare. Cheers! RichieScott J says
Thank you Richie. The precaution of using VSFTPD makes sense both in your reply above, and in the main article for the security reasons you cited. For my purposes, which is just trying it out at home, the SSH-FTP route is just fine, but I understand your point and its validity.
One more point, which I think I have right and I’ll make here for anyone passing this way that momentarily is confused on that last section: Although you’re saying to use root for login after changing the sshd_config file, root is not enabled by default on Debian (which Raspbian is based) distributions. You would need to enable the root account, which is not covered in the procedure above.
Richie says
Hi Scott, yes VSFTPD is the better/safer option. I actually do go through changing the
AllowRootLogin without-password
toAllowRootLogin yes
under the “Login to FTP as Root User” section, but you may not have read it as you went down the VSFTPD path 😉 Cheers, Richie