[Hardware Hacking General] r4v3rr:
How to host a WordPress website from home on a Raspberry Pi Zero.

You will need:

-A Raspberry Pi

-A wireless adaptor

-A bit of time

This guide assumes you already have Raspbian running on your Pi.

All commands can be run over ssh but you will need to VNC into it

a bit later. So you could also do all of it through VNC if you wish.

WARNING:

This is a fun little project but it's not advised to run a website

from your home network. If you miss-configure something or don't keep

things updated on your Pi the risk is greater than if you use a

web hosting service because if your Pi gets compromised, the attacker

now has a full Linux distro already authenticated on your network.

The risk of this actually happening is about as low as getting mugged.

It's not likely but...better safe than sorry.

Now for the good bit:

Ssh to your Pi, change the default password to a strong one and lets get started:

Install apache2:

$ sudo apt-get install apache2 -y

$ sudo apt-get install apache2-util

install mysql and php:

$ sudo apt-get install mysql-server php5-mysql -y

(mysql will prompt you for setup)

Restart apache:

$ sudo service apache2 restart

Move to this directory:

$ cd /var/www/

create a new folder:

$ sudo mkdir wordpress

Move to the new directory:

$ cd wordpress

Get wordpress:

$ sudo wget http://wordpress.org/latest.tar.gz

Extract wordpress:

$ sudo tar xzf latest.tar.gz

Move the contents of the wordpress folder to the current directory:

$ sudo mv wordpress/* .

Delete the now empty folder and the tar:

$ sudo rm -rf wordpress latest.tar.gz

Set perms:

$ sudo chown -R www-data: .

Create a database:

$ mysql -uroot -p (this assumes username is root and will prompt for password)

$ create database WordPress;

Forward port 80 to your Pi:

There is no 'one way' to do this. it depends on what router you have.

If you don't know how to do it, use Youtube and Google to find out how.

What you want to do though is forward port 80 to your Pi's LAN adress.

(the adress you used to ssh to the Pi).

Note: Some internet service providers block traffic on port 80 by

default so you may need to use different ones. If thats the case you might

also need to setup apache differently.

Get a domain name:

Go to a freedns site(https://freedns.afraid.org/) and register a subdomain to

your Pi's EXTERNAL IP adress. You can find your external address by visiting

'whatismyip.com' however this requires a screen so you will have to enable VNC

on your Pi by typing '$ sudo raspi-config' and going to the 'advanced' menu.

You then need a VNC viewer on the computer you are setting this up from. So type

'$ sudo apt-get install xtightvncviewer' then connect to you Pi by typing

'$ vncviewer the.Pi.lan.ip:5901'.

Next we need to point apache to the right directory for Wordpress because

you may have noticed that at the moment your subdomain just takes you

to the apache startup page.

$ sudo nano /etc/apache2/sites-enabled/000-default.conf

This will open a config file. Make sure the directory listing in there

is pointing to your Wordpress directory and add your site alias within

the virtual host tags. It should look something like this:

<VirtualHost *:80>

# blah blah blah

# blah blah blah

# blah blah blah

ServerAdmin webmaster@localhost

DocumentRoot /var/www/wordpress

ServerAlias yoursubdomain.here.com

#My changes

<Directory "/var/www/wordpress">

AllowOverride All

</Directory>

# blah blah blah

# blah blah blah

# blah blah blah

/VirtualHost>

press ctrl+o to save it. Hit enter to confirm then exit by

pressing ctrl+x

Now we need to install Wordpress.

In a browser type you Pi's LAN IP address and Wordpress will guide you

through the installation and setup.

(leave the database host as localhost when prompted)

Now we need to change the URLs in the database we created to

the URL of our subdomain.

For this you need to install PHPmyadmin:

$ sudo apt-get install phpmyadmin

You will be prompted to configure it and you will need to put

database username and password in.

The installation process actually adds the phpMyAdmin Apache

configuration file into the /etc/apache2/conf-enabled/ directory,

where it is automatically read.

The only thing we need to do is explicitly enable the php5-mcrypt

extension, which we can do by typing:

$ sudo php5enmod mcrypt

Afterwards, you'll need to restart Apache for your changes to be recognized:

$ sudo service apache2 restart

You can now access the web interface by visiting:

http://localhost/phpmyadmin (through vncviewer) or

http://lan_ip_of_Pi/phpmyadmin(from another machine on the network)

From here, once logged in, you should be able to see a collapsed directory

tree on the left side of the page. One of the databases listed here

should be named 'wordpress'. expand it by pressing the '+' then

click on 'wp_options'. Now in the main window you should see a

table with various entries. The ones we are interested in are

the ones named 'siteurl' and 'home'. Click the edit button to the

left of them and change the value of both of them to:

'http://YOUR_DOMAIN_HERE.com.'

Now there is just one last place to change the URLs.

In the browser of a machine on the same network as your Pi go to the

LAN IP of your Pi adding '/wp-admin' at the end. Log in with the

details you supplied during the setup. At the top of the page you will

now see an admin toolbar. Hover over the icon that looks like a dial

and click on 'dashboard'. When it loads the side bar, scroll down to

'settings' and select 'general'. Here you change 'Wordpress address URL'

and 'site address URL' to your shiny new domain name.

Voila! You should now have a live to the world Wordpress site

running off a cheap home server, with no hosting costs.

This guide 'should' get you all the way to a live site but there

is a chance that extra configuration is needed or that I forgot

something.

Similar steps can be used for all kinds of different servers. If You just want to serve files straight from an apache index style page you can follow this guide, missing out the wordpress stuff and leaving your apache configs alone. Implementing htaccess you can also password protect your files or a folder. If you do this I highly recommend not adding a directory listing for the folder that is 'private'. even if it is password protected.

Enjoy!!