Gentoo - Installing PHP

In this article we’ll cover installing PHP and give an example set of USE flags to get started with.

This article assumes that you have completed the Slice Setup articles and the Installing Apache article.

PHP5 Install

First, let’s see what compile options and built in php libraries are available:

emerge php -vp

Remember, you can get more info on the USE flags with:

equery uses php

Update your USE flags to include the options and modules that you require. Personally, I chose the flags listed below, and added them all in one line in ‘/etc/portage/package.use’ like this:

dev-lang/php apache2 cgi ctype curl curlwrappers -doc exif fastbuild filter ftp 
hash inifile json mysql mysqli pdo pic posix sharedext sharedmem 
simplexml sockets spell truetype xml xmlreader xmlrpc xmlwriter xpm zip

I’ve word wrapped this example, but in the actual file, it’s important that it’s all on one line. If the file doesn’t exist, you can just create it.

In my flags I’ve included ‘mysql’ and ‘mysqli’; those will cause the install to depend on the mysql database server, and install that along with php. If you’re using postgresql, or another database you might want to use different USE flags.

Once you’re happy with the USE flags you’ll need, install it for real:

sudo emerge php

This took about 46 minutes for me. As usual, keep an eye on the output, and follow any advice or warnings it gives.

Don’t worry too much about getting the USE flags correct, you can always modify them and re-install later. Re-installing php on it’s own took 9 minutes for me.

Once done, restart Apache:

sudo /etc/init.d/apache2 restart


Before going any further, it is always a good idea to test your setup and make sure that everything you’ve already done is working as expected.

You can test that Apache and PHP are playing nicely together very easily by creating a simple php file with a call to the phpinfo method and then loading it in your web browser.

First create the file:

sudo nano /var/www/localhost/htdocs/test.php

Now add some basic HTML and a call to the phpinfo method to the file:

<title> PHP Test Script </title>
phpinfo( );

Great, now you should be able to load that script in your web browser using your Slice IP address:

If everything is installed properly, you should see a PHP generated page that displays all sorts of information about your PHP installation:

PHP Info Screen

Great! No need to worry about what all that means for now. We just wanted to verify that PHP was working.

Now that we know it is, go ahead and remove that test script, you don’t need the whole world knowing about your PHP installation.

sudo rm /var/www/localhost/htdocs/test.php

Almost Done

Well, it’s almost ready to use.

In the next article we’ll go through installing external PHP modules.

Article Comments: commented Thu Jul 10 21:23:10 UTC 2014:

Firstly, there chair mode activated are many ecommerce business owners did not concern themselves so much with web design. That's the perception And I think if you look in the kitchen, bedroom, dining, and conservatory.

Here is my page :: chair design,,

Ferienhaus Kanaren commented Mon Jul 14 00:23:44 UTC 2014:

Its like you read my thoughts! You seem to grasp a lot about this, like you wrote the book in it or something. I feel that you simply can do with some p.c.

to drive the message home a bit, but other than that, this is excellent blog. A fantastic read. I will certainly be back.

Jewell commented Wed Jul 16 21:35:15 UTC 2014:

I'm extremely impressed with your writing skills and also with the format on your weblog. Is that this a paid topic or did you customize it yourself? Anyway keep up the nice quality writing, it is rare to see a nice blog like this one these days.. commented Thu Jul 17 05:51:27 UTC 2014:

Older boys like them and your toddler boy wants to be as much in fashion as they do. They will still love and be proud of their little man they are making. You should always try to give the food to your baby that is best for him and organic food provides quality as well best food for your baby.

Venus factor reviews commented Mon Jul 21 15:54:01 UTC 2014:

This allows fruit flies to get in but usually keeps them from gwtting out, therefore breaking their breeding cycle and substantially reducing their number. You understand, the matter is that precisely why diets frequently fail is usually thaat theyre certainly not adjusted for you to each individuals physique, metabolism, and make-up.

If the 2 H is in P K Y, then the native will have dire vicissitudes.

custom wine glasses commented Sat Jul 26 01:49:23 UTC 2014:

Hey there! This is my first visit to your blog! We are a group of volunteers and starting a new project in a community in the same niche. Your blog provided us useful information to work on. You have done a outstanding job!

My web page; custom wine glasses

online loans for people on benefits commented Thu Jul 31 19:02:20 UTC 2014:

If you find anything at all you do not understand, do not signal. The loan originator will need you to definitely give reliable data which you have employment and should be able to include the debt.

plumber tools Waco Texas commented Fri Aug 15 22:31:50 UTC 2014:

I am actually thankful to the holder of this web page who has shared this fantastic piece of writing at at this place.

Feel free to visit my blog post plumber tools Waco Texas

sims 3 downloads free pc full Version commented Wed Aug 20 01:51:57 UTC 2014:

whoah this blog is fantastic i love reading your posts. Keep up the great work! You understand, lots of individuals are searching around for this information, you can help them greatly.

best carpet and upholstery cleaner Victoria BC commented Wed Aug 20 04:47:50 UTC 2014:

My family always say that I am killing my time here at web, but I know I am getting experience everyday by reading such good posts.

My website: best carpet and upholstery cleaner Victoria BC

t-mobile store in hoffman estates commented Wed Aug 20 20:18:49 UTC 2014:

I've learn several good stuff here. Certainly worth bookmarking for revisiting. I surprise how so much effort you put to create this kind of great informative web site.

white surround sound speakers commented Thu Aug 28 06:36:26 UTC 2014:

Spot on with this write-up, I actually feel this web site needs much more attention. I'll probably be back again to read more, thanks for the info!

my web-site - white surround sound speakers

wedding invitations commented Sat Aug 30 20:50:16 UTC 2014:

Please let me know if you're looking for a writer for your blog. You have some really great articles and I believe I would be a good asset. If you ever want to take some of the load off, I'd love to write some material for your blog in exchange for a link back to mine. Please send me an e-mail if interested. Thanks!

Here is my web site wedding invitations

Want to comment?

(not made public)


(use plain text or Markdown syntax)