WordPress/LAMP Installation On Raspberry Pi

Were you thinking of making a WordPress site? Now you can! Just follow the tutorial on Wordpress/LAMP Installation On Raspberry Pi!

Intermediate Difficulty 

Hardware needed:

  • Raspberry Pi
  • 8GB Micro SD Card
  • A monitor and keyboard or a computer
  • Raspbian Lite connected to wifi 
Installation of Apache
  1. Boot up the Raspberry Pi
  2. Connect a monitor and keyboard or ssh into the Raspberry Pi
  3. Get the latest firmware updates
    sudo apt-get update && sudo apt-get upgrade
  4. If you already have the latest firmware, skip this step. Reboot your Raspberry Pi sudo reboot
  5.  Download and install apache 2
    sudo apt-get install apache2
  6. Type
    hostname -I
  7. Test the web server by opening a browser and searching http://(Ip address given by the step above) If everything is working you should see the site saying “It works!”

Installation of php

  1. Install php with
    sudo apt-get install php
  2. Move to the directory of the default page
    cd /var/www/html
  3. Test to see if php is working by adding a php file
    sudo nano index.php
  4. In the file, paste 
    <?php echo "hello world"; ?>
  5. Exit out of the file and save it using: CONTROL+ X,  Y, ENTER
  6. Remove the default apache file using
    sudo rm index.html
  7. Go back to the web browser and reload the http page, if everything is working, the website should say “hello, world”
Installation of mysql
  1. Install MySql with
    sudo apt-get install mysql-server php-mysql
  2.  Restart apache
    sudo service apache2 restart
INSTALLATION of wordpress
  1. Change directories
    cd /var/www/html/
  2.  Delete all files in the directory
    sudo rm *
  3.  Download WordPress
    sudo wget http://wordpress.org/latest.tar.gz
  4. Extract the downloaded file
    sudo tar xzf latest.tar.gz
  5.  Move the extracted files
    sudo mv wordpress/* .
  6.  Remove compressed files
    sudo rm -rf wordpress latest.tar.gz
  7.  Run ls and the output should be
    .
    ├── index.php
    ├── license.txt
    ├── readme.html
    ├── wp-activate.php
    ├── wp-admin
    ├── wp-blog-header.php
    ├── wp-comments-post.php
    ├── wp-config-sample.php
    ├── wp-content
    ├── wp-cron.php
    ├── wp-includes
    ├── wp-links-opml.php
    ├── wp-load.php
    ├── wp-login.php
    ├── wp-mail.php
    ├── wp-settings.php
    ├── wp-signup.php
    ├── wp-trackback.php
    └── xmlrpc.php
    
    3 directories, 16 files
  8. Change owner ship to the Apache user 

    sudo chown -R www-data: . 

WordPress database setup
  1. Run the MySQL installation setup
    sudo mysql_secure_installation
  2.  You will now be asked for a Password: Enter current password for root (enter for none): – Press Enter
  3. Type in Y and press Enter to Set root password?
  4. Type in a password at the New password:Important:  This is your root login password for your website! Don’t forget it as it is needed!
  5. Type to remove anonymous users
  6. Type in Y to Disallow root login remotely
  7. Type in Y to Remove test database and access to it
  8. Type in Y to Reload privilege tables now
  9. You should now see everything is done.
  10. Run MySQL
    sudo mysql -uroot -p
  11. Enter the password you have created before.
  12. At the MariaDB [(none)]> prompt
    create database wordpress;
  13. If it has worked this is the output
    Query OK, 1 row affected (0.00 sec)
  14. Grant privileges (change YOURPASSWORD to your root password)
    GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' IDENTIFIED BY 'YOURPASSWORD';
  15.  For changes to take place use
    FLUSH PRIVILEGES;
WordPress configuration
  1. Open a web browser and navigate to http://localhost
  2. Select your language and continue
  3. Click Let’s go!
  4. Fill out the information with (Change YOUR PASSWORD to your root password)
    Database Name:      wordpress
    User Name:          root
    Password:           <YOUR PASSWORD>
    Database Host:      localhost
    Table Prefix:       wp_
  5.  Click Submit
  6. Hit install
  7. Give your website a name, enter a username and email then click the installation button
  8. Use http://localhost/wp-admin to visit your site
  9. It is useful to change permalinks to make your websites URLs nicer,  goto settings, permalinks, and change to the Postname option.
  10. Enable apache rewrite
    sudo a2enmod rewrite
  11. Open the config file
    sudo nano /etc/apache2/sites-available/000-default.conf
  12.  Add this directly after Line 1
    <Directory "/var/www/html">
        AllowOverride All
    </Directory>
  13.  Restart apache
    sudo service apache2 restart

    There you have it! Enjoy your new site!

Any questions? Post in the comments section!

 

 

 

Leave a Reply

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