This typo gave me some laugh.
httpd: Syntax error on line 559 of /usr/local/apache2.2.17/conf/httpd.conf: Expected </VirtualHost> but saw </Virtualbox>
This typo gave me some laugh.
httpd: Syntax error on line 559 of /usr/local/apache2.2.17/conf/httpd.conf: Expected </VirtualHost> but saw </Virtualbox>
This tutorial is a part of the “Setting up your local development environment” series. It is based on this article while keeping in mind that in previous apache tutorial we compiled apache from source. So I’m definitely not taking all the credit for it. But there are some modifications.
Starting with PHPFarm, we need Git installed in order to check it out. If you don’t have it installed:
Now create a directory in which PHP versions will reside. The directory of my liking is /usr/local/php, so I will use that. You can of course change that.
Clone the phpfarm repository.
Now we have to edit the configuration options which phpfarm will use to compile php.
We can use more general configuration options or very strict ones. Default configuration options.sh can be overridden by creating a file called custom-options.sh or a bit more specific like custom-options-5.2.sh or very strict like custom-options-5.3.9.sh. Since the configurations for 5.2 and 5.3 are different and I like to be a strict person, I will create two configurations:
custom-options-5.2.17.sh contents (these config values were also mentioned in previous tutorial):
custom-options-5.3.9.sh contents:
For PHP 5.3 we don’t need the cgi parameters, since these are already enabled by default.
On Ubuntu 11.04, the configuration might fail with error messages about libjpeg and/or libpng. What you can do is the following:
Install the libjpeg8-dev package. This will solve the libjpeg error message.
Create a symbolic link to the libpng.so in the /usr/lib directory. This will solve the libpng error message.
Next step – compiling PHP.
Where the number after the ./compile.sh is the PHP version you wish to compile.
Now that we have compiled PHP, we can move on to set up apache. If you followed the apache tutorial, first of we need to recompile it.
These are just my configuration options. The options you have to pay attention to for this topic are:
Apache should be up and running. Next stop – FastCGI module.
Download and extract the latest (current) source from http://www.fastcgi.com/dist/.
Next thing to do is rename Makefile.AP2 to Makefile, so we can compile it for apache 2.
Compile and install the module.
The top_dir parameter is optional. If you compiled apache to the more usual location like /usr/local/apache2, you do not need to set this option.
Now that we have mod_fastcgi module compiled, we can load it as a shared object. Add the following line to your httpd.conf:
If you had previously ran PHP as an apache module, you must disable it. You can only run PHP either as CGI or an apache module. So in httpd.conf, comment out this line:
Create a .conf file (you can call it what you want) – i.e. php-fcgi.conf and put the following content inside:
And include it in your main httpd.conf:
Now create a directory for CGI scripts.
And create scripts.
And put something like the following in. Just change the version of PHP.
These scripts should be executable. So we set permissions to 0755.
Now we configure apache virtualhosts. Each virtualhost will have it’s own subdomain and PHP version.
Do the same for all versions of PHP.
We are almost there. Since these subdomains (asumingly) do not exist yet, we must point them to your localhost IP.
Just add your subdomains after the localhost definition. It should look something like this:
Everything is set, so just restart the apache.
Put a file phpinfo.php in /var/www directory with the following line:
And test it. If everything went well, you should see different PHP versions on different subdomains.
Enjoy!
Post updated on February 1st, 2012th to reflect latest updates.
Last time we went through steps needed for setting up apache. Now we will set up PHP. I encourage you to read the article on multiple PHP versions, which takes use of PHPFarm that makes things a lot easier. Plus you get to have multiple PHP versions installed.
First few steps are practically the same as for the apache. Download the source and check md5.
Extract the archive.
Go into the extracted directory.
You don’t need all of these extras, they just might be useful to you. Some of the more important ones are:
You can read more about the configuration options in the PHP manual.
On Ubuntu 11.04, the configuration might fail with error messages about libjpeg and/or libpng. What you can do is the following:
Install the libjpeg8-dev package. This will solve the libjpeg error message.
Create a symbolic link to the libpng.so in the /usr/lib directory. This will solve the libpng error message.
If this error occures while doing “make”:
Just install the libltdl-dev package. Should be something similar for other linux distributions.
It is a good practice to run tests and report any possible bugs by running this command. It however is not mandatory to do it.
This might take a while. After tests are through, there might be a fail or two, so you can decide if you want to report those or not.
Let’s go on and install it. This command must be run as super user.
Now we have to copy the php.ini to the appropriate directory.
Next, we configure apache to handle our PHP scripts.
Find a line which starts with AddType and add this below.
Than in line which starts with DirectoryIndex add this.
Save the file and restart apache.
Go to your documents root directory. In previous tutorial we used /var/www directory for this.
In this directory create a file named test.php and put this in it:
Now go to http://localhost/test.php
If you see a lot of data about your PHP installation, you have succeeded.
Enjoy!
Post updated on February 1st, 2012 to reflect newest updates.
This is the first on in the series of tutorials on how to set up your local web development environment on linux (I’m using Ubuntu). It is targeting those people, who don’t know their way around linux, but don’t want to use generic packages. It’s more fun.
First, you go to the apache homepage. You download apache, check sha1, because it can get corrupted!
If a line is returned, the file is OK, we can proceed, else, return to step 1.
Extract the archive.
Move into the directory of the extracted archive.
Next, we have to configure apache, before we compile it.
If you get this error during the configuration:
This happened because we enabled all mods by default, one of which is the mod_deflate that uses the zlib library. You can simply install its headers on ubuntu.
The dependencies should pass.
Next one must be executed as super user.
Now, apache should be working. Let’s test it.
Go to: http://localhost
You should see a “It works!” on your screen.
But when we started apache, it threw out an error:
It’s time to configure it, so it won’t throw errors at us. You can use different text editor than gedit (vi, nano, mcedit … )
ServerAdmin → change it to your email, just for a clean configuration file.
Uncomment ServerName directive (remove # in front of it) and change www.example.com to localhost. With this, we got rid of that error from before.
DocumentRoot → change to directory in which you want to have your html, php etc. files.
<Directory “/usr/local/apache2/htdocs”> → change if you changed the DocumentRoot in the previous step.
Here we must change the line AllowOverride None to AlloweOverride All if we want mod_rewrite to function properly.
Check if the syntax of the configuration file is OK.
If everything is OK, restart apache.
You’re good to go!
Post updated on February 1st, 2012 to reflect latest apache version.