hello world :-)
Posts: 121
Joined: Sat Nov 14, 2015 7:12 am
Location: England, in an insecure cloud, ie. The Interwebs
Contact: Website Yahoo Messenger AOL

How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Mon Jun 13, 2016 8:26 am

As the title says. LLMP (Linux+lighttpd+MySQL+PHP) stack + PhpBB + phpMyAdmin + h5ai (file indexer, like in Apache only prettier).
Please tell me if this guide helped you (it would make my day) or if you can't get it to work (I'll try to help).
:!: :arrow: After this setup, I'm using 123MB (yes, really) RAM when idle instead of the usual 80MB, so bear that in mind. The main memory hog is MySQL.

(These steps are in the order I did them. They do not neccesarily need to be followed in this order, but some things may not work otherwise.)
Step 1 - Lighttpd
Install lighttpd via apt-get:

Code: Select all

sudo apt-get install lighttpd
Now visit your Pi's IP address. You should see a lighttpd welcome page.

Step 2 - PHP5
Install PHP5 for lighttpd via apt-get:

Code: Select all

sudo apt-get install php5-cgi
Enable PHP5:

Code: Select all

sudo lighty-enable-mod fastcgi
sudo lighty-enable-mod fastcgi-php
Now run this command:

Code: Select all

sudo service lighttpd force-reload
to restart lighttpd, or simply reboot your Pi.

Step 3 - h5ai
Go to http://larsjung.de/h5ai/ and download the latest version of h5ai. However, DO NOT follow the installation instructions on the website. They do not work, and it took me a whole day to figure out why. Instead, just do as shown below.
Open the file manager as root with

Code: Select all

sudo pcmanfm
Decompress (Unzip) the h5ai download into the Document Root of your newly created server (defaults: /var/www on Raspbian Wheezy, /var/www/html on Jessie.)

*The next part is done via the GUI for simplicity*
Right click the _h5ai directory (folder), and go to the Permissions tab. You will see two text fields, both with "root" in them. In both of them, replace "root" with with your server user, which will be "www-data" (no quotes) unless you've changed it. Click OK. It will ask you Do you want to recursively apply these changes to all files and sub-folders?. Click Yes.

Now open /etc/lighttpd/lighttpd.conf in a text editor. Change the line beginning with "index-file.names" to

Code: Select all

index-file.names = ("index.html", "index.php", "/_h5ai/public/index.php")
Save and exit the text editor.

Now, if you want to, you can mess around with the configuration for h5ai in /var/www/html/_h5ai/private/conf (/var/www/_h5ai/private/conf on Wheezy).

Now restart lighttpd via

Code: Select all

sudo service lighttpd force-reload
or simply reboot your Pi.

When you're done with all the above, create a new, empty directory with no index file in /var/www/html (/var/www on Wheezy), and visit that location in your web browser (http://Pi-IP-Address/directoryYouMade). You should see an index of all the files in it (none), instead of a 404 Not Found error as before.

Step 4 - MySQL
Install MySQL and the needed PHP extension via apt-get:

Code: Select all

sudo apt-get install mysql-server mysql-client php5-mysql
As it's installing, it will ask you a few configuration questions. Answer them. When it asks you for a new root password, put a very good one in, as secure as you can manage.
When installation is done, open /etc/php5/cgi/php.ini in a text editor and find the Dynamic Extensions section. Add

Code: Select all

extension=mysqli.so
and

Code: Select all

extension=mysql.so
right at the very end of it.
The Dynamic Extensions section should now look like this:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename.extension
;
; For example, on Windows:
;
;   extension=msql.dll
;
; ... or under UNIX:
;
;   extension=msql.so
;
; ... or with a path:
;
;   extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.
;
extension=msqli.so
extension=msql.so
Now you have the MySQL extensions for PHP enabled.

Part 5 - phpMyAdmin
Install phpmyadmin via apt-get:

Code: Select all

