Showing posts with label Tuts. Show all posts
Showing posts with label Tuts. Show all posts

Saturday, 23 April 2016

Install MySQL Server on your Raspberry Pi

I’m writing this article following a number of requests, and a bit of a follow-up to a previous tutorial “Turn your Raspberry Pi 3 into a PHP 7 powered web server“. This tutorial will guide you through steps to install MySQL Server on your Raspberry Pi.

A bit of a word of warning

As mentioned in my replies to a few comments, I don’t recommend running MySQL Server on a Raspberry Pi unless you have a high-quality, high-speed USB flash drive (preferably) or a UHS1/UHS3 class MicroSd card from which you run Raspbian OS. You might want to look at a previous tutorial to learn how to run your Raspberry Pi from a USB Flash drive.

Step 1 – Install MySQL Server

The first thing to do before anything is to ensure that all updates and upgrades are installed. Run the following command:

sudo apt-get update && sudo apt-get upgrade

Once all the updates are installed, we’re ready to install MySQL server. Start by running the following command:

sudo apt-get install mysql-server && sudo apt-get install mysql-client

This will install the client as well as the server. The client will allow you to connect to your server from the command line which is always handy to do. After a short while, you will see this screen during the installation:

Install MySQL Server on your Raspberry Pi

Go ahead and provide a root password. The root account is the default administration account that allows full control of the locally installed server. You’ll be prompted to repeat this to confirm. Go ahead and type your password again. The installation will finish shortly after.

Step 2 – Connecting to your MySQL server locally

Now we’ve installed MySQL server, we will try connecting to it using the MySQL client we installed at the same time as the server. Type the following command:

mysql -uroot -p

You’ll be prompted for your password again to connect to your MySQL server installation. Congratulations, you’re logged in. You should see something like this:

Install MySQL on Raspbian

Type this command:

status;

This will give you a summary. It should look a little like this:

MySQL on Raspbian OS

This gives us a summary of MySQL Server running on your Raspberry Pi.

Conclusion

We’ve installed MySQL Server and if you’ve followed my previous tutorial to install Apache and PHP 7, you’re ready to start serving a PHP application like WordPress.

I’ll follow-up with another tutorial on installing WordPress in due time.

 

The post Install MySQL Server on your Raspberry Pi appeared first on Ste Wright the Web Developer.



from Tutorials – Ste Wright the Web Developer http://ift.tt/1U9gPG7
via http://ift.tt/1U9gPG7

Tuesday, 22 March 2016

Turn your Raspberry Pi 3 into a PHP 7 powered web server

In this tutorial I’m going to go through the steps to install Apache2 and PHP 7.0 on your Raspberry Pi 3, to create the ultimate low-powered, super quick web server.

Prerequisites

I’m going to assume that you have Raspbian installed on your Raspberry Pi 3. For the best results, I recommend running Raspbian from a USB Flash drive rather than a MicroSD card. See my tutorial on how to do this.

Update

These instructions should work fine on the Raspberry Pi 2 as well. Let me know if anyone tries this.

Step 1 – Add new repository sources

At the time of writing, PHP 7.0 hasn’t yet made the official repository sources, so we need to add one which provides us with the PHP 7.0 packages. Edit your sources file with this command:

sudo nano /etc/apt/sources.list

Below the existing entries in the file on a blank line, add the following two lines:

deb http://ift.tt/1o5dLx6 jessie-backports main contrib non-free
#deb-src http://ift.tt/1o5dLx6 jessie-backports main contrib non-free

Your file should look a little like this:

Install Apache 2 and PHP 7 on Raspberry Pi 3

Next we need to add a couple of certificates in order to allow us to use the sources with apt-get. Run the following two commands:

sudo gpg --keyserver pgpkeys.mit.edu --recv-key CCD91D6111A06851
sudo gpg --armor --export CCD91D6111A06851 | apt-key add -

And finally we need to update the package list by running:

sudo apt-get update

Step 2 – Install the core Apache2 and PHP 7 packages

We’re ready to install Apache2 and PHP7, along with some common packages that we may need for most web applications such as Symfony2, WordPress, Drupal etc. Run the following command to install these packages:

apt-get install apache2 php7.0 php7.0-curl php7.0-gd php7.0-imap php7.0-json php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-xmlrpc libapache2-mod-php7.0

This may take a little time, but as soon as we’re done, we are essentially finished.

Step 3 – Test Apache2 and PHP 7

Assuming all went well, we’re ready to test to see if everything went OK with the installation. First we’ll test the version of PHP that CLI is using:

php -v

You should see something like this:

Install PHP 7 on Raspbian

