WEB Server Apache Compilation Guide and advanced skills

Source: Internet
Author: User
Article Title: WEB server Apache Compilation Guide and advanced skills. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   I purpose of this article
This article describes how to compile Apache, OpenSSL, ModSSL, MM, Mod_Perl, PHP, Zend, MySQL, and Oracle Support and possible problems, and some common techniques for accelerating compilation and improving work efficiency.
  
   2. Work Environment
Redhat Linux OS 6.x/ 7.x
  
   Three compilation processes
1. Required Software
  
MM 1.1.3 http://www.engelschall.com/sw/mm/
OpenSSL 0.9.6d www.openssl.org
ModSSL 2.8.10 _ 1.3.26 www.modssl.org
Apache 1.3.26 www.apache.org
MySQL 3.23.51 www.mysql.com
PHP 4.2.1/3.0.18 www.php.net
Zend Optimizer 1.3.1 https://www.zend.com/store/freeware.php
Mod_Perl 1.27 http://perl.apache.org/dist/
Oracle 8.1.7 www.oracle.com
  
2. Start Compilation
  
A. Compile MM first (optional)
  
Cd./mm-1.1.3
./Configure -- prefix =/usr/local/mm (separate directories are easy to differentiate)
Make
Make test
Make install
  
B. Compile OpenSSL (http: Optional https: required)
  
Cd./openssl-0.9.6d
./Config no-threads-fPIC
Make
Make test
Make install
  
Note: no-threads does not support multithreading, because Apache 1.3.x does not support multithreading.
  
C. Compile Mod_SSL (http: Optional https: required)
  
Cd mod_ssl-2.8.10-1.3.26
./Configure -- with-apache = ../apache_1.3.26
  
D. Compile Apache
  
D1 maximum sub-process restriction patching (optional)
  
Cd ../apache_1.3.26
Vi src/include/httpd. h
Change value 256 to 1024 or above
  
D2 (optional) Preparations for later PHP with Oracle Support)
  
If you want to compile PHP with Oracle Support, You need to modify the Apache compilation file configure and add the following line LIBS =-lpthread in
For var in cflags ldflags libs includes deps; do
As shown in the following figure.
  
LIBS =-lpthread
For var in cflags ldflags libs includes deps; do
  
Note: If you forget to add LIBS =-lpthread, you can
# Cd/usr/src/apache_1.3.26
# Make clean
# LIBS =-lpthread./config. status
# Make
# Make install
  
D3 compiling Apache
  
