- IT Inventory and Resource Management with OCS Inventory NG 1.02
- Barzan
- 924字
- 2025-02-18 05:23:08
Installing Apache, MySQL, and PHP/Perl on Linux systems
We want to install Apache, MySQL, and PHP/PERL (also known as AMP solution stack) on our Linux system as our OCS-NG inventory is going to run on top of these. Apache is the web server daemon, and it's going to provide a web-based user interface for us too. MySQL will serve database requests, and it's the heart of the inventory after all. In order to provide dynamic content, we also need PHP and Perl interpreters.
After having learnt how to use package managers of various Linux distributions, let's put our knowledge to some practical use. We will focus on yum, then APT, and finally emerge.
Installing the AMP stack with yum
First things first, we can install all packages with one simple command line as follows:
# yum -y install httpd php mysql mysql-server php-mysql
Now that we have these basic packages installed, we can check whether there are updates available for them by using the yum check-update httpd
command In order to find out which version we installed, we can type the following command:
rpm -qa | grep -i httpd

Then, if an update is available, we can simply type yum update httpd
to update the package. This command can be applied to every package. Here httpd
was used for exemplification.
When we're trying to get all of the necessary packages with that one-liner yum
command, what happens if our Linux distribution already comes with some of these packages installed? Well, the yum
utility is fairly smart and can decide if there's a higher version for some of them. It also checks and resolves the dependencies.
We can update each package manually with the yum update packagename
, but it is a bit pointless to do it that way. Instead, we just command the installation of those packages, and the installer figures out if they are already on the machine and what to do in that situation.
Check out the next screenshot. Some packages are updates while others are already up-to-date.

The previous screenshot shows only one-third of the process. The entire downloading, updating, and cleanup processes are skipped. What matters is that it handles updates seamlessly. Each action is verbosely logged. It should not require user interaction.
You can check the version of MySQL installed by using the following command:
# mysql -V mysql Ver 14.14 Distrib 5.1.42, for redhat-linux-gnu (i386) using readline 5.1

We need to add them as services so that they start automatically with the operating system:
# chkconfig httpd on # chkconfig mysqld on
Let's manually start the services now, as we don't want to reboot.
# service httpd start Starting httpd: [ OK ] # service mysqld start Starting MySQL: [ OK ]
Now, we need to specify the MySQL root password. Here's how to do this:
# mysqladmin -u root password 'password-goes-here'
Do not ignore the simple quotes, as the password goes inside those apostrophe marks.
As a rule of thumb, it is recommended to execute the mysql_secure_installation
shell script. This bash script is shipped with MySQL packages, and it performs the following initial security configurations:
- Changes root password, if applicable. We did that earlier.
- Removes the anonymous user access.
- Disables root login from remote access (only allowed from 'localhost').
- Removes the default sample database.
Installing AMP stack with apt
First, we will install the Apache2 web server daemon using the following command:
# apt-get install apache2
Next, we will install the rest of PHP 5 packages using the following command:
# apt-get php5 libapache2-mod-php5 php5-cli php5-common php5-cgi php5-gd
MySQL related packages are then installed using the following command:
# apt-get install mysql-client mysql-common mysql-server php5-mysql
Once they are installed, we recommend running the mysql_secure_installation
shell script here too. If you decide not to run it, then at least don't forget to set the root password.
Installing AMP stack with emerge on Gentoo
Here's how we install Amp stack under Gentoo with Emerge:
First we add Apache2 and MySQL to the USE flag in /etc/make.conf:
# emacs -nw /etc/make.conf
Now we execute the emerge
utility:
# emerge -av apache # emerge -av mysql # emerge -av php # emerge -av mod_perl
Let's add them as services to start on each restart:
# rc-update add apache2 default # rc-update add mysql default
We need to enable PHP 5 in our Apache2 config
file:
# nano -w /etc/conf.d/apache2 at the end of "APACHE2_OPTS=" line add "-D PHP5"
Working with Gentoo Linux sometimes requires patience. Generally, if one runs a distro like Gentoo, some sort of experience with that environment is assumed. Thus, should you struggle getting an AMP stack set up together, don't hesitate to research for information. There are step-by-step guides available that are dedicated to that topic.
Installing the AMP stack with an XAMPP precompiled package
XAMPP is an open source project that contains an Apache distribution containing other critical web server elements such as MySQL server, PHP, and Perl. It also installs some good-to-have applications such as PhpMyAdmin, ProFTPd ( FTP server). The installation requires downloading, extracting, and installing. The script is automated.
For more information, please visit the project's official web page at:
http://www.apachefriends.org/en/xampp-linux.html
You can download XAMPP from the previously mentioned site as well. It comes with installation instructions.