CentOS 6.7 compilation and installation of LAMP

Source: Internet
Author: User
Tags mcrypt mysql commands zts opencart

CentOS 6.7 compilation and installation of LAMP

CentOS 6.7 compilation and installation of LAMP

I. Prepare the environment and Software Package

[Root @ bkjia ~] # Cat/etc/RedHat-release
CentOS release 6.7 (Final)
[Root @ bkjia ~] # Uname-rm
2.6.32-573. el6.x86 _ 64 x86_64

Use 163 yum Source

Cd/etc/yum. repos. d/
Wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

Disable firewall and selinux

Setenforce 0
Service iptables stop

Software packages to be prepared

Mkdir/tools; cd/tools

Apr-1.5.2.tar.gz

Apr-util-1.5.4.tar.gz

Httpd-2.4.16.tar.gz

Curl-7.45.0.tar.gz

Gettext-0.19.5.tar

Libmcrypt-2.5.7.tar.gz

Mcrypt-2.6.8.tar.gz

Lpng1618.zip

Mod_fastcgi-2.4.6.tar.gz

Mysql-5.6.26.tar.gz

Php-5.5.30.tar.gz

PhpMyAdmin-4.5.0.2-all-languages.zip

Libpng-1.2.53.tar

Freetype-2.4.0.tar

Jpegsrc.v9.tar

Opencart-2.1.0.1.zip

Zlib-1.2.3.tar

...................

Note: The version does not have to be the same.

Ii. Install the dependent Environment

Yum-y groupinstall "Development Libraries"
Yum-y groupinstall "Desktop Platform Development"
Yum-y groupinstall "X Software Development"
Yum-y install wget gcc-c ++ ncurses-devel cmakemake perl bison openssl-devel gcc * libxml2 libxml2-devel curl-devellibjpeg * libpng * freetype * pcre-devel bzip2-devel libmcrypt- devel

3. Compile and install apr
1. Compile and install apr

Cd/tools
Tar xjvfapr-1.5.2.tar.bz2-C/usr/src/; cd/usr/src/apr-1.5.2/
./Configure -- prefix =/usr/local/apr
Make & makeinstall

2. Compile and install apr-util

Cd/tools/
Tar xjvfapr-util-1.5.4.tar.bz2-C/usr/src/; cd/usr/src/apr-util-1.5.4
./Configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr/
Make & make install
 

4. Compile and install apache

Cd/tools
Tar xjvf httpd-2.4.17.tar.bz2-C/usr/src/; cd/usr/src/httpd-2.4.17

. /Configure -- prefix =/usr/local/apache2 -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util/-- -mpm = event -- enable-so -- enable-mods-shared = all -- enable-proxy = shared -- enable-proxy-balancer = shared -- enable-prosy-http = shared -- enable -proxy-ajp -- enable-deflate -- enable-cache -- enable-disk-cache -- enable-mem-cachemake & make install

V. Compile and install mysql
1. Install mysql

Cd/tools
Tar xzvfmysql-5.6.26.tar.gz-C/usr/src/; cd/usr/src/mysql-5.6.26
Cmake-DENABLE_DOWNLOADS = 1-DCMAKE_INSTALL_PREFIX =/opt/mysql -- with-mysql = mysqlnd -- with-pdo-mysql = mysqlnd -- with-mysqli = mysqlnd
Make & make install
 
2. Create related settings
Mkdir/data/mysql/{mysql-data, mysql-logs}-pv
Groupadd-r-g 306 mysql
Useradd-r-g 306-u 306 mysql
Chown-R mysql. mysql/data/mysql/

Edit configuration file

Vim/etc/my. cnf

Add the following content:

[Mysql]
Prompt = (\ u @ \ h) [\ d]>

[Client]
Port = 3306
Socket =/tmp/mysql3306.sock
Default_character_set = utf8

[Mysqld]
User = mysql
Port = 3306
Socket =/tmp/mysql3306.sock
Datadir =/data/mysql-data
Pid_file =/data/mysql-data/mysql. pid
Log-bin =/data/mysql-logs/mysql-bin
Log-error =/data/mysql-logs/mysql. err

 

For details, refer to the attachment my. cnf.

Edit Startup Script

Vim/etc/rc. d/init. d/mysqld

Add and modify the following three rows:

Basedir =/opt/mysql
Datadir =/data/mysql-data
Defaultconf =/etc/my. cnf

For details, refer to the attachment mysqld file.

Set the startup script permission

Chmod + x/etc/rc. d/init. d/mysqld

3. initialize the database and start
Initialize the database. If two OK statements are displayed after execution, the initialization is successful.

/Opt/mysql/scripts/mysql_install_db -- user = mysql -- datadir =/data/mysql-data/-- basedir =/opt/mysql/-- defaults-file =/etc/ my. cnf

