Centos6.5 Lamp Environmental Source package installation and configuration, with the installation package Baidu Network disk address

Source: Internet
Author: User
Tags install php soap mysql version phpinfo readline unpack iptables fully qualified domain name
Centos6.5 Lamp Environment Source package installation and configuration

HTTP://PAN.BAIDU.COM/S/1NVNRUZV installation package Baidu Network disk address
Lamp is a Web network application and development environment, is the abbreviation of Linux,apache,mysql,php/perl, each letter represents a component, each component in itself is a very powerful component in the aspect it represents.
The Linux:linux is at the bottom and provides the operating system. Its flexibility and customizable nature means it can produce a highly customizable platform for other components to run on. Other components run on Linux but are not necessarily limited to Linux or run on Microsoft Windows, Mac OS X, or UNIX.
Apache:apache, located on the second floor, is a Web services platform that provides a mechanism for users to obtain Web pages. Apache is a powerful, stable, mission-critical Web server that is used as a Web server by more than 50% of Web sites on the Internet.
Mysql:mysql is the most popular open source relational database management system, is the lamp data storage side. In a WEB application, all account information, product information, customer information, business data, and other types of information are stored in the database and can be easily queried in SQL language.
Php/perl:perl is a flexible language, especially when dealing with textual elements, which makes it easy for Perl to handle the data provided through the CGI interface, flexibly using text files and simple databases to support dynamic elements. PHP is a widely used, open source, multipurpose scripting language that can be embedded in HTML, especially for Web development. You can use PHP to write dynamic content that accesses the data in the MySQL database and some of the features that Linux provides. System Environment

System platform: CentOS release 6.5
Apache Version: httpd-2.2.9.tar.gz
Mysql version: mysql-5.5.20.tar.gz
PHP Version: php-5.3.22.tar.gz

Pre-Installation Preparation:
Installing GCC, gcc-c++ compilers
Use the GCC–V command to check for the existence of the compile work that is used during installation

If not installed, use in networked situations:
Yum install gcc and yum install gcc-c++ installation

Confirm that the environment required to build the lamp is installed:

Rpm-q make CMake gcc gcc-c++ zlib-devel libtool libtool-ltdl libtool-ltdl-devel Bison ncurses-devel
Note: When installing libpng, you need to zlib-devel install
    php libtool, Libtool-ltdl, libtool-ltdl-devel
    install MySQL need bison, ncurses-devel

Yum installation if the above required environment is not installed:

Yum-y install make CMake gcc gcc-c++ zlib-devel libtool libtool-ltdl libtool-ltdl-devel Bison ncurses-devel

Before you install PHP, you should first install the latest version of the library files that PHP5 requires, such as LIBXML2, Libmcrypt, and GD2 libraries. The GD2 library is installed to allow PHP5 to support GIF, PNG, and JPEG picture formats, so you must install the latest zlib, libpng, FreeType, and JPEGSRC library files before installing the GD2 library. And the middle will be interspersed with the installation of some software

The Ps-ef|grep mysqld      #查看是否有mysqld进程
        PS command is used to view the currently running process.
        grep is search
ps-aux | grep java     #-aux Show all States
 kill command used to terminate a process
for example: kill-9 [PID]       #-9 indicates that forcing a process to stop immediately is
commonly used PS View process PID, terminate process PS with kill command
[options]-
    e Show All processes, environment variable
    -F full format
    H does not display title-
    L Long Format-
    w wide output
    a display terminal All processes, including other user processes
    R shows only the running process
    x shows no control over the terminal process

See if installing httpd, MySQL, PHP Installation: Uninstall the old version of Apache if installed

Rpm-qa | grep httpd        #检查是否安装了httpd软件包
rpm-e httpd-2.2.3-63.el5.centos--nodeps       
#卸载软件包,--nodeps: If there is a connection, force uninstall
cd/etc/httpd/
rm-rf *     #到原来的apache安装目录下, delete all of its installation directories and files
Uninstall MySQL
Rpm-qa | grep mysql            #检查是否安装了mysql软件包
rpm-e mysql-5.0.77-4.el5_4.2--nodeps      #卸载mysql
Uninstall PHP
Rpm-qa | grep php          #检查是否安装了php软件包
rpm-e php-common-5.1.6-27.el5--nodeps
rpm-e php-ldap-5.1.6-27.el5--nodeps
rpm-e php-cli-5.1.6-27.el5--nodeps
rpm-e php-5.1.6-27.el5--nodeps
#卸载PHP

turn off SELinux and clear firewall rules