sudo apt-get install phpmyadmin
As it's installing, it'll ask you configuration options.
Choose lighttpd as the server to configure.
Yes, you do want a new database/user.
In the first password field, enter the password you set earlier when installing MySQL.
In the second password field, enter a new password (remember it)
Confirm the new password
Finish installation.

Lastly, run this command.

Code: Select all

sudo ln -s /usr/share/phpmyadmin DOCUMENTROOT/phpmyadmin
replacing DOCUMENTROOT with your server's Document Root (Defaults: /var/www/html on Raspbian Jessie, /var/www on Wheezy).

Part 6 - PhpBB
Go to http://www.phpbb.com and download the latest stable version of PhpBB. (Note: make sure you keep phpBb up to date! There are instructions for updating it on the website.)

Open the file manager as root with

Code: Select all

sudo pcmanfm
Decompress (Unzip) the PhpBB download into the Document Root of the server (defaults: /var/www on Raspbian Wheezy, /var/www/html on Jessie.)

*The next part is done via the GUI for simplicity*
Right click the PhpBB (PhpBB3 at the time of writing) directory (folder), and go to the Permissions tab. You will see two text fields, both with "root" in them. In both of them, replace "root" with with your server user, which will be "www-data" (no quotes) unless you've changed it. Click OK. It will ask you Do you want to recursively apply these changes to all files and sub-folders?. Click Yes.

Go to http://Pi-IP-Address/phpmyadmin and log in as:
User: root
Password: password you created when installing MySQL (not when installing phpMyAdmin)

When you're logged in, click on the Users tab. You will see a list of users. Underneath that, there will be an "Add user" button. Click it.

On the page that appears, enter this info/select these options:
Login Information:
User name: [Use text field:] phpbb-plswork (Note: You can name the user anything, it doesn't have to be phpbb-plswork (I named it that after 3 failed attempts to get it to work). In fact, it would probably be best to name it a random alphanumeric string, so none can guess the name. Just make sure you use the same name everywhere I put my name for it.)
Host: [Any host] %
Password: [Use text field:] enter a strong password here
Re-type: Confirm that password
Database for user: ( [/] = checked, [ ] = unchecked )
[/] Create database with same name and grant all privileges.
[/] Grant all privileges on wildcard name (username\_%).
Global privileges:
Leave all as default

Click OK, then when it's confirmed a new user has been made, click the Log out button (underneath the phpMyAdmin logo at the top left, next to the home button).

Go to http://Pi-IP-Address/TheFolderPhpBBIsIn replacing TheFolderPhpBBIsIn with the folder PhpBB is in in /var/www/html (/var/www on Wheezy), so if you followed this guite exactly, it would be http;//Pi-IP-Address/phpBB (http://Pi-IP-Address/phpBB3 at the time of writing).
You will be greeted with an Introduction page. Click the Install tab at the top, between Overview and Convert.
On the page that appears, click "Proceed to next step".
On the next page, scroll down to the bottom and click "Start install".
On the next page (Database configuration), set everything exactly as shown here:

Database configuration
Database type: [MySQL with MySQLi Extension]
Database server hostname or DSN: localhost
Database server port: (leave blank)
Database name: name you chose for the user you created earlier
Database username: ditto
Database password: (password you set when making a new user in phpMyAdmin)
Prefix for tables in database: (leave as is)

Note: the database name and username will be what you set as the username of the new user you created in phpMyAdmin, so if you followed this guide exactly, the'll be phpbb-plswork, because that's what I set as the username.

Click "Proceed to next step".
On the next page it should say:
Database connection
Test connection: Successful connection

Click "Proceed to next step".
On the next page (Administrator configuration), set everything as follows:
Administrator configuration
Default board language: set to whatever language you want to be used by default
Administrator username: set to whatever you want the administrator username to be - as far as I know you can't change this, so choose wisely
Administrator password: set a password for the account
Confirm password: confirm that password
Contact email address: speaks for itself

Click "Proceed to next step".
On the next page it should say:
Administrator details
Check administrator settings: Tests passed

Click "Proceed to next step".
The next page should say:
The configuration file has been written. You may now proceed to the next step of the installation.

Click "Proceed to next step".
The next page is a big one, but you don't need to change anything. As it says, everything can be changed later if needed.

Click "Proceed to next step".
The next page will take a while to load, but don't be fooled - there's nothing wrong. When it's loaded, you should see this:
The database tables used by phpBB (version) have been created and populated with some initial data. Proceed to the next screen to finish installing phpBB.

Click "Proceed to next step".
The next page will take a while to load, but don't be fooled - there's nothing wrong. When it's loaded, you're almost done!

Keep the web browser open in the background. Open the file manager as root (sudo pcmanfm) and navigate to the phpBB folder. Delete the Install folder inside it.
YOU'RE DONE!

Now you just need to follow the on-screen instructions in the web browser to finish setting up PhpBB.
:)
Last edited by hello world :-) on Wed Sep 21, 2016 2:23 pm, edited 1 time in total.
I do moral support. Here: https://www.raspberrypi.org/forums/search.php?search_id=egosearch
I know I use too many parentheses. Problem?
Topics I have posted in: http://bit.ly/1NbDdr5
My topics: http://bit.ly/1ObnKqQ
All my posts: http://bit.ly/1OHzje7

