Solution to lamp and related errors in centos6.5

Source: Internet
Author: User
Tags gpg install openssl mcrypt

Solution to lamp and related errors in centos6.5

I. Preparations

1. Install the compilation tools gcc and gcc-c ++

To solve the dependency, we recommend that you use yum for installation. If you cannot connect to the Internet, you can use the installation disc as the yum source --

1) edit the yum configuration file:

# Mount/dev/cdrom/mnt/cdrom

# Vi/etc/yum. repos. d/CentOS-Media.repo


Name = CentOS-$ releasever-Media

Baseurl = file: // mnt/cdrom * changed to the disk mount point.

File: // media/cdrom/

File: // media/cdrecorder/

Gpgcheck = 1

Enabled = 1 * to enable

Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

2) Cut/etc/yum. repos. d/CentOS-Base.repo

# Mv/etc/yum. repos. d/CentOS-Base.repo/backup

3) install gcc and gcc-c ++ in sequence

# Yum-y install gcc

# Yum-y install gcc-c ++

2. Disable the Apache and MySQL services of the system RPM installation package.

Disable started services httpd and mysqld

# Service httpd stop

# Service mysqld stop

Make sure that the httpd and mysqld files installed in the rpm package cannot be automatically started upon startup.

Chkconfig -- level2345 httpd (mysqld) off

3. Disable SELinux and allow access from port 80 of the firewall.

Use setup

Disable firewall and SElinux

1) Disable SELinux

# Vi/etc/selinux/config

SELINUX = disabled * If SELinux is not disabled during installation, change enforcing to disabled.

After modification, you must restart Linux to make it take effect!

2) disable the firewall Netfilter/iptables

Because no firewall has been explained yet, you can simply disable all firewall settings:

# Iptables-F * If the firewall is not disabled, access to port 80 is disabled by default.



4. disable unnecessary auto-start services

# Ntsysv

The following lists services that can be self-started, and unlisted services can be closed:


Crond # scheduled tasks by atd and crond


Microcode_ctl # system irq port call, System Service

Network # network settings

Sendmail # mail

Sshd # Remote Management

Syslog # system logs

5. Copy the source code package and decompress it.

We recommend that you store the LAMP environment installation source code package in a single directory, such as/lamp

You can compile a batch script to decompress all installation packages of .tar.gz.

# Vi tar. sh


/Bin/ls * .tar.gz> ls. list

/Bin/ls *. tgz> ls. list

ForTAR in 'cat ls. list' // note


/Bin/tar-zxf $ TAR


/Bin/rmls. list

6. Check whether the disk space is insufficient.


* If the/partition is full, you can move the installation package to another partition or delete other useless files.


How to determine the error:

1) the installation process is stopped.

2) After the service is stopped, an error or warning occurs on the page.

Determine whether the installation is successful:

Go to the installation directory and check that the installation program appears.

Ii. Compilation and Installation

* After each source code package is compiled and installed, check whether the installation file is generated in the installation directory.

Make clean

# Install libxml2

Libxml2 is an xml C language parser. It was originally developed for the Gnome project and is a free open-source software based on MIT License. In addition to the c language version, it also supports binding c ++, PHP, Pascal, Ruby, Tcl and other languages, and can run on Windows, Linux, Solaris, MacOsX, and other platforms. The function is still quite powerful. I believe there is no problem in meeting the needs of general users.

Libxml is a function library used to parse XML documents. It is written in C and can be called in multiple languages, such as C, C ++, and XSH. C #, Python, Kylix/Delphi, Ruby, and PHP. The XML: LibXML module can also be used in Perl. It was initially developed for GNOME, but can now be used in a variety of ways. LibXML code is highly portable because it is based on the standard ansi c library and uses the MIT license.

# Yum install-y libxml2-devel if an error is reported, install this package and try again

Yum-y installpython-devel must have


./Configure -- prefix =/usr/local/libxml2/


Make install

# Install libmcrypt

Libmcrypt is an extension library of encryption algorithms. Supports DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER +, and other algorithms.


./Configure -- prefix =/usr/local/libmcrypt/


Make install

* The gcc-c ++ compiler must be called. If it is not installed, an error is returned.

# Install libltdl, which is also in the libmcrypt source code directory. Non-New Software


./Configure -- enable-ltdl-install


Make install

# Install mhash

Mhash is an extension library based on discrete mathematics that cannot be reversed in php encryption mode. It is disabled by default. Mhash can be used to create verification values, message digests, message authentication codes, and save key information (such as passwords) in the original text.




Make install

# Install mcrypt

Mcrypt is an important encryption supporting extension library in php. The Mcrypt Library supports over 20 encryption algorithms and 8 encryption modes.


