lamp compiler environment installed on centos6

First, the preparatory work

1) Close selinux, iptables

[root@centos ~]# sed -i 7s/enforcing/disabled/ /etc/selinux/config
[root@centos ~]# service iptables stop
[root@centos ~]# chkconfig iptables off
#记得重启

2) configured local CD yum source, the experimental machine is cenos6.8

[root@centos ~]# mount /dev/sr0 /mnt/cdrom1
[root@centos ~]# mount /dev/sr1 /mnt/cdrom2
#光盘源配置
    [c6-media]
    name=CentOS-$releasever - Media
    baseurl=file:///mnt/cdrom1/
            file:///mnt/cdrom2/
    gpgcheck=0
    enabled=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

3) installation-related compilation tools

[root@centos ~]#  yum -y install gcc gcc-c++ make 

4) Prepare relevant source package

#建立一个专门存放源码包文件夹
mkdir  /lamp
#解压参考脚本
#!/bin/bash
cd /lamp
/bin/ls *.tar.gz >ls.txt
for i in `/bin/cat ls.txt`
do
    tar -zxf $i
    if [ $? -eq 0 ];then
        echo " $i 解压成功"
    else
        echo " $i 解压失败" >> error.txt
    fi
done 
/bin/rm -rf ls.txt

Second, compile and install

1, install libxml2

Libxml2 is a xml c language version of the parser, originally developed for the Gnome project tool, based on the MIT License is a free open source software. In addition to its support c language version, it also supports binding c ++, PHP, Pascal, Ruby, Tcl and other languages, and can run on Windows, Linux, Solaris, MacOsX platforms.

[root@centos ~]#  yum install -y libxml2-devel python-devel 
[root@centos ~]# cd /lamp/libxml2-2.9.8
[root@centos libxml2-2.9.8]# ./configure --prefix=/usr/local/libxml2/ 
[root@centos libxml2-2.9.8]# make && make install
2, installation libmcrypt

libmcrypt encryption algorithm extensions. Supports DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER + algorithms.

[root@centos libxml2-2.9.8]# cd /lamp/libmcrypt-2.5.8
[root@centos libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt/
[root@centos libmcrypt-2.5.8]# make && make install

Installation libltdl, also libmcrypt source directory

[root@centos libmcrypt-2.5.8]# cd /lamp/libmcrypt-2.5.8/libltdl
[root@centos libltdl]#  ./configure --enable-ltdl-install
[root@centos libltdl]# make && make install
3, installation mhash

mhash is based not reverse php encryption extension libraries discrete mathematical principles, it is not turned on by default. mhash check sum may be used to create a message digest, message authentication codes, and information stored without the original key (e.g., password) and the like.

[root@centos libltdl]# cd /lamp/mhash-0.9.9.9
[root@centos mhash-0.9.9.9]# ./configure && make && make install
4, install mcrypt

mcrypt php which is important encryption support extensions. mcrypt library supports 20 kinds of encryption algorithms and 8 encryption mode

[root@centos mhash-0.9.9.9]# cd /lamp/mcrypt-2.6.8
[root@centos mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib #变量:LD_LIBRARY_PATH 用于指定 libmcrypt 和 mhash 的库的位置
[root@centos mcrypt-2.6.8]# ./configure --with-libmcrypt-prefix=/usr/local/libmcrypt
[root@centos mcrypt-2.6.8]# make && make install
5, install zlib

zlib is used to provide data compression library, developed by Jean-loup Gailly and Mark Adler, version 0.9 first edition, published in 1995, May 1. DEFLATE algorithm using zlib, libpng library originally written, was popular for many of the software you are using. This library is free software, using zlib license

[root@centos mcrypt-2.6.8]#  cd /lamp/zlib-1.2.8
[root@centos zlib-1.2.8]# ./configure && make && make install
6, install libpng

libpng package contains libpng libraries. These libraries are other programs for decoding png image

[root@centos zlib-1.2.8]# cd /lamp/libpng-1.2.31
[root@centos libpng-1.2.31]# ./configure --prefix=/usr/local/libpng
[root@centos libpng-1.2.31]# make && make install
7, install jpeg6

jpeg6 provide libraries for decoding .jpg and .jpeg pictures

#创建目录
[root@centos libpng-1.2.31]# mkdir /usr/local/jpeg6 \
mkdir /usr/local/jpeg6/bin \
mkdir /usr/local/jpeg6/lib \
mkdir /usr/local/jpeg6/include \
mkdir -p /usr/local/jpeg6/man/man1
[root@centos libpng-1.2.31]# yum -y install libtool* 
[root@centos libpng-1.2.31]# cd /lamp/jpeg-6b
复制 libtool 中的文件,覆盖 jpeg-6b 中的文件(64 位中的问题) 
[root@centos jpeg-6b]# cp -a /usr/share/libtool/config/config.sub ./
[root@centos jpeg-6b]# cp -a /usr/share/libtool/config/config.guess ./
[root@centos jpeg-6b]# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
[root@centos jpeg-6b]# make && make install
8, install freetype

FreeType library is a free (open source), high quality and portable font engine, which provides a unified interface to access a variety of font formats, supports monochrome bitmaps, rendering, anti-aliasing bitmap.

[root@centos jpeg-6b]#  cd /lamp/freetype-2.3.5 
[root@centos freetype-2.3.5]# ./configure --prefix=/usr/local/freetype/
[root@centos freetype-2.3.5]# make && makre install 
9, install Apache

1), source packages 2.4. * Version without integrated apr default dependencies, so it is necessary to solve the problem in advance dependent

[root@centos freetype-2.3.5]# yum install expat-devel -y
[root@centos freetype-2.3.5]#  cp  -a  /lamp/apr-1.7.0 /lamp/httpd-2.4.41/srclib/apr
[root@centos freetype-2.3.5]#  cp  -a  /lamp/apr-util-1.6.1 /lamp/httpd-2.4.41/srclib/apr-util

2), Apache default pcre need to rely on software, but because of higher Apache software version, the system pre-installed pcre can not use, so people need to manually install the appropriate version.

