You are here: Home > FAQ > LAMP configuration example


LAMP configuration example

Apache is the world's number one Web server, according to Netcraf ([url] [/ url]) survey made ??by more than fifty percent of the world's Web servers use Apache.
Especially now, the use of LAMP (Linux + Apache + MySQL + PHP) to build medium-level application is already a popular way, therefore, to grasp the Apache configuration is one of the essential skills of systems engineers.

Using the LAMP (Linux + Apache + MySQL + PHP) to build medium-level applications (especially e-commerce) has been a popular way because all is open source and free software, so the cost is very low. This section describes the build platform. When a platform, you can also use direct RPM package to install, but does not support the use of RPM packages on some systems, so we use the more common method: Direct to install from source.

Apache features:
1) can run on almost all computer platforms.
2) support for the latest HTTP / 1.1 protocol
3) simple and powerful file-based configuration (HTTPD.CONF)
4) supports the Common Gateway Interface (CGI)
5) supports virtual hosts.
6) support HTTP authentication.
7) integrated PERL.
8) integrated proxy server
9) can be monitored by the state WEB server browser, you can customize the log.
10) supports server-side include commands (SSI) .
11) to support security SOCKET Layer (SSL).
12) has the ability to track a user's session.
13) Support FASTCGI
14) Support JAVA SERVLETS.

Install Apache from source
generally, for most e-commerce sites, there will be online payment system. For safety reasons, on
to the payment system needs to be accessed using https protocol, SSL support is needed, therefore, in the open
before beginning to install apache software, first install OpenSSL.

To install OpenSSL as follows:
(a) To obtain the source code:
Create a directory to store software:
mkdir / root / Software (can be stored in any directory they want stored)
to the [url] / [/ url] download the source code package, put / root / software /.
This case is downloaded openssl-0.9.8.tar.gz
(2) Decompression software
tar -zxvf openssl-0.9.8.tar.gz
(3) Into the source directory:
cd openssl-0.9.8
(4) Configuration Compile options:
./config --prefix = / usr / local / openssl --shared
--shared meaning is to create a shared library file, if not, at compile time to generate only static library file.
(5) Compile:
make test # test
(6) Install
make install
will perform to copy the relevant files to the / usr / local / openssl corresponding directory.

If the system has been installed at the time, then installed openssl, you can use rpm -qf openssl rpm package installation directory to find the time to prepare to install apache call
if you want to upgrade the existing installation of the rpm package openssl so, follow these few steps:
A, rpm -e nodeps openssl (forcibly remove rpm package openssl, try not to make use remote login)
B, the / usr / include / openssl backup, and the / lib next two a point and soft connection delete
C, install openssl-0.9.8.tar.gz (steps as stated above) installation directory is / usr / local / openssl
D , manually modify lib libraries have flexible connections to prepare for ssh and other programs call
-s /usr/local/openssl/lib/ /lib/ LN
LN -s / usr / local / openssl / lib / /lib/
-s /usr/local/openssl/lib/ /lib/ LN
LN -s / usr / local / openssl / lib / /lib/
E, echo / usr / local / openssl / lib >> /etc/
F, ldconfig -v
G, / etc / init.d / sshd restart
H, Ssh -V check the version information

After installing OpenSSL, then you can install Apache up , steps to install Apache as follows:
(a) to obtain the source code
to create a directory to store software:
mkdir / root / Software  
to [url] [/ url] download the latest stable version of the source code, into / root / software.
This case is downloaded httpd-2.0.59.tar.bz2
(2) Unzip the package
tar -jxvf httpd-2.0.59.tar.bz2
cd httpd-2.0.59
(3) Configuring the Compile Options
Apache is modular servers, core server contains the most commonly used modules only, and extended functionality provided by other modules. During setup, you must specify the module needs to contain. Apache has a module list for future reference document, which the state is "Base" module will be included into the core server by default, if you do not contain a module (eg mod_userdir), you must explicitly disable it; other state modules (such as mod_expires), must also be enabled in order to include explicitly into the core server.
There are two ways to use Apache module methods, one is permanently included into the core; If the operating system supports Dynamic Shared Object (DSO), but also for autoconf detected, the module can also be dynamically compiled. Storage DSO module is independent of the core can be provided by using the run-time module configuration instructions mod_so include or exclude core. If the compiler contains any dynamic module, mod_so module will be automatically included into the core. If you want the core can be loaded DSO, without actually compile any dynamic modules, you need to explicitly specify --enable-so.

In our e-commerce website, under normal circumstances, all our core module function is enabled; addition, we also enable SSL encryption (mod_ssl); in order to make it easier for search engines included in our pages, dynamic pages need to be URL URL rewriting for static pages, you need mod_rewrite; future modules to be added dynamically without recompiling apache (eg add PHP support), you need to enable mod_so. Based on the above analysis, I compile option when configuring recommended the following options:
./configure --prefix = / usr / local / apache2 --with-SSL = / usr / local / openssl
--enable-SSL --enable -so --enable-rewrite --enable-mime-magic --enable-mem-cache