LD_LIBRARY_PATH =/usr/local/libmcrypt/lib:/usr/local/lib \

./Configure -- with-libmcrypt-prefix =/usr/local/libmcrypt

Backslash \ indicates that a command has not completed line feed.

# The preceding command is used. LD_LIBRARY_PATH is used to specify the location of libmcrypt and mhash libraries.

-- With-libmcrypt-prefix is used to specify the libmcrypt software location


Make install

# Mcrypt is not installed. This is the php module. You need to continue the installation after the php installation is complete.

# Installing zlib

Zlib is a library for data compression. It was developed by Jean-loup Gailly and Mark Adler. The first version of zlib was published in 0.9. Zlib uses the DEFLATE algorithm, which was originally written for the libpng library and was generally used by many software. This function library is free software and is authorized using zlib.




Make install>/root/zlib. log

* The installation directory specified by zlib may cause libpng installation failure. Therefore, it is not specified. For ease of uninstallation, we recommend that you make install to output the execution result to the Installation Log File for later uninstallation.

# Install libpng

The libpng package contains the libpng library. These libraries are used by other programs to decode png images.


./Configure -- prefix =/usr/local/libpng


Make install

# Install IIS6

For decoding. jpg and. JPEG images

Mkdir/usr/local/limit 6

Mkdir/usr/local/partition 6/bin


Mkdir/usr/local/users 6/include

Mkdir-p/usr/local/users 6/man/man1

# The directory must be created manually.


./Configure -- prefix =/usr/local/configure 6/-- enable-shared -- enable-static


Make install

* The -- enable-shared and -- enable-static parameters are libtool used to create a shared library and a static library respectively.

# Install freetype

FreeType library is a completely free (open-source) high-quality and portable font engine. It provides a unified interface to access a variety of font format files, including TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, X11 PCF, etc. Supports the rendering of monochrome bitmaps and reverse-sample bitmaps. FreeType library is a highly modular library. Although it is developed using ansi c, it adopts the object-oriented idea. Therefore, FreeType users can flexibly crop it.


./Configure -- prefix =/usr/local/freetype/


Make install

# Install the GD library

The GD library is an extension library for php graphics processing. The GD library provides a series of APIS for image processing. You can use the GD library to process images or generate images. The GD library is usually used to generate thumbnails, add watermarks to images, generate Chinese Character verification codes, or generate reports for website data.



* Png error. modification method:

Vi gd_png.c

Replace # include "png. h" with # include "/usr/local/libpng/include/png. h"

. /Configure -- prefix =/usr/local/gd2/-- with-jpeg =/usr/local/versions 6/-- with-freetype =/usr/local/freetype/-- with-png =/usr/local/libpng/


Make install

* If the installation directory is not specified when zlib is configured, do not add the -- with-zlib =/usr/local/zlib/parameter during gd configuration.

# Install Apache

Configure: error: Bundled APR requested but not found at./srclib/. Download and unpack the corresponding apr and apr-util packages to./srclib /.

# If an error is reported:

Tarzxvf apr-1.4.6.tar.gz

Tarzxvf apr-util-1.4.1.tar.gz



# Decompress apr and apr-util, copy and cancel the version number.

Configure: error: pcre-config for libpcre not found. PCRE is requiredand available from

# If an error is reported:

Tarzxvf pcre-8.34.tar.gz


./Configure & make install

Checking whether to enable mod_ssl... configure: error: mod_ssl has beenrequested but can not be built due to prerequisite failures

# If an error is reported:

Yum install openssl-devel

Install apache


. /Configure -- prefix =/usr/local/apache2/-- sysconfdir =/usr/local/apache2/etc/-- with-encoded-apr -- enable-so -- enable-deflate = shared -- enable-expires = shared -- enable-rewrite = shared



* If the installation directory is not specified when zlib is configured, do not add the -- with-z =/usr/local/zlib/parameter during Apache configuration.

**************************************** **************************

Start Apache test:

/Usr/local/apache2/bin/apachectl start

Ps-aux | grep httpd

Netstat-tlun | grep: 80

* If the prompt "/usr/local/apache2/modules/" is not available at startup, disable SELinux or run the command chcon-t texrel_shlib_t/usr/local/apache2/modules/mod_defl, similar to this type. so files cannot be loaded or have no permissions. They are all SELinux problems. Use the command "chcon-t texrel_shlib_t file name" to solve them. MySQL and Apache may also have similar problems.

Enter the address in the browser to access: http: // Apache server address. If "It works" is displayed, Apache works properly.

Start Apache during boot:

Echo "/usr/local/apache2/bin/apachectl start">/etc/rc. d/rc. local

# Install ncurses