[root@centos freetype-2.3.5]# cd /lamp/pcre-8.43-RC1
[root@centos pcre-8.43-RC1]# ./configure && make && make install

3), Apache modules encrypted transmissions mod_ssl, the software needs to be installed to produce

[root@centos pcre-8.43-RC1]# yum install openssl-devel  -y

4), httpd software installation

[root@centos pcre-8.43-RC1]# cd /lamp/httpd-2.4.41
[root@centos httpd-2.4.41]# ./configure --prefix=/usr/local/apache2 --sysconfdir=/usr/local/apache2/etc --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-ssl
[root@centos httpd-2.4.41]# make && make install
10, install ncurses

Ncurses provides character terminal handling libraries, including panels and menus. It provides a set of cursor control, windowing, change the foreground and background colors of the mouse handler. Allowing users to bypass the underlying mechanisms of those annoying when writing applications in character terminal

[root@centos httpd-2.4.41]# yum -y install ncurses-devel
[root@centos httpd-2.4.41]# cd /lamp/ncurses-5.9
[root@centos ncurses-5.9]#  ./configure --with-shared --without-debug --without-ada --enable-overwrite
[root@centos ncurses-5.9]# make && make install
11, installation and bison cmake

After mysql 5.5, is no longer used ./configure tool, compile and install. The use cmake tool replaces ./configure tool. bison is a free software for automatically generating parser program, available for all common operating systems

[root@centos ncurses-5.9]# yum -y install cmake bison
12, Installing MySQL

1) Create mysql user

[root@centos ncurses-5.9]# useradd -r -s /sbin/nologin mysql

2), mounted mysql

[root@centos ncurses-5.9]# cd /lamp/mysql-5.5.48
[root@centos mysql-5.5.48]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
[root@centos mysql-5.5.48]# make && make install 

Parameter Description

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql  安装位置 
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock   指定 socket(套接字)文件位置 
-DEXTRA_CHARSETS=all      扩展字符支持 
-DDEFAULT_CHARSET=utf8         默认字符集 
-DDEFAULT_COLLATION=utf8_general_ci      默认字符校对 
-DWITH_MYISAM_STORAGE_ENGINE=1      安装 myisam 存储引擎 
-DWITH_INNOBASE_STORAGE_ENGINE=1      安装 innodb 存储引擎 
-DWITH_MEMORY_STORAGE_ENGINE=1     安装 memory 存储引擎  
-DWITH_READLINE=1          支持 readline 库 
-DENABLED_LOCAL_INFILE=1        启用加载本地数据 
-DMYSQL_USER=mysql        指定 mysql 运行用户 
-DMYSQL_TCP_PORT=3306      指定 mysql 端口 

3), modify the MySQL directory user belongs

[root@centos mysql-5.5.48]# cd /usr/local/mysql/
[root@centos mysql]# chown -R root .
[root@centos mysql]# chown -R mysql data

4), generating a configuration file, and initialize the grant table

[root@centos mysql]# cp -a /lamp/mysql-5.5.48/support-files/my-medium.cnf /etc/my.cnf
[root@centos mysql]#  cd /usr/local/mysql 
[root@centos mysql]#  ./scripts/mysql_install_db --user=mysql

5) to start the service

[root@centos mysql]# /usr/local/mysql/bin/mysqld_safe &

6), password

[root@centos mysql]# /usr/local/mysql/bin/mysqladmin -uroot password 123456

7), log in mysql

[root@centos mysql]# /usr/local/mysql/bin/mysql -u root -p
13, to install PHP
[root@centos mysql]# cd /lamp/php-7.3.11
[root@centos php-7.3.11]# ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config
[root@centos php-7.3.11]# make && make install

Parameter Description