First, view the SELinux status command:

/usr/sbin/sestatus-v   #如果SELinux Status parameter is enabled and is open
    SELinux status:                 enabled

    Getenforce                 # #也可以用这个命令检查

Turn off the SELinux method:

        1, temporarily shutdown (do not restart the machine): The
        code is as follows:
        Setenforce 0 #设置SELinux become permissive mode
        Setenforce 1 #设置SELinux become enforcing mode
        2, modify the configuration file needs to restart the machine:
        Modify
        The Vim/etc/selinux/config file will be selinux=enforcing to selinux=disabled restart
        machine can

Use the SSH shell to upload the 13 source packages under Windows to/USR/LOCAL/SRC unpack
Introduction to compiling the installation process:
1 decompression tar.gz for the suffix of the compression software package: Lamp environment to build the software required for each soft code files, are tar.gz or. tgz provided to our packaging compressed files, so we have to unpack and unpack. The order is as follows:

       TAR–ZXVF *.tar.gz

2 in the Linux system source code package installation process: Lamp environment to build the software required by the C language development, so the installation of source code files need to configure, compile and install at least three steps
Configuration (Configure), compilation (make), installation (Makeinstall) installation lamp

1. Installation LIBXML2

cd/usr/local/src/libxml2-2.6.30

./configure--prefix=/usr/local/libxml2 make

&& make install

2. Installation Libmcrypt

cd/usr/local/src/libmcrypt-2.5.8

./configure--prefix=/usr/local/libmcrypt make

&& make install

3. Installation zlib

cd/usr/local/src/zlib-1.2.3

cflags= "-o3-fpic"./configure--prefix=/usr/local/zlib/
(compiled with a 64-bit method)

Make && make install

4. Installation libpng

cd/usr/local/src/libpng-1.2.31

./configure--prefix=/usr/local/libpng--enable-shared
    #-- Enable-shared (GNU Libtool for shared libraries) make && make

install

5. Install JPEG
This package installation is special, other packages installed when the directory does not exist, will be automatically created, but this package installation needs to be manually created.

Mkdir/usr/local/jpeg && mkdir/usr/local/jpeg/bin && mkdir/usr/local/jpeg/lib && mkdir/usr/ Local/jpeg/include && mkdir-p/usr/local/jpeg/man/man1
    #   Mkdir/usr/local/jpeg (Create the installation directory for JPEG software)
    #   Mkdir/usr/local/jpeg/bin (Create the directory that holds the command)
    #   Mkdir/usr/local/jpeg/lib   (Create the directory where the JPEG library files are located)
    #   Mkdir/usr/local/jpeg/include (Create a storage header file directory)
    #   Mkdir-p/usr/local/jpeg/man/man1 (set up a directory for storing manuals)

cd/usr/ local/src/jpeg-6b

./configure--prefix=/usr/local/jpeg--enable-shared--enable-static
        #>-- Enable-shared  \  (Generate dynamic link library)
        #>--enable-static   (generate static link library) make

&& make install

When you execute make, you receive the following error:

./libtool--mode=compile Gcc-o2-  I.-C/JCAPIMIN.C make
:./libtool:command notfound Make
: * * * * Jcapimin.lo] Error 127

Workaround:
Libtool and Libtool-ltdl-devel are installed by default (see procedure 2 for help if needed)

[root@localhostjpeg-6b]# Find/-name config.sub
/usr/share/libtool/config/config.sub
[ root@localhostjpeg-6b]# Find/-name config.guess
/usr/share/libtool/config/config.guess

operations are as follows:
[ root@localhostjpeg-6b]# cp-vrp/usr/share/libtool/config/config.sub.

[root@localhostjpeg-6b]# cp-vrp/usr/share/libtool/config/config.guess.

That is, take the two profiles inside the Libtool and overwrite the corresponding files in the jpeg-6b directory.
Make clean and configure again.

./configure--prefix=/usr/local/jpeg--enable-shared--enable-static make

&& make install

6. Installation FreeType

cd/usr/local/src/freetype-2.3.5

./configure--prefix=/usr/local/freetype--enable-shared
        #>-- Enable-shared (gun libtool for shared library use) make

install freetype make [install] Error 1 (ignore) problem

