Installing WordPress in RaspberryPi using Apache server
What you need:
- Raspberry Pi Noobs installed and updated
- Access through Putty
Install LAMP
Once you are logged in using Putty, you can copy paste the codes from this page. You can paste it by simply right clicking your mouse inside Putty.
Lets start installing Apache first, copy the code below and paste it to your Putty:
sudo apt-get install apache2
Next is MySQL
sudo apt-get install mysql-server php5-mysql -y
Finally, install Php
sudo apt-get install php5 libapache2-mod-php5 -y
Check Apache if it works. Go to you browser and enter the address of your server, in this tutorial its 192.168.2.101
Check your Php if it works, paste this code in your Putty:
php -r 'echo "\n\nYour PHP is working.\n\n\n";'
Configuring SQL
We will create an SQL database that will be used by the wordpress.
Paste this code, this will ask your SQL root password
mysql -u root -p
Create database named: Raspi
CREATE DATABASE Raspi;
Add user named: pi
CREATE USER [email protected];
Password is Password1
SET PASSWORD FOR [email protected]= PASSWORD("Password1");
Lastly grant user privilege
GRANT ALL PRIVILEGES ON Raspi.* TO [email protected] IDENTIFIED BY 'Password1';
Finish it with the following code:
FLUSH PRIVILEGES;
exit
Installing WordPress
Ensure you are in user root directory
cd
Download the latest WordPress
wget http://wordpress.org/latest.tar.gz
Unzip the file
tar xzvf latest.tar.gz
Make a copy of wp-config.php
cd wordpress
sudo cp wp-config-sample.php wp-config.php
Create directory where we will save the wordpress files
sudo mkdir /var/www/raspi
Copy the wordpress files
sudo rsync -avP * /var/www/raspi/
Give the server user access to folder
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data pi
Configuring WordPress
cd /var/www/raspi
Open WordPress configuration file
sudo nano wp-config.php
Now change the DB_NAME, DB_USER and DB_PASSWORD according to the details below:
/** The name of the database for WordPress */
define('DB_NAME', 'Raspi');
/** MySQL database username */
define('DB_USER', 'pi');
/** MySQL database password */
define('DB_PASSWORD', 'Password1');
cd /etc/apache2/sites-available
check the files on the folder
ls
Some apache version has different filename. If you see default.conf that is the one we need to copy. But in my case it shows 000-default.conf
Lets copy the file and save it as raspi.conf
sudo cp 000-default.conf raspi.conf
Edit raspi.conf
sudo nano raspi.conf
Paste this code:
ServerAdmin [email protected] ServerName 192.168.2.101 ServerAlias www.raspi.com DocumentRoot /var/www/raspi <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/raspi> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory>
activate site
sudo a2ensite raspi.conf
reload apache
sudo service apache2 reload