Next we’ll test two things; Apache2 and PHP 7. In your web browser, visit the IP address of your Raspberry Pi. If you haven’t used ssh and have followed these steps on your Raspberry Pi 3 itself, just visit http://127.0.0.1, otherwise change 127.0.0.1 for the IP address of your Raspberry Pi.

You should see the default Debian holding page:

Turn Raspberry Pi into a web server

Next we’ll test PHP. Run the following command to create a test file:

echo "<?php phpinfo();" >> /var/www/html/phpinfo.php

Yet again, visit the IP address of your Raspberry Pi, this time adding /phpinfo.php to the URL. You should see the PHP Information as shown below:

Install PHP 7 on Raspberry Pi

Conclusion

The Raspberry Pi 3 is a very capable, low power consuming little piece of kit. Combine that with the awesome power and speed of PHP 7.0 and you have a low energy web server that’s lightning quick and ideal for blogging from. As mentioned in the prerequisites, I do recommend using a decent USB Flash drive instead of an MicroSD card to run the operating system.

My first experiments with WordPress on PHP 7 on a Raspberry Pi 3 were very promising. I’m probably going to switch back to hosting this site from one again, now that the equipment and software can keep up with the traffic to the site.

Any questions or feedback, feel free to add below. Let me know about your own projects too and I’ll share them.

The post Turn your Raspberry Pi 3 into a PHP 7 powered web server appeared first on Ste Wright the Web Developer.



from Tutorials – Ste Wright the Web Developer http://ift.tt/1Pq9CKf
via http://ift.tt/1Pq9CKf

Sunday, 20 March 2016

Upgrade to PHP 7.0 on Ubuntu

I took the plunge and upgraded to PHP 7.0 on Ubuntu 14.04 and so far so good, everything’s lightning fast, and touch wood, nothing seems to be broken. Here’s the steps I took to upgrade.

Prerequisites and disclaimer

My server is a Ubuntu 14.04 box that uses Apache 2.4 and PHP 5.5.9 prior to upgrade. These instructions are for Apache 2.4 users with a similar configuration, and I recommend you test in isolation before using in a production environment. Proceed at your own risk.

Step 1 – Add a new Apt source

At the time of writing, I’m using the packages maintained by a guy called Ondřej Surý (he’s worth a follow on Twitter) until there’s a Debian package for PHP 7 in the official release channels.

To do this, enter the following command into the box you’re upgrading:

sudo add-apt-repository ppa:ondrej/php

You’ll probably be prompted to enter your password at this point. Go ahead and enter it.

Step 2 – Install updates and the PHP 7.0 package

Next we’re going to update and upgrade packages on our system to ensure everything goes smoothly. You can do this in a single command with:

sudo apt-get update && sudo apt-get upgrade

Once this has finished, we’re ready to install PHP 7.0. Enter the following command into your terminal:

sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0

This will install PHP 7.0, the MySQL DB package for PHP 7.0 and the Apache PHP7 module. I found that everything else pretty much worked without being installed separately. That’s it pretty much. You shouldn’t need to make any configuration changes and everything should just work.

Step 3 – Test to ensure your server is using PHP 7.0

From the command line, type the following command:

php -v

You should see something line this:

Upgrade to PHP 7.0 on Ubuntu

Congratulations, your command line at least is using PHP 7.0.

Now we need to ensure Apache is using the right version of PHP. Change directory to any of your sites (or if you have just one on your server, this will probably be /var/www/):

cd /var/www/

Amend the path to suit. Now we’re going to create a test file to see the information about our PHP environment. Type this command to create the file:

echo "<?php phpinfo();" >> phpinfo.php

Visit the page from your browser, hopefully you’ll see something like this:

Install PHP 7 on Ubuntu

Conclusion

PHP 7 is a complete overhaul and from my own experience, it’s rock solid and incredibly quick. It will speed up your applications and serve data to your web servers quicker than ever, whether it be Nginx or Apache. It’s bundled in the next LTS of Ubuntu which is due anytime now, I can see PHP 7 being huge.

Any feedback, comments or questions, feel free to comment away.

The post Upgrade to PHP 7.0 on Ubuntu appeared first on Ste Wright the Web Developer.



from Tutorials – Ste Wright the Web Developer http://ift.tt/25cXk3u
via http://ift.tt/25cXk3u

Thursday, 13 August 2015

Tutorial – Install Apache and PHP on a Raspberry Pi 2

I’ve been running LAMP setups on Raspberry Pi’s for years, so am excited to use the little pocket-sized powerhouse that is the Raspberry Pi 2 as a web server. This is the first in...

from RaspiPress » Tutorials http://ift.tt/1MqzBW8
via http://ift.tt/1MqzBW8

Amazon

Donate

Donate Towards More Raspberry PI's for Projects