Ricmedia PC Help

Tech guides for everyone.

  • Home
  • Browsers +
    • Chrome
    • Chromium
    • Firefox
    • Internet Explorer
    • Microsoft Edge
    • Safari
    • Opera
    • Browsers (all)
  • Windows +
    • Windows 10
    • Windows 8/8.1
    • Windows 7
    • Windows Vista
    • Windows XP
    • Windows (all)
  • Other OS +
    • Linux
    • MAC OS X
    • Raspbian
    • Other OS (all)
  • MS Office +
    • Office 2013
    • Office 2010
    • Office 2007
  • Software +
    • Antivirus
    • Audio
    • Image
    • System Tools
    • Video
    • Web
  • More +
    • Raspberry Pi
    • Networking
    • Hardware
    • Builds
    • Tools & Apps
    • Miscellaneous
    • Get a Product Reviewed
    • Support +
      • Help
      • Sitemap
      • Legal
      • About
      • Contact
    • Legal +
      • Disclaimer
      • Copyright
      • Privacy Policy
      • Terms of Service

Setup LAMP Server on Raspberry Pi 3 – [Updated 2018] Complete DIY Guide

March 7, 2017 By Richie 21 Comments

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

Login prompt on Raspbian
Login prompt on Raspbian

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

This slideshow requires JavaScript.

Now we can move on to the next section Install LAMP Server Packages, Setup FTP

Share ➤

  • Twitter
  • Facebook
  • Google
  • Print

Related

Pages: 1 2 3 4

Filed Under: Builds, Hardware, Linux, Motherboards, Other OS, Raspberry Pi, Raspberry Pi 3, Raspbian, Web Design Tagged With: Apache, LAMP, LAMP Server, Linux, MySQL, PHP, Portable, Raspberry Pi, RasPi, Web Server

About Richie

I started working with computers in 1996 with the advent of the Internet and started my own online shop selling musical instrument accessories in 2000.

In 2006 I studied Multimedia Development & Design which opened up the world of Photoshop, HTML, Flash and JavaScript.

Since then I have designed dozens of websites as well as maintaining my own group of websites including Ricmedia PC Help and Ricmedia Guitar among others.

I am currently the webmaster and content creator for all Ricmedia.com websites.

Comments

  1. Kenneth H says

    February 4, 2018 at 6:28 pm

    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 ?

    Reply
    • Richie says

      February 4, 2018 at 6:50 pm

      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:

      1
      2
      3
      4
      5
      create user 'wordpress2'@'localhost' identified by 'abc123';
      create database wordpress2;
      grant all privileges on wordpress2.* to 'wordpress2'@'localhost';
      flush privileges;
      exit;

      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

      Reply
      • Kenneth H says

        February 4, 2018 at 10:44 pm

        that did the trick 🙂

        thank you ! and sorry for my noob mistake

        Reply
        • Richie says

          February 4, 2018 at 10:46 pm

          No worries at all mate, cheers, Richie

          Reply
  2. Richie says

    January 30, 2018 at 8:43 pm

    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

    Reply
  3. Angelo says

    January 30, 2018 at 10:30 am

    Thanks alot for the guide. Please note that default phpmyadmin login details are: phpmyadmin with the password that you provided in the setup prompt.

    Reply
  4. orthodoxcumbriawebmaster says

    January 27, 2018 at 4:08 am

    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.

    Reply
    • Richie says

      January 27, 2018 at 10:59 am

      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

      Reply
  5. Joshua says

    January 7, 2018 at 5:40 am

    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.

    Reply
    • Richie says

      January 7, 2018 at 11:46 am

      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

      Reply
  6. Michu says

    December 30, 2017 at 10:42 pm

    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?

    Reply
    • Richie says

      December 30, 2017 at 10:53 pm

      Hi Michu, are you sure you put in the right web address? Remember you need to find the Raspberry Pi IP address with ifconfig OR ip 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

      Reply
  7. Angel says

    December 28, 2017 at 8:01 pm

    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?

    Reply
    • Richie says

      December 28, 2017 at 8:15 pm

      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 use sudo mysql or if you’re already logged in as root just type mysql 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

      Reply
  8. Tevis C says

    November 30, 2017 at 6:12 am

    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.

    Reply
    • Richie says

      November 30, 2017 at 8:22 am

      I would love to do many more RPi tutorials, time is the factor 😉 cheers, Richie

      Reply
  9. Scott J says

    June 9, 2017 at 12:03 pm

    My bad…. I missed it…. you have a link to FileZilla in the section just above where I jumped to…. thank you!

    Reply
  10. Scott J says

    June 8, 2017 at 1:25 pm

    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!

    Reply
    • Richie says

      June 8, 2017 at 1:48 pm

      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! Richie

      Reply
      • Scott J says

        June 10, 2017 at 11:33 am

        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.

        Reply
        • Richie says

          June 10, 2017 at 12:30 pm

          Hi Scott, yes VSFTPD is the better/safer option. I actually do go through changing the AllowRootLogin without-password to AllowRootLogin 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

          Reply

Leave a comment Cancel reply

HELP & SUPPORT

  • About us
  • Contact details
  • FAQ
  • Sitemap

NEWS & FEED

  • Latest news
  • Subscribe to Newsletter
  • Subscribe to RSS feed

SOCIAL

  • facebook.com/ricmedia.pchelp
  • twitter.com/RicmediaPCHelp
  • youtube.com/user/RicmediaPCHelp
  • Google+ Page

Help & Support • Legal, Terms & Privacy • Contact Details • Copyright ©2006- Ricmedia • Part of the Ricmedia group of websites   Part of the Ricmedia group of websites