Ncurses provides character terminal processing libraries, including panels and menus. It provides a set of functions to control the cursor, create a window, change the foreground background color, and process mouse operations. This allows users to bypass the annoying underlying mechanisms when writing applications on character terminals. In short, it is a function library that allows applications to directly control terminal screen display.


Yum-y installncurses-devel

Note: if an error is reported, the package cannot be found. * The wildcard is not identified. Double quotation marks ("ncurses *") are added to the file name *"

2. source code compilation:


./Configure -- with-shared -- without-debug -- without-ada -- enable-overwrite


Make install

* If ncurses is not installed to compile MySQL, an error is returned.

* -- The without-ada parameter is set to not be compiled as ada binding. ada cannot be used because the chroot environment is entered; -- enable-overwrite: the header file is installed under/tools/include instead of the/tools/include/ncurses directory.

* -- With-shared library generation

# Install cmake and bison

After mysql 5.5, the./configure tool is no longer used for compilation and installation. Instead of the./configure tool, use the cmake tool. For more information about cmake usage, see cmake.

Bison is a free software used to automatically generate a syntax analyzer program, which can be used in all common operating systems

Yum-y install cmake

Yum-y install bison

# Install MySQL

Groupadd mysql

Useradd-g mysql

* Add the user group mysql and set the default mysql user group to the mysql user group.


Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_UNIX_ADDR =/tmp/mysql. sock-DEXTRA_CHARSETS = all-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = bytes-rows = 1-rows = 1-rows = 1-DWITH_READLINE = 1-rows = 1-DMYSQL_USER = mysql-rows = 3306

-DCMAKE_INSTALL_PREFIX =/usr/local/mysql installation location

-DMYSQL_UNIX_ADDR =/tmp/mysql. sock specifies the socket File Location

-DEXTRA_CHARSETS = all extension characters supported

-DDEFAULT_CHARSET = utf8 default Character Set

-DDEFAULT_COLLATION = utf8_general_ci default character Verification

-DWITH_MYISAM_STORAGE_ENGINE = 1 install the myisam storage engine

-DWITH_INNOBASE_STORAGE_ENGINE = 1 install the innodb Storage Engine

-DWITH_MEMORY_STORAGE_ENGINE = 1 install the memory storage engine

-DWITH_READLINE = 1 supports the readline Library

-DENABLED_LOCAL_INFILE = 1 enable local data loading

-DMYSQL_USER = mysql specifies the mysql running user

-DMYSQL_TCP_PORT = 3306 specify the mysql Port


Make install

Make clean

Rm CMakeCache.txt

# Use the preceding command to clear the cache if an error is reported


Chown-R mysql.

Chgrp-R mysql.

# Modifying mysql Directory Permissions

/Usr/local/mysql/scripts/mysql_install_db -- user = mysql

# Create a database authorization table and initialize the database

Chown-R root.

Chown-R mysql data

# Modifying mysql Directory Permissions

Cpsupport-files/my-medium.cnf/etc/my. cnf

# Copying the mysql configuration file

/Usr/local/mysql/scripts/mysql_install_db -- user = mysql

Start the MySQL service:

1. Use and start mysql with the original source code

/Usr/local/mysql/bin/mysqld_safe -- user = mysql &

& Symbol background running

2. It will take effect after restart:

Vi/etc/rc. local

/Usr/local/mysql/bin/mysqld_safe -- user = mysql &

3. Set the mysql password

/Usr/local/mysql/bin/mysqladmin-uroot password lonly

Clear history command history-c

* Add password 123 to the root user of mysql

* Note that the password cannot be "123"

/Usr/local/mysql/bin/mysql-u root-p

Mysql> showdatabases;

Mysql> usetest;

Mysql> showtables;

Mysql> \ s # Check whether the character set is changed to utf8

* Use set to change the password after entering mysql.

Mysql> exit

* Log on to the MySQL console and set the specified root password.

# Install PHP

Before compilation, make sure that the libtool and libtool-ltdl software packages are installed. Install:

Yum-y install "libtool *"

Yum-y install "libtool-ltdl *"


Typedef struct gdIOCtx



Void (* data );

# Add this sentence


# Php 5.4 bug. Check if the gd library is faulty and need to be manually modified


. /Configure -- prefix =/usr/local/php/-- with-config-file-path =/usr/local/php/etc/-- with-apxs2 =/usr/local/apache2/ bin/apxs -- with-mysql =/usr/local/mysql/-- with-libxml-dir =/usr/local/libxml2/-- with-jpeg-dir =/usr/local /configure 6/-- with-png-dir =/usr/local/libpng/-- with-freetype-dir =/usr/local/freetype/-- with-gd =/usr/local /gd2/-- with-mcrypt =/usr/local/libmcrypt/-- with-mysqli =/usr/local/mysql/bin/mysql_config -- enable-soap -- enable-mbstring = all -- enable-sockets -- without-pear

