LAMP source code compilation installation (Apache MySQL5.5.21 PHP5.3.10)

Source: Internet
Author: User
Tags chmod curl gettext install php install openssl mcrypt openssl openssl version


One: Install dependent components

First yum install the basic dependent components:

Yum install make apr* autoconf automake gcc gcc-c++ zlib-devel OpenSSL openssl-devel pcre-devel gd kernel keyutils patch P Erl kernel-headers compat* MPFR cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libse Pol-devel libselinux-devel krb5-devel zlib-devel libxpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* Lib XML2 libxml2-devel Patch--disable-fileinfo

(the basic components are well after the Yum installation, the following compile and install to install the latest version of the components)

1: Install Zlib

Zlib Official website: http://zlib.net


wget http://zlib.net/zlib-1.2.8.tar.gz
Tar-xvzf zlib-1.2.8.tar.gz
CD zlib-1.2.7.tar.gz
./configure
Make
Make install

2: Install FreeType


wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.0.1.tar.gz
Cd/usr/local/src
TAR-ZXVF freetype-2.3.5.tar.gz
CD freetype-2.3.5
./configure--prefix=/usr/local/freetype
Make
Make install
There may be an error while make:
/usr/include/libpng12/pngconf.h:336:error:expected ' = ', ', ', '; ', ' asm ' or ' __attribute__ ' before '. ' Token
/usr/include/libpng12/pngconf.h:337:error:expected ' = ', ', ', '; ', ' asm ' or ' __attribute__ ' before ' include '
Make: * * * [/usr/local/src/freetype-2.5.0.1/objs/sfnt.lo] Error 1
Solution:
./configure–prefix=/usr/local/freetype–without-png (plus this option on the line)

3: Install Libpng

wget http://sourceforge.net/projects/libpng/files/libpng12/older-releases/1.2.31/libpng-1.2.31.tar.gz/download
Cd/usr/local/src
TAR-ZXVF libpng-1.2.31.tar.gz
CD libpng-1.2.31
./configure
Make
Make install

4: Install LIBXML2

wget http://xmlsoft.org/sources/old/libxml2-2.7.1.tar.gz
Cd/usr/local/src
TAR-XZVF libxml2-2.7.1.tar.gz
CD libxml2-2.7.1
./configure--PREFIX=/USR/LOCAL/LIBXML2--without-zlib (remember to add the following sentence, or it will go wrong)
Make
Make install

5: Install Libmcypt

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
Cd/usr/local/src
Tar zxvf libmcrypt-2.5.7.tar.gz
CD libmcrypt-2.5. 7
./configure--prefix=/usr/local/libmcrypt
Make
Make install

