Apache, ProFTP, PHP, and WordPress – Raspberry Pi Zero

Great Links:
Have to use Jessie build.

Use windows key to go to the Terminal Session. Jessie boots to Xwindows.

sudo raspi-config
expand FS.
Enable SSH.
Boot to command prompt.

sudo raspi-config
Change Localization to: en_US-UTF8
Changed PI password.
exit. Reboot
login as PI
change root password: sudo passwd root

reboot. Test logins.
Setup wireless:

Edit the interfaces file etc/network/interfaces

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf


Edit etc/resolv.conf

# Google’s public DNS servers


Edit the file etc/wpa_supplicant/wpa_supplicant.conf

Add this to the end:

ssid=”my network name”
psk=”my network password”


Reboot. PING. Use SSH now.

sudo apt-get update -y
sudo apt-get upgrade -y

sudo rpi-update


sudo apt-get clean
=========== OPTIONAL APACHE ===========

sudo apt-get install apache2 php5 libapache2-mod-php5

sudo service apache2 restart

Test Webpage
=========== OPTIONAL FTP ===========

To get our program source code to the server we need a FTP connection. For this we install ProFTP.

sudo apt-get install proftpd

During installation we choose ‘standalone’.


For our FTP server we don’t need real Unix users, but some virtual ones. For this we change the following file:

sudo nano /etc/proftpd/proftpd.conf

we add the following lines at the end:

DefaultRoot ~
AuthOrder mod_auth_file.c mod_auth_unix.c
AuthUserFile /etc/proftpd/ftpd.passwd
AuthPAM off
RequireValidShell off


Now we create a virtual User (for me the username is hansi):

cd /etc/proftpd/
sudo ftpasswd passwd name ftp-admin uid 33 gid 33 home /var/www/ shell /bin/false

Now you will be asked to set a password for the FTP user. This FTP user now has read and write permissions for your web server root directory. We only need to set some rights:

sudo chmod g+s /var/www
sudo chmod 775 /var/www
sudo chown -R www-data:www-data /var/www

The last thing is to restart out FTP server daemon:

sudo /etc/init.d/proftpd restart

=========== OPTIONAL WORDPRESS ===========

cd /var/www/html
ls -al

Should be no files. If index.html you will need to rename it or remove it. It takes precendence over the index.php

sudo apt-get install php5 libapache2-mod-php5 -y
(Already installed from above)


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

cd /var/www/html/
sudo chown pi: .
sudo rm *
wget http://wordpress.org/latest.tar.gz

tar xzf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz

– DB Portion –

mysql -uroot -ppassword <- Your password here. >


mysql> create database wordpress;

Exit out of the MySQL prompt with Ctrl + D.

sudo service apache2 restart

TEST – SHould get the webpage with a Let’s Go Button.

Click the big button marked Let’s go! button on the next page.

Now fill out the basic site information as follows:

Database Name: wordpress
User Name: root
Database Host: localhost
Table Prefix: wp_
Upon successful database connection, you will be given the contents of your wp-config.php file:


Had to paste contents into new file located at /var/www/html called wp-config.php

Click Run Install

Should get a Information needed screen.

It’s recommended that you change your permalink settings to make your URLs more friendly.
To do this, log in to WordPress and go to the dashboard. Go to Settings then Permalinks.
Select the Post name option and click Save Changes.

I SET MINE UNDER CUSTOM TO: /%year%/%monthnum%/%day%/%postname%/

After saving, you will be prompted to update your .htaccess file.
You probably don’t have one yet, so add one in /var/www/html/ by typing nano .htaccess; note this is a hidden file, so it starts with a dot.

Then paste in the contents provided:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Save the file and return to the website homepage.

Click on the post title or the sample page link and you’ll probably see a Not Found error page.
This is because the rewrite module has not been enabled in Apache.
To do this, enter sudo a2enmod rewrite.

service apache2 restart

You’ll also need to tell the virtual host serving the site to allow requests to be overwritten.
Do this by editing the virtual host file (with root permissions):
sudo nano /etc/apache2/sites-available/default
also, change the AllowOverride setting on line 11 (inside the <Directory /var/www/html/> block) from None to All. Save the file and then restart Apache with sudo service apache2 restart. Once it’s restarted, refresh the page and it should load successfully. Now posts have URLs like /hello-world/ instead of /?p=123, and pages have URLs like /sample-page/ instead of /?page_id=2.

Edited apache2.conf in

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride ALL <— CHANGED TO ALL
Require all granted

<Directory /var/www/html> <—- CREATED THIS WHOLE SECTION for HTML
Options Indexes FollowSymLinks
AllowOverride ALL
Require all granted


service apache2 restart

You may need to set the timzone if you notice bad times on pages: sudo dpkg-reconfigure tzdata

Also set timezone within WordPress, Settings – General.

service apache2 restart

sudo chmod g+s /var/www
sudo chmod 775 /var/www
sudo chown -R www-data:www-data /var/www
service apache2 restart
sudo /etc/init.d/proftpd restart



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s