Installing LAMP: Part 1
One of the most popular open source technology stacks is LAMP – Linux, Apache, MySQL, PHP. To sum it up in a very simplistic manner, this technology stack gives the ability for one to create a presence online (be it for internal or external purposes). This stack consists of the operating system, the web server, a database, and the server side language. This blog will focus on two different distributions of Linux, CentOS and Ubuntu. These two distros are general enough to cover both Debian based and RHEL based versions which make up the majority of Linux distributions. This blog will be broken into 2 parts to go over various installs of PHP (the primary focus). There are several ways to install Apache, MySQL, PHP and they serve different purposes.
Simplest to Manage
Utilizing the repositories provided by the OS (and even adding 3rd party repos), one can easily manage and maintain their environment as the OS provides the supported versions of these technologies, choosing which versions are stable (for the most part) and do extensive testing. For CentOS and Ubuntu, this would involve utilizing ‘yum’ and ‘apt-get’ respectively.
Manually Build and Configure
When one manually configures their environment, this involves a lot more details and one has to be mindful of all the interacting parts. However, this allows for more control and you can be specific in installing only what is needed which helps reduce the ‘weight’ of the software and potentially helps them run faster. You also have the advantage of the latest versions that may provide important enhancements. As of writing this, the current version of PHP is 5.4.5. The 5.4 branch is reported to be up to 20% faster than the 5.3 branch (this is the branch currently supported by CentOS and Ubuntu).
The following is part 1 of a 2 part series that will go over these various installations of Apache, MySQL, and PHP. The current versions of CentOS and Ubuntu are 6.2 and 12.04 and those will be assumed. I will also include some 3rd party repositories that will help you install the latest versions of PHP if you so choose.
1. Change to Root
2. Add Repositories
Note – If you want to keep the versions that are provided with the OS, then skip this step.
rpm - Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Check and Confirm Repo
Should list PHP 5.4.5
5.4.5 is still very new and this package contains 5.4.4.
3. Install Base (Apache, PHP, MySQL)
More info on php-common package can be found here:
Note: remove ‘
--enablerepo=remi,remi-test‘ from all steps if you dont want the 3rd party packages.
4. Install Addons
There are many packages available to add on, and this is something you should look into and understand your needs. The packages I added are the php to mysql connector; apc which is a caching tool to help increase the speed; pear is an extension library for php. The only one really needed is php-mysql.
Once again, the php-apc is only to show the ability to add other php modules. The previous 3 are needed for the LAMP environment.
5. Configure MySQL
The steps are pretty straightforward. If this is a production server, I would recommend adding a password for root, remove the test database, and flush privleges.
6. Start Apache
7. Hello World
Go to your document root (should be /var/www/html for CentOS and /var/www for Ubuntu) using your text editor of choice to create info.php.
Add the following text:
After saving the file, go to the page in your browser - domain name or ip address
This should show the php info page and you're done!
This concludes the basic installs for both CentOS 6.2 and Ubuntu 12.04. If you understand APC or have some basic knowledge of it, you will want to increase the size of apc.shm_size (I usually set it to at least 64M). Also, it is a good idea to find the apc.php file in your server and cp it to your document root, so you can access all the details through the web http://ipaddress_or_domainname.com/apc.php (depending on how you set it up) regarding your APC cache. In the next part, I will go over a more advanced install building from source. Stay tuned!
Mohammad Saleh is a software engineer at AMD. His postings are his own opinions and may not represent AMDs positions, strategies or opinions. Links to third party sites, and references to third party trademarks, are provided for convenience and illustrative purposes only. Unless explicitly stated, AMD is not responsible for the contents of such links, and no third party endorsement of AMD or any of its products is implied.