New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

PHP 5.4 on B3

Got problems with your B2 or B3? Share and get helped!
Post Reply
redw0001
Posts: 96
Joined: 07 Sep 2009, 14:03

PHP 5.4 on B3

Post by redw0001 »

Has anybody managed to compile PHP 5.4 on a B3? If so would you be prepared to share how or if you created a .deb share the file.

I need to install PHP 5.4 as it is a requirement for Opencloud 8. I ended up at https://www.howtoforge.com/building-php ... an-squeeze but get lots of Unable to locate package messages.

As far as I can see I have three choices:
1: compile PHP 5.4 on current B3s with Squeeze
2: move B3 to either Wheezy (or possibly the Gentoo or Arch build that have been done successfully by others.
3: move to a different (non ARM) platform.

I do want to go to Opencloud 8 so just sitting back and doing nothing doesn't work for me. I do not wamt tp do Option 3 due to cost and the fact that until now I've been very happy with my B3s.

Currently two B3s running with copying of data between the two (for backup). I'm happy to rebuild one totally, move everything across then repeat the process to get to install Opencloud 8. Keen not to go down a dead-end route however.

Any suggestions would be appreciated.
Ubi
Posts: 1549
Joined: 17 Jul 2007, 09:01

Re: PHP 5.4 on B3

Post by Ubi »

I think you mean OwnCloud 8 right?
sakaki
Posts: 172
Joined: 15 Aug 2014, 11:20

Re: PHP 5.4 on B3

Post by sakaki »

Assuming it is ownCloud you want, version 8 is in the archlinuxarm repository. As such, you could try writing my Arch Linux live USB image to a USB key and booting your B3 from that (it won't harm any existing Excito system on your B3's hard drive). Then, ssh in per the instructions, and:

Code: Select all

[root@archb3 ~] pacman -Sy
 (to update package metadata)
[root@archb3 ~] pacman -S owncloud
 (confirm when prompted)
Done! Arch is a binary distro so all this is pretty fast. You will then need to set up a web server, database etc. to your preferences per the standard Arch Linux wiki instructions. Start the httpd service and off you go. I've just got a simple system up and running on my B3 here with Arch, took about 30 minutes end to end.

Also, since there is persistence on the live USB, once you have a system running as you like it, you can then follow the instructions on the GitHub page to copy everything over to your B3's internal HDD (if you wish).

Alternatively, you could run Docker (also in the archlinuxarm repo) and download a prebuilt LAMP stack for ownCloud 8. Haven't tried that though. Or build your own version of ownCloud with the Gentoo live USB for B3. But the Arch live USB route is a fairly painless thing to try, as you don't have to compile anything.

Hope that helps,

sakaki
redw0001
Posts: 96
Joined: 07 Sep 2009, 14:03

Re: PHP 5.4 on B3

Post by redw0001 »

Yes, fundamental error on my part, read more haste = more embarrassment. Indeed Owncloud 8 is exactly what I meant.
redw0001
Posts: 96
Joined: 07 Sep 2009, 14:03

Re: PHP 5.4 on B3

Post by redw0001 »

Thanks Sakaki, will give that a shot over the weekend.

**Update: Bit short on time at weekend, however I did download the image, build the key, tailor wan and boot successfully. Thank you. I just need to sort easiest way to get LAMP stack and Owncloud working now.

Admittedly not much running but seems very responsive

Thanks again Sakaki for your Arch project and help**
sakaki
Posts: 172
Joined: 15 Aug 2014, 11:20

Re: PHP 5.4 on B3

Post by sakaki »

Hi -

I'm glad the Arch Linux live USB is working for you ^-^

However, I realized afterwards that my comment:
I've just got a simple [ownCloud] system up and running on my B3 here with Arch, took about 30 minutes end to end.
might not have been particularly helpful ><

So, here's a quick step by step guide to getting a simple OwnCloud 8 system up and running on your B3 under Arch. There's lots that could be done to improve it from a stability, security and performance perspective, but it should be enough to get you started.

OK, begin by downloading, configuring and booting the current Arch Linux live USB. I know you've already done this with the 1.0.0 release, but I would recommend you start from the newly released 1.1.2 version (available here), as this lets you update your kernel, as well as userspace packages, from archlinuxarm (which means you can keep everything on your B3 up to date going forward, without any further releases or updates from me).

Once your B3 is up, from a PC on the same subnet, log into it as root, via ssh, per the instructions (on the project's GitHub page).

OK. Now the first thing we need to do is a full system update (to avoid issues with 'partial upgrades'). Issue:

Code: Select all

[root@archb3 ~] pacman -Syu
  (confirm when prompted)
If this warns you that your kernel (linux-kirkwood-dt) has been upgraded, then when the process completes, power down your B3 (press and hold the rear button for 5 seconds, then wait for the light to go out), and then reboot from the live USB, so that you are running the newly updated kernel. Log in again via ssh. If your kernel didn't need to be updated, however, just keep going, there's no need to reboot.

Next, we'll load all the necessary packages (LAMP stack, owncloud etc.). I'm going to assume in the following that you want to use apache (2) as the web server, sqlite as the database, and that you need a self-signed certificate for HTTPS. Obviously, adapt as necessary (use this Arch Linux wiki page to guide you if you want to make changes). Issue:

Code: Select all

[root@archb3 ~] pacman -S owncloud php-intl php-mcrypt sqlite php-sqlite apache php-apache php-apcu
  (confirm when prompted)
Now we need to set up the various configuration files. First, php. Issue:

Code: Select all

[root@archb3 ~] nano -w /etc/php/php.ini
and uncomment (by removing the leading semicolon) the following lines in the file (leaving the other lines in the file unchanged):

Code: Select all

extension=bz2.so
extension=gd.so
extension=iconv.so
extension=intl.so
extension=mcrypt.so
zend_extension=opcache.so
extension=openssl.so
extension=pdo_sqlite.so
extension=sqlite3.so
extension=xmlrpc.so
extension=zip.so
Save and exit nano.

Next, ensure data caching is on. Issue:

Code: Select all

[root@archb3 ~] nano -w /etc/php/conf.d/apcu.ini
and uncomment the following line so it reads:

Code: Select all

extension=apcu.so
Save and exit nano.

Next, copy the provided baseline ownCloud 8 server configuration into place:

Code: Select all

[root@archb3 ~] cp /etc/webapps/owncloud/apache.example.conf /etc/httpd/conf/extra/owncloud.conf
Next, we'll want to modify this so that it can service https requests. Issue:

Code: Select all

[root@archb3 ~] nano -w /etc/httpd/conf/extra/owncloud.conf
and add the following lines to the end of the file:

Code: Select all

<VirtualHost 192.168.1.129:443>
    ServerName foofarm.com:443
    SSLEngine on
    SSLCertificateFile /etc/httpd/conf/server.crt
    SSLCertificateKeyFile /etc/httpd/conf/server.key
    ServerAdmin foo@foofarm.com
    DocumentRoot /usr/share/webapps/owncloud
    ErrorLog /var/log/httpd/owncloud.foo.info-error_log
    CustomLog /var/log/httpd/owncloud.foo.info-access_log common
</VirtualHost>
Obviously, if you have changed the wan (eth0) address of your B3 from 192.168.1.129, substitute this in the above.
Also, if you have a real name (for example, myserver.com), subsitute this for 'foofarm.com' (and you can also change the port 80 VirtualHost data above in the file too, if you like). If you are just testing locally, the above will work fine (provided only that the IP address is correct).
When done, save and exit nano.

We don't have a self-signed certificate yet for the site, so let's generate that now (per these Arch Linux notes). Issue:

Code: Select all

[root@archb3 ~] pushd /etc/httpd/conf
[root@archb3 conf] openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out server.key
[root@archb3 conf] chmod 600 server.key
[root@archb3 conf] openssl req -new -sha256 -key server.key -out server.csr
Here, you will be prompted to enter various fields. For a test system, it really doesn't matter what you put, but in a production system, you'd need to ensure at least that Common Name matches your domain name; also, be sure to just leave the challenge password blank when asked for it, or else your certificate won't be usable by apache. See e.g. these notes for more details.

With that done, continue as follows:

Code: Select all

[root@archb3 conf] openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
[root@archb3 conf] popd
Now we can set up apache's configuration file appropriately.
Issue:

Code: Select all

[root@archb3 ~] nano -w /etc/httpd/conf/httpd.conf
and uncomment the following lines (remove the leading #, in this case), so they read:

Code: Select all

LoadModule socache_shmcb_module modules/mod_socache_shmcb.socode
LoadModule ssl_module modules/mod_ssl.so
LoadModule rewrite_module modules/mod_rewrite.so
Include conf/extra/httpd-ssl.conf
Still in this file, deselect the 'mpm_event_module', by commenting out the relevant line so it reads:

Code: Select all

#LoadModule mpm_event_module modules/mod_mpm_event.so
then add the following line afterwards, so you now have:

Code: Select all

#LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
Finally, scroll down to the end of the file, and add the following lines:

Code: Select all

#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>

Include conf/extra/owncloud.conf
Include conf/extra/php5_module.conf
Leave the rest of the file as-is. Save and exit nano.

Nearly there! We next have to ensure that we have at least one of the locales that ownCloud requires. Issue:

Code: Select all

[root@archb3 ~] nano -w /etc/locale.gen
and uncomment the following line (remove the leading #), so it reads:

Code: Select all

en_US.UTF-8 UTF-8
Save and exit nano.
Then issue:

Code: Select all

[root@archb3 ~] locale-gen
Next, we need to make sure that ownCloud has appropriate access rights; issue:

Code: Select all

[root@archb3 ~] chown -R http:http /usr/share/webapps/owncloud/
And that's it, ready to try it out! Start apache:

Code: Select all

[root@archb3 ~] systemctl start httpd
If that completes without errors (it should), then on the PC on which you have ssh'd into your B3, open a web browser, and navigate to "https://192.168.1.129" (obviously, if you have used a different address for your B3's wan port, use that instead here). Your web browser will probably issue some sort of security warning at this point, stating the certificate does not match the address, is self-signed etc., which of course is true, as we just generated it with spurious data (of course, if you used a real certificate, rather than generating it, then you won't get any warnings). Allow your browser to continue to the site (you may need to add a security exception, if using Firefox - you'll be prompted to do this). Ensure that javascript is enabled in your web browser too, since ownCloud needs it.

OK, you should then get to an initial setup page visible in your browser, something like the below (incidentally, in case of problems with https, you can navigate to the unsecured page, "http://192.168.1.129", which should also work):
Image

You can (apparently) ignore the 'error' about 32-bit php: see this post for example.

Enter a username and password, and click on 'Finish setup'. ownCloud will do its stuff for a bit, and after that, you should be in:
Image
That's it. Obviously, in a production system, you'd want to set up a firewall, put the thing in a container or at least a chroot, take more care with your VirtualHosts etc etc. But hopefully this gives you the pointers you need to get started.

PS if you want your web server (and ownCloud) to come up automatically after a reboot, remember to issue:

Code: Select all

[root@archb3 ~] systemctl enable httpd
Also, if you get the system working as you like it on the live-USB, and want to install it to your hard drive, you can do so easily (simply follow these instructions on the GitHub page). All the configuration work you have done will be copied over to the HDD.

Finally, if you'd like to change your hostname, you can do so now. For example, to change it to "hana" (and reflect the change immediately), issue:

Code: Select all

[root@archb3 ~]# hostnamectl set-hostname hana
[root@archb3 ~]# exec bash --login
[root@hana ~]#
Best,

sakaki

PS I have verified that this works end-to-end on a fresh 1.1.2 live-USB image. It took 28 minutes (including the initial pacman -Syu) but ymmv, depending on your network speed etc.

Edited to reflect how to set hostname, as requested (this is also now in the live-USB's instructions on GitHub).
Last edited by sakaki on 08 Apr 2015, 12:12, edited 1 time in total.
redw0001
Posts: 96
Joined: 07 Sep 2009, 14:03

Re: PHP 5.4 on B3

Post by redw0001 »

Wow!

I timed out over Easter, however I'd got as far as starting Owncloud, but hit two problems:
1: 'Cannot write to apps directory'
2: 'need to set locale'

Your update contains the fixes for both. This is an awesome piece of work, thank you. I've decided to start from scratch again, recutting my USB image to my key.

Please allow me to suggest one minor update to your instructions, include how to change archb3 to a user chosen name. It only takes 30 seconds (probably 5 for you given how fast you appear to work). It is only minor but useful.

I'll update here once I've sorted this, probably tomorrow night now.
redw0001
Posts: 96
Joined: 07 Sep 2009, 14:03

Re: PHP 5.4 on B3

Post by redw0001 »

Up and running this evening. Logged on to Owncloud successfully. Instructions were spot-on thank you.

Now just down to me to swap HDD for SSD and move the USB key contents to the SSD. Once that is done and stable add the old HDD as external drive and move all contents from my 'production B3' across to the arch based B3.

After that I'll repeat the process so both B3s on arch.

Thanks for your help Sakaki.
Post Reply