Always when make install: Rm-f/usr/local/modules/freetype/include/freetype2/freetype/cache/* rmdir/usr/local/modules/
Freetype/include/freetype2/freetype/cache rm-f/usr/local/modules/freetype/include/freetype2/freetype/internal/* Rmdir/usr/local/modules/freetype/include/freetype2/freetype/internal rmdir: '/usr/local/modules/freetype/include
          /freetype2/freetype/internal ': No file or directory make: [Install] Error 1 (ignored)/usr/bin/install-c-M 644./builds/unix/ft2unix.h \                        /usr/local/modules/freetype/include/ft2build.h/usr/bin/install-c-M 644./builds/unix/ftconfig.h \/usr/local/modules/freetype/include/freetype2/freetype/config/ftconfig.h/usr/bin/install-c-M 644/o Pt/src/lamp/freetype-2.2.1/objs/ftmodule.h \/usr/local/modules/freetype/include/freety Pe2/freetype/config/ftmodule.h/usr/bin/install-c-M 755./builds/unix/freetype-config \/usr/local/modules/fre Etype/bin/freetype-config/usr/bin/install-c-M644/builds/unix/freetype2.m4 \/usr/local/modules/freetype/share/aclocal/freetype2.m4/usr/bin/install-c-M 6 /BUILDS/UNIX/FREETYPE2.PC \/usr/local/modules/freetype/lib/pkgconfig/freetype2.pc (Error)

Solution:

Mkdir/usr/local/freetype/include/freetype2/freetype/internal
#需要在freetype的安装目录下创建internal This directory then,
make Install

7. Installation autoconf

        cd/usr/local/src/autoconf-2.61

        ./configure make

        && make install

8. Install GD library

        cd/usr/local/src/gd-2.0.35

    ./configure--prefix=/usr/local/gd--enable-m4_pattern_allow--with-zlib=/usr/ local/zlib/--with-jpeg=/usr/local/jpeg/--with-png=/usr/local/libpng/--with-freetype=/usr/local/freetype/
    #>--enable-m4_pattern_allow \
    #>--with-zlib=/usr/local/zlib/\  (Specify location of zlib library files)
    #>-- with-jpeg=/usr/local/jpeg/\    (Specify the location of the JPEG library file)
    #>--with-png=/usr/local/libpng/\   (Specify the location of the PNG library file)
#>--with-freetype=/usr/local/freetype/(Specify the location of the FreeType font library) make

Error occurred:

MAKE[2]: * * * [Gd_png.lo] Error 1
make[2]: Leaving directory '/usr/local/src/gd-2.0.35 '
make[1]: * * * All-recursive] Error 1
make[1]: Leaving directory '/usr/local/src/gd-2.0.35 ' make
: * * * [ALL] Error 2


Analysis: This problem is because the GD_PNG.C in the GD library contains png.h when the source file, png.h not find the cause.
Solve:
[root@localhostgd-2.0.35]# Find/-name gd_png.c
/usr/local/src/gd-2.0.35/gd_png.c
[root@localhostgd-2.0.35]# Find/-name png.h
/usr/local/libpng/include/png.h
[root@localhostgd-2.0.35]# VI gd_png.c
In the compiled file

VI gd_png.c

Change include "Png.h" to include "/usr/local/libpng/include/png.h"

Where/usr/local/libpng/is the libpng installation path.

Make install

9. Install Apache

    cd/usr/local/src/httpd-2.2.9

./configure--prefix=/usr/local/apache2--enable-so--enable-rewrite
#>-- ENABLE-SO \      (compiled with dynamic shared objects) enables the Apache core load DSO
#>--enable-rewrite  (rule-based URL manipulation) to enable the override

     feature

     make Install

Add Apache to boot

Cp-vrp/usr/local/apache2/bin/apachectl/etc/init.d/httpd

Add Apache service ↓

Chkconfig--add httpd

when you perform chkconfig, the following error occurs:
Chkconfig service httpd does not supportch Kconfig Apache is not supported
Workaround:
The HTTPD service does not support Chkconfig when the chkconfig is set as a system service.
The resolution process is as follows:
1. Editors

VIM/ETC/INIT.D/HTTPD
#!/bin/bash
add:
#chkconfig: 345
#description: Apache httpd

Save and then execute Chkconfig

        Chkconfig--add httpd chkconfig--list|grep httpd chkconfig--level 2345 httpd on
        service httpd start

When you start the service, you receive the following error:

Httpd:could not reliablydetermine the server ' s fully qualified domain name, using localhost.localdomainfor ServerName

Workaround:

[root@localhosthttpd-2.2.9]# vi/usr/local/apache2/conf/httpd.conf

Find #servername localhost.com:80 to remove the # and restart Apache.

Configure Apache

Start Apache
    #/usr/local/apache2/bin/apachectl start
off Apache
    #/usr/local/apache2/bin/apachectl Stop
See if Port 80 is open
    # Netstat-tnl|grep 80

Accessing the Apache server

Firewall
Open the firewall 80 port so that the external network can access

    Vi/etc/sysconfig/iptables

    -A input-p tcp-m tcp--dport 80-j ACCEPT

    service iptables restart

External network through browser access to compile install MySQL

(The latest version requires a cmake compile installation)
How to clear CMake compilation scripts
Delete a file under a folder RM CMakeCache.txt
Recompile.
Compile and install MySQL5.5.20

[root@localhostsrc]# groupadd MySQL #添加一个mysql标准组 [root@localhostsrc]# useradd-g mysql mysql #添加mysql用户并加到mysql组中 [ro ot@localhostlinux]# TAR-ZXVF mysql-5.5.20.tar.gz [root@localhostlinux]# cd/usr/local/src/mysql-5.5.20 [ root@localhostmysql-5.5.20]# cmake-dcmake_install_prefix=/usr/local/mysql/-dmysql_unix_addr=/usr/local/mysql/ Data/mysql.sock-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_extra_charsets=all-dwith_myisam _storage_engine=1-dwith_innobase_storage_engine=1-dwith_memory_storage_engine=1-dwith_readline=1-dwith_innodb_ Memcached=1-dwith_debug=off-dwith_zlib=bundled-denabled_local_infile=1-denabled_profiling=on-dmysql_maintainer _mode=off-dmysql_datadir=/usr/local/mysql/data-dmysql_tcp_port=3306-dwith_memory_storage_engine=1-dwith_ readline=1 #cmake-dcmake_install_prefix=/usr/local/mysql \ (Installation root directory) #-dmysql_unix_addr=/usr/local/mysql/data/mys Ql.sock \ (UNIX socket file) #-ddefault_charset=utf8 \ (default character Set) #-ddefault_collation=utF8_GENERAL_CI \ (default encoding) #-dwith_extra_charsets=utf8,gbk \ (additional encoding) #-dwith_perfschema_storage_engine=1 \ (Enable Perfsche MA engine support) #-dwith_federated_storage_engine=1 \ (enable federated engine Support) #-dwith_partition_storage_engine=1\ (Enable PARTITION engine support ) #-dwith_archive_storage_engine=1 \ (enable ARCHIVE engine support) #-dwith_readline=1 \ (use READLINE features) #-dmysql_datadir=/usr/loca L/mysql/data \ (Database Data directory) #-dmysql_tcp_port=3306 (TCP/IP port) **mysql Common Parameters * * #-dcmake_install_ Prefix=/usr/local/mysql \ #安装路径 #-dmysql_datadir=/usr/local/mysql/data \ #数据文件存放位置 #-DSYSCONFD
IR=/ETC \ #my. cnf path #-dwith_myisam_storage_engine=1 \ #支持MyIASM引擎    #-dwith_innobase_storage_engine=1 \ #支持InnoDB引擎 #-dwith_memory_storage_engine=1 \               #支持Memory引擎 #-dwith_readline=1 \ #快捷键功能 (I didn't use it) #-dmysql_unix_addr=/tmp/mysqld.sock \ #连接数据库sOcket path #-dmysql_tcp_port=3306 \ #端口 #-denabled_local_infile=1 \                             #允许从本地导入数据 #-dwith_partition_storage_engine=1 \ #安装支持数据库分区 #-dextra_charsets=all \ #安装所有的字符集 #-ddefault_charset=utf8 \ #默认字符 make make install
CP  /USR/LOCAL/MYSQL/SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF

Modify configuration file

[root@localhostmysql-5.5.20]# vi/etc/my.cnf

[mysqld]
     basedir=/usr/local/mysql
     datadir=/usr/local/ Mysql/data
     log-error=/usr/local/mysql/data/error.log
     pid-file=/usr/local/mysql/data/mysql.pid

Initializing database files

[root@localhostmysql-5.5.20]#/usr/local/mysql/scripts/mysql_install_db--defaults-flie=/etc/my.cnf--basedir=/ usr/local/mysql/--datadir=/usr/local/mysql/data--pid-file=/usr/local/mysql/data/mysql.pid--user=mysql

Permission set ↓ (go to MySQL file)

Cd/usr/local/mysql
[root@localhostmysql]# chown-r root.
[root@localhostmysql]# chown-r mysql data
[root@localhostmysql]# chgrp-r MySQL.

Add MySQL to boot

[root@localhostmysql]# cp-vrp support-files/mysql.server/etc/init.d/mysqld
[root@localhostmysql]# chmod +x/etc /init.d/mysqld

Add MySQL Service

[root@localhostmysql]# chkconfig--add mysqld
[root@localhostmysql]# chkconfig--level 345-mysqld on

failed to start.
Mysql:starting MySQL ..... error! The server quit without updating PID file solution
Reason: no initialization permission table

[Root@localhost ~]# cd/usr/local/mysql
[root@localhost mysql]# chown-r.
[Root@localhost mysql]# su-mysql
[mysql@localhost ~]$ cd/usr/local/mysql
[mysql@localhost mysql]$ scripts/ mysql_install_db
[mysql@localhost mysql]$/usr/local/mysql/bin/mysqld_safe--user=mysql &
[ root@localhostmysql]# Service mysqld start
or
[mysql@localhost mysql]$/etc/init.d/mysqld start

Configure MySQL

[root@localhostmysql]# Bin/mysql

if MySQL does not go to MySQL:

Ln-s/usr/local/mysql/bin/mysql/usr/bin

Sometimes install the MySQL program, the direct input command mysql or mysqladmin will find that the prompt command does not exist, this is because the system defaults will look for commands under/usr/bin, if this command is not in this directory, of course, will not find the command, All we need to do is map a link to the/usr/bin directory, equivalent to creating a linked file.

First you need to know the full path to the MySQL command or mysqladmin command, such as the MySQL path is:/usr/local/mysql/bin/mysql, we can execute the command:

Ln-s/usr/local/mysql/bin/mysql (mysqladmin)/usr/bin  
Mysql> deletefrom mysql.user where host!= ' localhost '; # (leave only the account that allows this machine to log in)
mysql> flushprivileges;  # (Refresh authorization table)
mysql> setpassword for ' root ' @ ' localhost ' =password (' 123456 ');  # (set user password)
mysql> exit
[root@localhostmysql]# bin/mysql-h localhost-u root-p123456 # (login to MySQL)

compiling and installing PHP

[root@localhostlinux]# tar-zxvf php-5.3.22.tar.gz [root@localhostlinux]# cd/usr/local/src/php-5.3.22 [ root@localhostphp-5.3.22]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs-- with-mysql=/usr/local/mysql/--with-libxml-dir=/usr/local/libxml2/--with-png-dir=/usr/local/libpng/-- with-jpeg-dir=/usr/local/jpeg/--with-freetype-dir=/usr/local/freetype/--with-gd=/usr/local/gd/--with-mcrypt=/ usr/local/libmcrypt/--with-mysqli=/usr/local/mysql/bin/mysql_config--enable-soap--enable-mbstring=all--
    Enable-sockets * * If error, change--with-gd=/usr/local/gd/to--WITH-GD system gd** #./configure--prefix=/usr/local/php \ #--with-apxs2=/usr/local/apache2/bin/apxs \ #--with-mysql=/usr/local/mysql/\ #--with-libxml-dir=/usr/local/libxm l2/\ #--with-png-dir=/usr/local/libpng/\ #--with-jpeg-dir=/usr/local/jpeg/\ #--with-freetype-dir=/usr/local /freetype/\ #--with-gd=/usr/local/gd/\ #--with-mcrypt=/usr/local/libmcrypt/\ #--with-mYsqli=/usr/local/mysql/bin/mysql_config \ #--enable-soap\ (variable activation soap and Web services support) #--enable-mbstring=all \ (Enable multibyte string support) #--enable-sockets (variable activates socket traffic feature) [root@localhostphp-5.3.22]# make [root@localhostph p-5.3.22]# make install [root@localhostphp-5.3.22]# cp-vrp Php.ini-development/etc/php.ini [root@localhostphp-5.3.22 ]# vi/usr/local/apache2/conf/httpd.conf found: AddType application/x-compress. Z AddType application/x-gzip. GZ Tgz added later: AddType application/x-httpd-php. php AddType application/x-ht Tpd-php-source. PHP5 found: <ifmodule dir_module> directoryindex index.html </IfModule> add: In
Dex.html after adding index.php on the line. [root@localhostphp-5.3.22]# service httpd stop [root@localhostphp-5.3.22]# service httpd start [   root@localhostphp-5.3.22]# vi/usr/local/apache2/htdocs/phpinfo.php Add Content: <?php phpinfo ();?>

Open the browser to access, if the PHP version of the interface, and installation is successful.
http://xxx.xxx.xxx.xxx./phpinfo.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.