Start Database

[Root @ bkjia tools] #/etc/rc. d/init. d/mysqld start
Starting MySQL ...... SUCCESS!

 

Add mysql commands to Environment Variables

PATH = $ PATH:/opt/mysql/bin/

Chkconfig -- add mysqld
Chkconfig mysqld on
[Root @ bkjia tools] # chkconfig -- list mysqld
Mysqld 0: off1: off2: on3: on4: on5: on6: off

 

Use service commands to manage mysql Processes

[Root @ bkjia tools] # service mysqld stop
Shutting down MySQL. SUCCESS!

 

6. Compile and install php
1. Install curl
Cd/tools
Tar xzvf curl-7.45.0.tar.gz-C/usr/src/; cd/usr/src/curl-7.45.0
./Configure -- prefix =/usr/local/curl & make install

2. Install libmcrypt
Cd/tools
Tar xzvflibmcrypt-2.5.8.tar.gz-C/usr/src/; cd/usr/src/libmcrypt-2.5.8/
./Configure -- prefix =/usr/local/libmcrypt & make install

3. Install mhash

Cd/tools
Tar xzvfmhash-0.9.9.9.tar.gz-C/usr/src/; cd/usr/src/mhash-0.9.9.9
./Configure -- prefix =/usr/local/mhash & make install
Ln-s/usr/local/lib/libmhash. a/usr/lib/libmhash.
Ln-s/usr/local/lib/libmhash. la/usr/lib/libmhash. la
Ln-s/usr/local/lib/libmhash. so/usr/lib/libmhash. so
Ln-s/usr/local/lib/libmhash. so.2/usr/lib/libmhash. so.2
Ln-s/usr/local/lib/libmhash. so.2.0.1/usr/lib/libmhash. so.2.0.1

Echo "/usr/local/lib">/etc/ld. so. conf
Ldconfig

4. Install mcrypt

Cd/tools
Tar xzvf mcrypt-2.6.8.tar.gz-C/usr/src/; cd/usr/src/mcrypt-2.6.8
./Configure -- prefix =/usr/local/mcrypt -- with-libmcrypt =/usr/local/libmcrypt/& make install

5. Install gettext

Cd/tools
Tar xvf gettext-0.19.5.tar-C/usr/src/; cd/usr/src/gettext-0.19.5
./Configure -- prefix =/usr/local/gettext & make install

6. Install libxml2
Cd/tools
Tar xzvflibxml2-2.6.30.tar.gz-C/usr/src/; cd/usr/src/libxml2-2.6.30/
./Configure -- prefix =/usr/local/libxml2 & make install

 
7. install php
Cd/tools
Tarxzvf php-5.5.30.tar.gz-C/usr/src/; cd/usr/src/php-5.5.30
. /Configure -- prefix =/opt/php -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-curl =/usr/local/curl/-- with-mcrypt =/ usr/local/mcrypt/-- with-mysql =/opt/mysql/-- with-gettext =/usr/local/gettext/-- with-mysqli -- with-bz2 -- with-mhash -- enable -sockets -- enable-mbstring -- enable-zip -- enable-bcmath -- enable-calendar -- enable-exif -- enable-ftp -- enable-fpm -- with-openssl -- with-libxml-dir =/usr/local/libxml2/
Make & make install

8. Set phpinfo and phpadmin
(1) set the phpinfo page

Cd/usr/local/apache2/htdocs/

Cat> index. php <EOF
<? Php
Phpinfo ();
?>
EOF

Modify the apache configuration file

Vim/usr/local/apache2/conf/httpd. conf

Add index. php after DirectoryIndex, as shown below:

DirectoryIndexindex. php index.html

Add

AddTypeapplication/x-httpd-php. php. phtml
AddType application/x-httpd-php-source.phps

Access http: // yourip

The following page indicates that lamp is successfully installed.

(2) Set phpadmin

Cd/tools
UnzipphpMyAdmin-4.5.0.2-all-languages.zip
MvphpMyAdmin-4.5.0.2-all-languages/usr/local/apache2/htdocs/phpadmin
Cd/usr/local/apache2/htdocs/phpadmin
Cpconfig. sample. inc. php config. inc. php
Vim config. inc. php

Add any character after $ cfg ['blowfish _ secret'] to encrypt the password.

Change the localhost of $ cfg ['servers'] [$ I] ['host'] To 127.0.0.1.

Set mysql password

Mysqladmin-u root password abc123
Mysqladmin-u root-h 127.0.0.1 passwordabc123

Log on to mysql

Mysql-u root-pabc123
(Root@127.0.0.1) [(none)]> grant allprivileges on *. * to root @ '%' identified by 'root ';
Query OK, 0 rows affected (0.00 sec)

Access http: // yourip/phpadmin in a browser

