Compile and install LAMP to implement PHP as a module and FastCGI separation-php Tutorial

Source: Internet
Author: User
Tags openssl library perl regular expression zts
Compile and install the LAMP source code package to implement PHP as a module and FastCGI separation:

Httpd-2.4.9 Apache2.4.9 compile the installation package
Apr-1.5.1 Apache Portable Runtime Library
Apr-util-1.5.3 Apache runtime tool
Php-5.5.30 PHP source package
Mysql-5.5.47 General binary edition (Generic)


I. compile LAMP as a module in PHP:

Note:

1. because PHP is an Apache module, it is necessary to compile PHP after httpd.

2. the -- enable-maintainer-zts option is used during compilation to support the MPM of apache worker or event.

3. PHP connection to the MySQL database requires the development component support of the mysql client. However, if PHP5.3 or later is used, you can specify mysqlnd to connect to the MySQL database, in this way, you do not need to install MySQL or MySQL development kit on the local machine. Mysqlnd is available from php 5.3 and can be bound to it during compilation (instead of binding to a specific MySQL client library), but it is set by default since PHP 5.4.

#./Configure -- with-mysql = mysqlnd -- with-pdo-mysql = mysqlnd -- with-mysqli = mysqlnd

1. compile apr-1.5.1:

[Root @ localhost ~] # Yum install-y pcre-devel # install the perl regular expression dependency package [root @ localhost ~] # Cd lamp/[root @ localhost lamp] # tar xf apr-1.5.1.tar.gz [root @ localhost lamp] # cd apr-1.5.1 [root @ localhost apr-1.5.1] #. /configure -- prefix =/usr/local/apr & make install

2. compile apr-util-1.5.3:

[root@localhost lamp]# tar xf apr-util-1.5.3.tar.bz2 [root@localhost lamp]# cd apr-util-1.5.3[root@localhost apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ && make && make install

3. compile httpd-2.4.9:

[Root @ localhost lamp] # tar xf httpd-2.4.9.tar.gz [root @ localhost lamp] # cd httpd-2.4.9 [root @ localhost httpd-2.4.9] #. /configure -- prefix =/usr/local/httpd-2.4.9 \ # specify the installation directory> -- sysconfdir =/etc/httpd \ # configure File Directory> -- enable-modules = most \ # compile most common modules> -- enable-MoD-shared = most \ # compile common modules into dynamic modules, shared> -- enable-so \ # enable Apache to support dynamic loading modules> -- enable-ssl \ # support ssl> -- enable-mpms-shared = all \ # Add all supported MPM modules compile as a dynamic module> -- wi Th-apr =/usr/local/apr \ # specify the location of apr> -- with-apr-util =/usr/local/apr-util \ # specify the location of apr-util> -- with-mpm = event \ # specify the default MPM as event> -- enable-proxy \ # enable proxy module> -- enable-proxy-fcgi \ # enable the fcgi module, enable -- enable-proxy option> -- enable-deflate \ # compression supported> make & make install # installation ############# installation complete after, you also need to configure the runtime environment ################ [root @ localhost ~] # Ln-sv/usr/local/httpd-2.4.9/usr/local/httpd # link the directory to httpd for later upgrade [root @ localhost ~] # Vim/etc/profile. d/httpd. sh # provide command search path 1. add a row: export PATH =/usr/local/httpd/bin: $ PATH [root @ localhost ~] # Ln-sv/usr/local/httpd/include // usr/include/httpd # link the header file to the system's default search location: /usr/include '/usr/include/httpd'-> '/usr/local/httpd/include/' [root @ localhost ~] # Vim/etc/man. config # Edit man document directory 1. add a line: MANPATH/usr/local/httpd/man


4. decompress mysql:

[Root @ localhost lamp] # tar xf mysql-5.5.47-linux2.6-x86_64.tar.gz-C/usr/local/############## after the installation is complete, you also need to configure the runtime environment ################ [root @ localhost lamp] # ln-sv/usr/local/mysql-5.5.47-linux2.6-x86_64/ /usr/local/mysql # link the mysql-5.5.47 directory to mysql '/usr/local/mysql'->'/usr/local/mysql-5.5.47-linux2.6-x86_64/'[root @ localhost lamp] # vim /etc/profile. d/mysql. sh # provide command search path 1. add a row: export PATH =/usr/local/mysql/bin: $ PATH [root @ localhost lamp] # ln-sv/usr/local/mysql/include // usr/include/mysql # Link header file '/usr/include/mysql/include' -> '/usr/local/mysql/include/' [root @ localhost lamp] # vim/etc/ld. so. conf. d/mysql. conf # Library File 1. add a line:/usr/local/mysql/lib [root @ localhost lamp] # ldconfig # reread the library file

5. compile php-5.5.30:

[Root @ localhost lamp] # yum install-y openssl-devel bzip2-devel libmcrypt-devel [root @ localhost lamp] # cd php-5.5.30 [root @ localhost php-5.5.30]. /configure -- prefix =/usr/local/php-5.5.30 \ # specify the installation directory> -- with-mysql =/usr/local/mysql \ # specify the MySQL installation directory> -- with-openssl \ # Use the openssl library, you need to install the openssl-devel package> -- with-mysqli =/usr/local/mysql/bin/mysql_config \ # specify mysql_config> -- enable-mbstring \ # enable multi-string Support> -- -freetype-dir \> -- with-jpeg-dir \ # supports jpeg> -- with-png-dir \ # supports png> -- with-zlib \ # specifies zlib> --- libxml-dir =/usr \ # specify libxml Library> -- enable-xml \ # enable xml> -- enable-sockets \ # enable socket mode Support> -- with-apxs2 =/usr/local/ apache/bin/apxs \ # apxs is the Apache module support Library, to compile it as an Apache module, you must specify the encryption library based on apxs> -- with-mcrypt, libmcrypt-devel package> -- with-config-file-path =/etc \ # specify the directory where the configuration file is located> -- with-config-file-scan-dir =/etc/php. d \ # specify additional Directory> -- with-bz2 \ # specify bz2 compression library, need bzip2-devel> -- enable-maintainer-zts # support apache worker or event these two MPM ############## after installation is complete, you also need to configure the runtime environment ################ [root @ localhost lamp] # ln-sv/usr/local/php-5.5.30/ /usr/local/php '/usr/local/php'->'/usr/local/php-5.5.30/[root @ localhost lamp] # ln-sv/usr/local/php-5.5.30 /include // usr/include/php'/usr/include/php'-> '/usr/local/php-5.5.30/include/' [root @ localhost lamp] # vim/etc /profile. d/php. sh 1. add a row: export PATH =/usr/local/php/bin: $ PATH [root @ localhost lamp] # vim/etc/ld. so. conf. d/php. conf 1. add a row:/usr/local/php/lib


7. configure httpd:

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.