6: Install GD2 (PHP's GD library, compression and processing pictures will be used)

wget http://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz
Cd/usr/local/src
TAR-ZXVF gd-2.0.35.tar.gz
Mkdir-p/USR/LOCAL/GD
CD gd-2.0.35
./configure--prefix=/usr/local/gd--enable-m4_pattern_allow--with-jpeg--with-png--with-zlib--with-freetype=/usr /local/freetype--with-libmcrypt=/usr/local/libmcrypt
Make
Make instal
(–with-jpeg: Make IT support JPEG image processing; –with-png: support for PNG image processing)
There may be an error in the compilation process:
First compile and install the GetText


wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.3.1.tar.gz
Tar xzf gettext-0.17.tar.gz
CD gettext-0.17
./configure
Make
Make install

Note: If the GD library version is gd-2.0.35 or above, you will need./configure–enable-m4_pattern_allow or compile the GetText component and then recompile GD

7: Install APR (Apache Portable runtime)

At this address http://mirror.bit.edu.cn/apache/apr/download Apr and Apr-util

Cd/usr/local/src
wget http://mirror.bit.edu.cn/apache/apr/apr-1.5.1.tar.gz
TAR-ZXVF apr-1.5.1.tar.gz
CD apr-1.5.1
./configure--PREFIX=/USR/LOCAL/APR
Make
Make install

8: Install Apr-util

wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.4.1.tar.gz
Tar zxvf apr-util-1.4.1.tar.gz
CD apr-util-1.4.1
./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR
Make
Make install

9: Install OpenSSL

wget ftp://ftp.openssl.org/source/openssl-1.0.1c.tar.gz #openssldir is the configuration file directory, recommended installation two times, shared role is to generate dynamic connection library.
TAR-ZXF openssl-1.0.1c.tar.gz
CD openssl-1.0.1c/
./config--prefix=/usr/local/openssl--openssldir=/usr/local/openssl/ssl
Make && Make install
./config Shared--prefix=/usr/local/openssl--openssldir=/usr/local/openssl/ssl
Make clean
Make
Make install

10: Install Curl


wget http://curl.haxx.se/download/curl-7.17.1.tar.gz
TAR-ZXVF curl-7.17.1.tar.gz
CD curl-7.17.1
./configure--prefix=/usr/local/curl
Make
Make install
If an error occurs:
Curl.so-lz-lrt-wl,-rpath-wl,/usr/local/curl/lib
.. /lib/.libs/libcurl.so:undefined reference to ' err_remove_thread_state '
Collect2:ld returned 1 exit status
MAKE[2]: * * * [curl] Error 1
MAKE[2]: Leaving directory '/USR/LOCAL/SRC/CURL-7.32.0/SRC '
MAKE[1]: * * * [ALL] Error 2
MAKE[1]: Leaving directory '/USR/LOCAL/SRC/CURL-7.32.0/SRC '
Make: * * * [all-recursive] Error 1
It is recommended to install the old point version, especially if the OpenSSL version is below 1.0

Two: Install httpd

wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.9.tar.gz
TAR-ZXVF httpd-2.4.9.tar.gz
CD httpd-2.4.9
./configure--prefix=/usr/local/apache--with-apr=/usr/local/apr--with-included-apr--with-apr-util=/usr/local/ Apr-util--with-ssl=/usr/local/openssl--enable-ssl=static--enable-so--enable-maintainer-mode--with-mpm=prefork- -enable-rewrite=shared--enable-userdir--enable-vhost-alias=shared--enable-cgi--enable-cgid--enable-expires= Shared--enable-mem-cache=shared--enable-disk-cache=shared--enable-cache=shared--enable-deflate--enable-modules =all--enable-mods-shared=all
Make
Make install
/usr/local/apache/bin/apachectl-k Start #启动httpd
Vim/usr/local/apache/conf/httpd.conf #编辑配置文件
Find: #ServerName www.example.com:80
Modified to: ServerName localhost:80
Find: DirectoryIndex index.html
Modified to: DirectoryIndex index.html index.php
Find: Options Indexes followsymlinks
Modified to: Options followsymlinks #不显示目录结构
Find AllowOverride None

Modified to: allowoverride all #开启apache支持伪静态, notice that there are two changes to make
LoadModule rewrite_module modules/mod_rewrite.so #取消前面的注释, open Apache support pseudo static
CP/USR/LOCAL/APACHE/BIN/APACHECTL/ETC/RC.D/INIT.D/HTTPD #加入到系统启动

Vim/etc/init.d/httpd
Add the following two lines below #!/bin/sh
#chkconfig: 2345 10 90
#description: activates/deactivates Apache Web Server

Chown daemon.daemon-r/usr/local/apache/htdocs #更改默认项目目录所有者
chmod 700/usr/local/apache/htdocs-r #更改apache默认网站目录权限
Chkconfig httpd on #设置开机自动启动httpd
/ETC/INIT.D/HTTPD Start #启动httpd
Service httpd Restart #重启httpd

The following error may occur when compiling or configuring:

1: Error message:

httpd-2.4.4/support/ab.c:2271:undefined reference to ' Tlsv1_1_client_method '

Solution:

This is a OpenSSL version of the issue, version less than 1.0 recommended to compile the installation of a high version of 1.0.0C, and then compile and install Apache time add –with-ssl=/usr/local/openssl This parameter, solve the problem

2: Error message:

/usr/local/ssl/lib/libssl.a:could not read Symbols:bad value
Collect2:ld returned 1 exit status
MAKE[4]: * * * [mod_ssl.la] Error 1
MAKE[4]: Leaving directory '/usr/local/src/httpd-2.4.9/modules/ssl '
MAKE[3]: * * * [shared-build-recursive] Error 1
MAKE[3]: Leaving directory '/usr/local/src/httpd-2.4.9/modules/ssl '
MAKE[2]: * * * [shared-build-recursive] Error 1
MAKE[2]: Leaving directory '/usr/local/src/httpd-2.4.9/modules '
MAKE[1]: * * * [shared-build-recursive] Error 1
MAKE[1]: Leaving directory '/usr/local/src/httpd-2.4.9′
Make: * * * [all-recursive] Error 1

Solution:

This error indicates an SSL error and requires recompilation
A: The compile time did not bring –with-ssl=/usr/local/openssl
B: With the –with-ssl parameters, but OpenSSL compiled without the tape: fpic This parameter
Position independent Code is necessary to a module like mod_ssl which could get placed anywhere with memory at runtime. It is not necessary to the standalone OpenSSL test program, which are why make test worked OK Without-fpic.

3: Error message:

Error while loading shared Libraries:libssl.so.1.0.0:cannot open Shared object file:no such file or directory

Solution:

Because we loaded the module is mod_ssl.so, to the OpenSSL directory Lib issued the existing two libraries
If you want mod_ssl.so to find both libraries, you must add Ssl/lib to the Ld_library_path variable
~/.BASHRC (once every login opens shell read once),
After modifying the user's environment variable, it will not take effect immediately, execute the source ~/.BASHRC to make it effective, so that you can start Apache

4: Error message:

Chkconfig httpd on, an error occurred using service httpd start:
Error while loading shared Libraries:libssl.so.1.0.0:cannot open Shared object file:no such file or directory

The reason is: the library file libssl.so.1.0.0 was not found at startup because/usr/lib64 (64-bit user library file) does not have this file.

Solution:

Use the ln soft link to share/usr/local/openssl/lib library files.
Ln-s/usr/local/openssl/lib/libssl.so.1.0.0/usr/lib64/libssl.so.1.0.0
Ln-s/usr/local/openssl/lib/libcrypto.so.1.0.0/usr/lib64/libcrypto.so.1.0.0
Service httpd start succeeded.

5: Error message:

Configure when there is a mistake
Configure:error:Bundled APR requested but not found at./srclib/. Download and unpack the corresponding APR and Apr-util packages to./srclib/.

Solution:

Because: apache-2.2 and the new apache-2.4 installed different place is, version 2.4 has not come with the APR library, so before installing apache-2.4, need to download Apr.
CP-RF apr-1.4.4 HTTPD-2.4.9/SRCLIB/APR
CP-RF apr-util-1.5.3 Httpd-2.4.9/srclib/apr-util
Configure can be

Third: Install MySQL

MySQL official website: http://dev.mysql.com/downloads/Download Source Package

Groupadd MySQL #添加mysql组
useradd-g mysql mysql-s/bin/false #创建用户mysql并加入到mysql组, MySQL users are not allowed to log on directly to the system
Mkdir-p/U Sr/local/mysql #创建MySQL安装目录
mkdir-p/usr/local/mysql/data #创建MySQL数据存放目录
Tar zxvf mysql-5.5.21.tar.gz
CD mysql-5.5.21
CMake.-dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/usr/local/mysql/data-dsysconfdir =/etc-dmysql_unix_addr=/tmp/mysql.sock-dwith_innobase_storage_engine=1-dwith_myisam_storage_engine=1-denabled_ Local_infile=1-dmysql_tcp_port=3306-dwith_extra_charsets:string=utf8,gbk-ddefault_charset=utf8-ddefault_ Collation=utf8_general_ci-dwith_debug=0-dwith_readline=1-dwith_ssl=yes
# (sometimes there are warnings that/usr/local/mysql/data are not found, Regardless of him, continue compiling directly)
make
make install

Cd/usr/local/mysql
CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #提示文件存在的话直接覆盖
VIM/ETC/MY.CNF #在 [mysqld] part increased
DataDir =/usr/local/mysql/data #数据库存放路径
./scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql #生成mysql系统数据库
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把Mysql加入系统启动
chmod 755/etc/init.d/mysqld #增加执行权限
Chkconfig mysqld on #加入开机启动
Vim/etc/rc.d/init.d/mysqld #编辑
Basedir =/usr/local/mysql #MySQL程序安装路径
DataDir =/usr/lcoal/mysql/data #MySQl数据库存放目录
Service mysqld Start #启动
/usr/local/mysql/bin/mysql-u root–p # login MySQL

#安装成功后进行root用户密码修改:
/usr/local/mysql/bin/mysqladmin-u root-p Password "New password" #回车后提示输入旧密码, enter successful password revision success
/etc/init.d/mysqld Restart #重启mysql, installation success!

Four: Install PHP

wget http://cn2.php.net/get/php-5.3.27.tar.gz/from/ar2.php.net/mirror
./configure--prefix=/usr/local/php- -with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/ mysql --with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-gd -- With-iconv--with-freetype-dir=/usr/local/freetype--with-jpeg-dir=/usr/local/jpeg9--with-png-dir=/usr/local/ Libpng--with-zlib--with-libxml-dir=/usr/local/libxml2--enable-xml--enable-discard-path--enable-magic-quotes-- Enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curlwrappers-- Enable-mbregex--enable-fastcgi--enable-force-cgi-redirect--enable-mbstring--enable-ftp--enable-gd-native-ttf-- With-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap- With-mime-magic--enable-suhosin--enable-session--with-mcrypt

Make
Make install
(–with-jpeg-dir uses the default version of Yum installation)

Problems that may occur when configure is configured:

Checking for CURL in default path ... not found
Configure:error:Please Reinstall the Libcurl distribution-
Because: Curl's dev pack is not installed
Solution: Yum-y Install Curl-devel

Issues that may occur when make is compiled:

Virtual Memory Exhausted:cannot Allocate memory

Reason: The compilation process is a memory consumption of a large action, memory tight, unable to allocate

WORKAROUND: Configure the item plus –disable-fileinfo this parameter, recompile


CP Php.ini-production/usr/local/php/etc/php.ini #复制php配置文件到安装目录
Rm-rf/etc/php.ini #删除系统自带的配置文件
Ln-s/usr/local/php/etc/php.ini/etc/php.ini #创建配置文件软链接
Vim/usr/local/php/etc/php.ini #编辑
To find:; Open_basedir =
Modified to: Open_basedir =.:/ tmp/#防止php木马跨站
Find:;d Ate.timezone =
Modified as: Date.timezone = PRC
Find: expose_php = On
Modified to: expose_php = off #禁止显示php版本的信息
Find: Display_errors = On
Modified to: Display_errors = off #关闭错误提示
wq! #保存 PHP Installation Complete
Five: Configure Apache to support PHP


Vim/usr/local/apache/conf/httpd.conf #编辑apache配置文件

Add the following two lines

LoadModule php5_module        modules/libphp5.so
AddHandler application/ x-httpd-php .php  (Note: PHP. PHP has a space in front of this point)
service httpd restart    #重启apache
Service mysqld restart   #重启mysql
cd /usr/local/apache/htdocsvi  index.php   #输入下面内容
: wq! #保存
[cc lang= PHP]
enters the server IP address in the client browser and can see related configuration information such as PHP!

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.