Abraxas16
Posts: 2
Joined: Sat Jul 23, 2016 7:46 pm

Re: How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Sat Jul 23, 2016 8:00 pm

Hi there, I'm brand new to the forum and I wanted to give you a massive thanks for this guide. I recently rediscovered my rpi and never got around to doing much with it. I decided I'd like to have some fun hosting a forum for some online friends and I, the only thing that I had minor concerns about were the security aspects. Not a huge concern but for peace of mind I wanted to ask, are there any security aspects to all this which are worth noting? Can extra steps be taken to protect the pi server? I've had suggestions of using a dmz on my router or using port forwarding, or a vlan, but it's all stuff I don't have experience in. Are any of those things necessary to ensure the server is as secure as possible from the unlikely event that someone given access to the forum intends to try and gain access to the rest of my network?

Please forgive me for joining and asking for help right away, but yours is the most recent and spot-on guide to achieve what I'm trying to do and I'm a little out of my depth, I figured if anyone may know how to add an extra step to this guide to include extra security steps then it would be wise to ask the author :-) if not, I'm still extremely grateful for the guide regardless. I look forward to getting the spare time to crack on with this!

MDanihy
Posts: 1
Joined: Sun Aug 28, 2016 7:46 pm

Re: How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Sun Aug 28, 2016 8:13 pm

Thanks for taking the time to post these instructions, but there are so many items wrong with it that you should really update and fix.

Abraxas16
Posts: 2
Joined: Sat Jul 23, 2016 7:46 pm

Re: How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Wed Sep 21, 2016 7:55 am

MDanihy wrote:Thanks for taking the time to post these instructions, but there are so many items wrong with it that you should really update and fix.
I'm patiently awaiting a response from the author about this, I suspect it may not be updated for some time. Which items are wrong with it?

hello world :-)
Posts: 121
Joined: Sat Nov 14, 2015 7:12 am
Location: England, in an insecure cloud, ie. The Interwebs
Contact: Website Yahoo Messenger AOL

Re: How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Wed Sep 21, 2016 2:07 pm

Abraxas16 wrote:Hi there, I'm brand new to the forum and I wanted to give you a massive thanks for this guide. I recently rediscovered my rpi and never got around to doing much with it. I decided I'd like to have some fun hosting a forum for some online friends and I, the only thing that I had minor concerns about were the security aspects. Not a huge concern but for peace of mind I wanted to ask, are there any security aspects to all this which are worth noting? Can extra steps be taken to protect the pi server? I've had suggestions of using a dmz on my router or using port forwarding, or a vlan, but it's all stuff I don't have experience in. Are any of those things necessary to ensure the server is as secure as possible from the unlikely event that someone given access to the forum intends to try and gain access to the rest of my network?