L if the installation directory is not specified when zlib is configured, do not add the -- with-zlib-dir =/usr/local/zlib/parameter during PHP configuration.


-- With-config-file-path =/usr/local/php/etc/Specify the configuration file directory

-- With-apxs2 =/usr/local/apache2/bin/apxs specifies the location of the apache dynamic module

-- With-mysql =/usr/local/mysql/Specify the mysql location

-- With-libxml-dir =/usr/local/libxml2/Specify the libxml location

-- With-jpeg-dir =/usr/local/jpeg 6/Specify the jpeg position

-- With-png-dir =/usr/local/libpng/Specify the libpng position

-- With-freetype-dir =/usr/local/freetype/Specify the freetype location

-- With-gd =/usr/local/gd2/Specify the gd position

-- With-mcrypt =/usr/local/libmcrypt/Specify the libmcrypt location

-- With-mysqli =/usr/local/mysql/bin/mysql_config specify the position of mysqli

-- Enable-soap supports the soap Service

-- Enable-mbstring = all supports multibyte, string

-- Enable-sockets supports sockets

-- Without-pear does not install pear. (To install pear, you must connect to the Internet. PEAR is a PHP extension and application Library)


Make install

Generate php. ini

Cp/lamp/php-5.4.25/php. ini-production/usr/local/php/etc/php. ini

Test the connectivity between Apache and PHP to see if Apache can parse the PHP File

Vi/usr/local/apache2/etc/httpd. conf

AddType applications/x-httpd-php.php. phtml. phps

(Case Sensitive)

*. Phtml uses. phps as the PHP source file for syntax highlighting.

Restart Apache:/usr/local/apache2/bin/apachectl stop

/Usr/local/apache2/bin/apachectl start

* Apache cannot be started. The error "cannot restore segment protafter reloc: Permission denied" is returned. If SELinux is incorrect, disable SELinux or run the command "chcon-t texrel_shlib_t/usr/local/apache2/modu

Test: vi/usr/local/apache2/htdocs/test. php

<? Php

Phpinfo ();


Enter the address in the browser to access: http: // Apache server address/test. php

Default page Directory/var/www/html/installed in the Rpm package/

* Sometimes the browser test fails for the first time. Close the browser and restart it. This is not a compilation error.

# Compile and install memcache

Memcache is a high-performance distributed memory object cache system. By maintaining a unified and huge hash table in the memory, Memcache can be used to store data in various formats, including image, video, file, and database retrieval results. Simply put, the data is called to the memory and then read from the memory, which greatly improves the reading speed.

Yum-y installzlib-devel

Cd memcache-3.0.8


./Configure -- with-php-config =/usr/local/php/bin/php-config

Make & makeinstall

# Compile and install mcrypt



./Configure -- with-php-config =/usr/local/php/bin/php-config -- with-mcrypt =/usr/local/libmcrypt/


Make install

# Use these commands to install the mcrypt module after php installation is complete

Modify/usr/local/php/etc/php. ini

Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20100525 /"

# Open comments and modify

Extension = "memcache. so ";

Extension = "mcrypt. so ";

# Add

# Restart apache. You can find these two modules in phpinfo.

# Install memcache source code

First install the dependency package libevent

Yum-y install "libevent *"

# In CentOS 6.3, change the disk.


./Configure -- prefix =/usr/local/memcache

Make & make install

Useradd memcache

# Add a memcache user. This user does not need to log on or set a password.

/Usr/local/memcache/bin/memcached-umemcache &

Netstat an | grep: 11211

Telnet 11211


Write auto-start:

Vi/etc/rc. d/rc. local

/Usr/local/memcache/bin/memcached-umemcache &

# Install phpMyAdmin

Cp-r phpMyAdmin-4.1.4-all-languages/usr/local/apache2/htdocs/phpmyadmin


Cp config. sample. inc. phpconfig. inc. php

Vi config. inc. php

$ Cfg ['servers'] [$ I] ['auth _ type'] = 'cooker ';

$ Cfg ['servers'] [$ I] ['auth _ type'] = 'http ';

* Set auth_type to http, that is, set to HTTP Identity Authentication mode.

Enter the address in the browser to access: http: // Apache server address/phpmyadmin/index. php

The username is root, and the password is the root password (lampbrother) specified when MySQL is set)

Most of the installation errors are input errors. You can use the history command to check the history.

Grantall privileges on *. * TO 'root' @ '%' identified by '000000' with grant option;

SQL statement, not a linux Command

Grant all privileges on *. * to 'root' @ '%' identified by '000000' with grant option

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: 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.