EAPI_MM = ../mm-1.1.3 SSL_BASE = ../openssl-0.9.6d./configure
-- Prefix =/usr/local/apache_ssl -- enable-module = most -- enable-shared = max -- enable-module = rewrite -- enable-shared = rewrite -- enable-module = proxy -- enable-shared = proxy -- enable-module = ssl -- enable-shared = ssl
Make
Make certificate (TYPE = test by default)
Make install
Strip/usr/local/apache_ssl/bin /*
  
Note:
D3.1 if you only want to test SSL, use the above command, because the default is to test.
D3.2 if you upgrade the running SSL site, you can make certificate TYPE = dummy, and finally copy the ssl. crt/server. crt and
Ssl. key/server. key.
D3.3 before make install, run the ldd src/httpd command to check whether libpthread is output to check whether enable LIBS =-lpthread exists.
D3.4 strip all apache executable files include httpd to save memory space.
  
E. Compile MySQL
  
Shell> groupadd mysql
Shell> useradd-g mysql
Shell> cd/usr/local
Shell> gunzip </path/to/mysql-VERSION-OS.tar.gz | tar xvf-
Shell> ln-s full-path-to-mysql-VERSION-OS mysql
Shell> cd mysql
Shell> scripts/mysql_install_db
Shell> chown-R root.
Shell> chown-R mysql data
Shell> chgrp-R mysql.
Shell> bin/safe_mysqld -- user = mysql &
  
Shutdown MySQL: cd/usr/local/mysql; bin/mysqladmin shutdown
  
F compile PHP
  
. /Configure -- with-apxs =/usr/local/apache_ssl/bin/apxs -- with-mysql =/usr/local/mysql -- with-zlib -- disable-debug -- enable-track -vars -- with-xml -- with-gdbm -- enable-sysvsem -- enable-sysvshm -- with-openssl =/usr/local/ssl -- with-mm =/usr/local/mm -- enable-ftp
  
If you need Oracle support, plus -- with-oracle =/home/oracle/oracle8 -- with-oci8 =/home/oracle/oracle8 -- enable-sigchild (assuming that the Oracle home Directory is/home/oracle/oracle8)
  
Make
Make install
Cp php. ini-dist/usr/local/apache_ssl/conf/php. ini
Add the following parts to/usr/local/apache_ssl/conf/httpd. conf.
  
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps
  
Add the following parts to/usr/local/apache_ssl/bin/apachectl
  
PHPRC =/usr/local/apache_ssl/conf
Export PHPRC
LD_LIBRARY_PATH = $ ORACLE_HOME/lib
Export LD_LIBRARY
  
If the LD_LIBRARY section above is not added, When you compile PHP with Oracle Support, you may get the following error message when starting Apache: libclntsh. so.8.0: not found
  
If you still have oracle problems, you may need to put all the Oracle environment variables into apachectl, as shown in the following example:
  
./Etc/profile
TWO_TASK = asdbs; export TWO_TASK
ORACLE_HOME =/home/oracle/oracle8; export ORACLE_HOME
ORACLE_BASE =/home/oracle; export ORACLE_BASE
LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: $ ORACLE_HOME/lib:/usr/local/lib:/usr/lib; export LD_LIBRARY_PATH
Ulimit unlimited
Ulimit-n 32768
Umask 002
PATH = $ ORACLE_HOME/bin:/usr/local/bin:/usr/bin; export PATH
  
G install Zend Optimizer
  
# Cd/usr/local/apache_ssl/libexec
# Cp/path/to/ZendOptimizer-1.1.0-PHP_4.0.5-Linux_glibc21-i386/ZendOptimizer. so.
  
Add the following parts to/usr/local/apache_ssl/conf/php. ini.
  
Zend_optimizer.optimization_level = 15
Zend_extension = "/usr/local/apache/libexec/ZendOptimizer. so"
  
H compile Mod_Perl
  
# Cd mod_perl-1.27
# Perl Makefile. PL USE_APXS = 1 WITH_APXS =/usr/local/apache_ssl/bin/apxs EVERYTHING = 1
# Make
# Make test
# Make install
# Mkdir/usr/local/apache_ssl/perl
  
Add the following single line to/usr/local/apache_ssl/conf/httpd. conf
Include conf/mod_perl.conf
The content of mod_perl.conf is as follows:
-------------------------------
# Typical for plain cgi scripts:
ScriptAlias/cgi-bin // usr/local/apache_ssl/perl/
# Typical for Apache: Registry scripts:
Alias/perl // usr/local/apache_ssl/perl/
# Typical for Apache: PerlRun scripts:
Alias/cgi-perl // usr/local/apache_ssl/perl/
  
PerlModule Apache: Registry
  
SetHandler perl-script
PerlHandler Apache: Registry
Options + ExecCGI
PerlSendHeader On
Allow from all
  
-------------------------------
Note: Common perl script problems.
  
How to write a Perl script?
  
A. standard perl script
#! /Usr/bin/perl
Print "Content-Type: text/html \ n ";
  
B. CGI perl script
Use strict;
Use CGI qw (: all );
Print header;
  
B. print "Location: URL"; and print header; problem?
When you use the print "Location: URL" function, you cannot have any print header; the statement is before print "Location: URL.
  
Use strict;
Use CGI qw (: all );
  
Print "Location: http://www.linuxforum.net ";
  
Print header;
Print "This is a testing html page \ n ";
  
Otherwise print "Location: http://www.linuxforum.net"; will not work.
Use strict;
Use CGI qw (: all );
Print header;
Print "Location: http://www.linuxforum.net ";
  
  
I. Modify the module location in the Apache configuration file.
  
When you compile SSL before compiling PHP and Mod_Perl, the PHP and Mod_Perl modules are included in Ifdefine SSL, that is, PHP and Mod_Perl are loaded only when SSL is started, let's modify it as follows:
  
LoadModule php4_module libexec/libphp4.so
LoadModule perl_module libexec/libperl. so
  
LoadModule ssl_module libexec/libssl. so
  
  
AddModule mod_php4.c
AddModule mod_perl.c
  
AddModule mod_ssl.c
  
  
J. Configure and start Apache
  
#/Usr/local/apache_ssl/bin/apachectl start
#/Usr/local/apache_ssl/bin/apachectl st

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.