Please forgive me for joining and asking for help right away, but yours is the most recent and spot-on guide to achieve what I'm trying to do and I'm a little out of my depth, I figured if anyone may know how to add an extra step to this guide to include extra security steps then it would be wise to ask the author :-) if not, I'm still extremely grateful for the guide regardless. I look forward to getting the spare time to crack on with this!
To be honest, I'm not quite sure... I'm sure there are a lot of things that could be done securer, but this tutorial is the result of 2 days of googling and trial-and-error, and is kind of the best I can do... Currently, my setup is on a LAN. I think it would be best for you to maybe take the basics of the tutorial, and customise it for your own needs (eg. Make it securer, remove things you don't need (eg. h5ai).
To answer one of your questions, no, there are no specific things here that you need to do to make it securer, but I would take the time to go over the PHP and phpBB configuration, and change things how you see fit.
Sorry I didn't reply earlier, but for some reason email notifications weren't working for me...

EDIT: Just noticed something. You can name the database anything, it doesn't have to be phpbb-plswork (I named it that after 3 failed attempts to get it to work). In fact, it would probably be best to name it a random alphanumeric string, so none can guess the name. Just make sure you use the same name everywhere I put my name for it. I will update the tutorial to include this.
Last edited by hello world :-) on Wed Sep 21, 2016 2:18 pm, edited 1 time in total.
I do moral support. Here: https://www.raspberrypi.org/forums/search.php?search_id=egosearch
I know I use too many parentheses. Problem?
Topics I have posted in: http://bit.ly/1NbDdr5
My topics: http://bit.ly/1ObnKqQ
All my posts: http://bit.ly/1OHzje7

hello world :-)
Posts: 121
Joined: Sat Nov 14, 2015 7:12 am
Location: England, in an insecure cloud, ie. The Interwebs
Contact: Website Yahoo Messenger AOL

Re: How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Wed Sep 21, 2016 2:10 pm

MDanihy wrote:Thanks for taking the time to post these instructions, but there are so many items wrong with it that you should really update and fix.
Thanks for the thanks, and sorry I didn't reply sooner. Could you possibly point out some of the problems for me?
I do moral support. Here: https://www.raspberrypi.org/forums/search.php?search_id=egosearch
I know I use too many parentheses. Problem?
Topics I have posted in: http://bit.ly/1NbDdr5
My topics: http://bit.ly/1ObnKqQ
All my posts: http://bit.ly/1OHzje7

User avatar
Hafenzoll
Posts: 2
Joined: Sat Oct 21, 2017 12:55 am
Location: Western Germany
Contact: ICQ Website

Re: How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Sat Oct 21, 2017 12:59 am

/etc/php5/cgi/php.ini
changed to
/etc/php5/apache2/php.ini

Does it not?
Hafenzoll.com

haroldcoyle
Posts: 1
Joined: Wed Feb 20, 2019 10:33 pm

Re: How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Wed Feb 20, 2019 10:41 pm

It is my hope that you are still monitoring this board. I am currently attempting to install phpbb via your instructions. However, when I try to install php5-cgi I get an error stating "Package php5-cgi is not available,but is referred to by another package". I'm very new to pi and would like to have some guidance on this problem.

K Research
Posts: 13
Joined: Wed Jun 19, 2019 12:45 am

Re: How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Wed Jun 19, 2019 10:23 pm

Can someone label this as broken in the first post and in the header and or fix this whole how-to

Made it to step 2 get an error about not finding php5

Thanks

Andyroo
Posts: 3319
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: How-to: LLMP Stack + PhpBB + phpMyAdmin + h5ai

Wed Jun 19, 2019 10:28 pm

The article is years and two operating systems out of date..
(defaults: /var/www on Raspbian Wheezy, /var/www/html on Jessie.)
You've been zombied...

Just love the 'net - so much out of date info.
Need Pi spray - these things are breeding in my house...

Return to “Networking and servers”