You can see the following interface and use your mysql user name and password to log on.

(3) Modify php. in
After LAMP installation is complete, you can adjust php. ini to implement some custom functions.

Cd/usr/src/php-5.5.30/
Cp php. ini-production/opt/php/lib/php. ini

VII. Extend the PHP Module
Sometimes, after installing php, we find that the required modules are not installed, but we do not want to re-compile and install php. Then we can use dynamic extension to install the php extension module.

The following uses the GD module and zlib module as an example:

1. Install freetype

Cd/tools
Tar xjvffreetype-2.4.0.tar.bz2-C/usr/src/; cd/usr/src/freetype-2.4.0/
./Configure -- prefix =/usr/local/freetype & make install

2. Install jpeg

Cd/tools
Tar xzvf jpegsrc.v9.tar.gz-C/usr/src/; cd/usr/src/jpeg-9
CFLAGS = "-O3-fPIC"./configure -- prefix =/usr/local/jpeg & make install

Mkdir-p/usr/local/jpeg/include
Mkdir-p/usr/local/jpeg/lib
Mkdir-p/usr/local/jpeg/bin
Mkdir-p/usr/local/jpeg/man/man1

3. Install libpng

Cd/tools
Tar xzvflibpng-1.2.53.tar.gz-C/usr/src/; cd/usr/src/libpng-1.2.53
CFLAGS = "-O3-fPIC"./configure -- prefix =/usr/local/libpng & make install

4. Install gd

Cd/usr/src/php-5.5.30/ext/gd/

[Root @ bkjia gd] #/opt/php/bin/phpize
Processing ing:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212

 
. /Configure -- with-php-config =/opt/php/bin/php-config -- with-jpeg-dir =/usr/local/jpeg -- with-png-dir =/ usr/local/libpng -- with-freetype-dir =/usr/local/freetype & make & makeinstall

5. Install zlib

Cd/tools
Tar xzvf zlib-1.2.3.tar.gz-C/usr/src/; cd/usr/src/zlib-1.2.3
./Configure -- prefix =/usr/local/zlib & make install
Cd/usr/src/php-5.5.30/ext/zlib/
Mv config0.m4 config. m4

[Root @ bkjia zlib] #/opt/php/bin/phpize
Processing ing:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212

./Configure -- with-php-config =/opt/php/bin/php-config & make & makeinstall

[Root @ bkjia zlib] # ls/opt/php/lib/php/extensions/no-debug-zts-20121212/
Gd. so opcache. so zlib. so

6. Edit the php. ini file.
Vim/opt/php/lib/php. ini

Add the following lines at the end

Extension_dir =/opt/php/lib/php/extension/ no-debug-zts-20121212/
Extension = gd. so
Extension = zlib. so

 
/Opt/php/bin/php-m

Restart the httpd service

/Usr/local/apache2/bin/apachectlrestart

7. verify whether the installation is successful
Access phpinfo in a browser to check whether the GD module and zlib module are available

Http: // youip

Php GD module and zlib module are installed successfully.

8. Build WebSite Services
We use opencart as an open-source project as a WEB site experiment.

Cd/tools
Unzip opencart-2.1.0.1.zip; cd opencart-2.1.0.1
Mv upload // usr/local/apache2/htdocs/opencart

Browser access http: // youip/opencart

Site construction is complete.

9. Set firewall

[Root @ bkjia tools] # iptables-tfilter-I INPUT-p tcp -- dport 80-j ACCEPT
[Root @ bkjia tools] # iptables-tfilter-I INPUT-p tcp -- dport 443-j ACCEPT
[Root @ bkjia tools] # iptables-tfilter-I INPUT-p tcp -- dport 22-j ACCEPT
[Root @ bkjia tools] # iptables-tfilter-I INPUT-p tcp -- dport 3306-j ACCEPT
[Root @ bkjia tools] # iptables-tfilter-P INPUT DROP
[Root @ bkjia tools] # iptables-tfilter-I INPUT-m state -- stateRELATED, ESTABLISHED

Download related attachments:

------------------------------------------ Split line ------------------------------------------

Free in http://linux.bkjia.com/

The username and password are both www.bkjia.com

The specific download directory is in/July 15, 6.7/July 27/July 27/CentOS for compiling and installing LAMP/

For the download method, see

------------------------------------------ Split line ------------------------------------------

You may also like the following LAMP-related content:

Install Xcache and Memcached on the LAMP platform to accelerate website operation

Build a LAMP platform environment in CentOS 7

CentOS 6.5 system installation and configuration LAMP (Apache + PHP5 + MySQL) server environment

Configure the LAMP + phpMyAdmin PHP (5.5.9) development environment in Ubuntu 14.04

Install LAMP in Ubuntu 14.10

LAMP combines NFS to build a small blog site

This article permanently updates the link address:

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.