--with-config-file-path=/usr/local/php/etc/  指定配置文件目录 
--with-apxs2=/usr/local/apache2/bin/apxs  指定 apache 动态模块位置 
--with-libxml-dir=/usr/local/libxml2/   指定 libxml 位置 
--with-jpeg-dir=/usr/local/jpeg6/    指定 jpeg 位置 
--with-png-dir=/usr/local/libpng/    指定 libpng 位置 
--with-mcrypt=/usr/local/libmcrypt/       指定 libmcrypt 位置
--with-freetype-dir=/usr/local/freetype/  指定 freetype 位
--with-mysqli=/usr/local/mysql/bin/mysql_config 指定 mysqli 位置 
--with-gd    启用 gd 库 
--enable-soap       支持 soap 服务 
--enable-mbstring=all     支持多字节,字符串 
--enable-sockets      支持套接字 
--with-pdo-mysql=/usr/local/mysql  启用 mysql 的 pdo 模块支持 
--without-pear       不安装 pear(安装 pear 需要连接互联网) 

1), the profile generating php

[root@centos php-7.3.11]# cp /lamp/php-7.3.11/php.ini-production /usr/local/php/etc/php.ini

2), modify the apache configuration file, so the file identification php

[root@centos ~]# vim /usr/local/apache2/etc/httpd.conf
    AddType application/x-httpd-php .php .phtml    
    AddType application/x-httpd-php-source .phps

3), restart apache

[root@centos ~]# /usr/local/apache2/bin/apachectl restart

4) to test whether you can connect

[root@centos ~]# vim /usr/local/apache2/htdocs/test.php   
<?php   
    phpinfo();   
?>

Access test, as follows
http://20.20.20.21/test.php

14, the module mounting openssl

OpenSSL is a powerful Secure Sockets Layer cryptographic library cryptographic algorithms include major, commonly used key and certificate management and SSL protocol encapsulation, and provides a wealth of applications for testing or other purposes.

#先卸载原来系统中自带的 Autoconf ,版本过低会报错
[root@centos openssl]# rpm -e --nodeps autoconf-2.63
[root@centos openssl]# cd /lamp/autoconf-2.69
[root@centos autoconf-2.69]# ./configure && make && make install
#安装 openssl
[root@centos ~]# cd /lamp/php-7.3.11/ext/openssl
[root@centos openssl]# mv config0.m4 config.m4
[root@centos openssl]# /usr/local/php/bin/phpize
[root@centos openssl]# ./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config
[root@centos openssl]# make && make install
15, the module mounting memcache

Memcache is a high-performance distributed memory object caching system, by maintaining a uniform huge hash table in memory, it can be used to store a variety of data formats, including images, videos, files, and database search results, etc. . Simply put, it is to call the data into memory, and then read from memory, thus greatly improving the read speed.

[root@centos lamp]# unzip  pecl-memcache-php7.zip
[root@centos pecl-memcache-php7]# cd  pecl-memcache-php7
[root@centos pecl-memcache-php7]# mv memcache.loT memcache.lo
[root@centos pecl-memcache-php7]# /usr/local/php/bin/phpize
[root@centos pecl-memcache-php7]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@centos pecl-memcache-php7]# make && make install
#记录下安装位置
/usr/local/php/lib/php/extensions/no-debug-zts-20180731/
16, modify the php configuration file

And call it to recognize the two modules and memcache openssl

[root@centos pecl-memcache-php7]# vim /usr/local/php/etc/php.ini 
    extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20180731/"
    extension="openssl.so";    
    extension="memcache.so";
#重启apache,测试看是否多了两个模块
17, install memcached service
[root@centos pecl-memcache-php7]# yum -y install libevent-devel
[root@centos pecl-memcache-php7]# cd /lamp/memcached-1.5.9
[root@centos memcached-1.5.9]# ./configure --prefix=/usr/local/memcache
[root@centos memcached-1.5.9]# make && make install
[root@centos memcached-1.5.9]#  useradd -r -s /sbin/nologin memcache
[root@centos memcached-1.5.9]# /usr/local/memcache/bin/memcached -umemcache &
18, install phpMyAdmin

phpMyAdmin is a PHP-based, Web-Base mode architecture MySQL database management tool on the website of the host, so that managers available Web interface to manage MySQL database.

[root@centos lamp]#  cp -a /lamp/phpMyAdmin-4.9.1-all-languages  /usr/local/apache2/htdocs/phpmyadmin
[root@centos lamp]# cd /usr/local/apache2/htdocs/phpmyadmin
[root@centos phpmyadmin]# cp -a config.sample.inc.php config.inc.php
[root@centos phpmyadmin]# vim config.inc.php
#新增
    $cfg['Servers'][$i]['auth_type'] = 'http';

Access test
http://20.20.20.21/phpmyadmin/index.php user name is root, password is specified when the MySQL root password 123456 is set
as follows

19, set up Apache, MySQL, Memcache boot from Kai
[root@centos phpmyadmin]# vim /etc/rc.local   
    /usr/local/apache2/bin/apachectl start   
    /usr/local/mysql/bin/mysqld_safe --user=mysql &   
    /usr/local/memcache/bin/memcached -umemcache &
20, lamp environment has been set up is complete.

Guess you like

Origin www.cnblogs.com/hjnzs/p/12145414.html