CentOS6 compile and install LNMP

Source: Internet
Author: User
Tags mcrypt zts

# Manually install lnmp
Include libiconv libunwind gperftools libmcrypt mhash mcrypt libpng freetype jpeg
Gd pcre libmemcached php_memcached (memcached. so) eaccelerator ZendOptimizer
Mysql5.5 php5.3 nginx1.2.7 memcached tokyocabinet tokyotyrant
# Path
Program storage/data/service
Lib or common/data/service/common
Data storage/data
Log storage/data/logs


# Yum source change
Rm-f CentOS6-Base-163.repo \
Rm-f/etc/yum. repos. d/CentOS6-Base-163.repo
Yum install-y wget
Wget-4 -- no-cache http://mirrors.163.com/.help/CentOS6-Base-163.repo \
-O/etc/yum. repos. d/CentOS6-Base-163.repo


Mv/etc/yum. repos. d/CentOS-Base.repo/etc/yum. repos. d/CentOS-Base.repo.bak


Yum makecache & yum update-y & rm-f/etc/yum. repos. d/CentOS-Base.repo


Yum install ntp wget cpp gcc-c ++ gcc-g77 make unzip libtool \
Libtool-ltdl-devel libc-client-devel libstdc ++-devel db4-utils libcap-devel \
Expat-devel perl pam-devel perl-Time-HiRes libaio-devel bzr patches bzip2-devel \
Cmake bison libevent-devel ncurses-devel openssl-devel zlib-devel curl-devel \
Libxml2-devel tcp_wrappers-devel nasm lemon flex libXpm-devel fontconfig-devel \
Pcre-devel sqlite-devel perl-ExtUtils-Embed neon-devel


# Libiconv
./Configure
Make & make install
Echo "/usr/local/lib" >> \
/Etc/ld. so. conf. d/service_lib.conf &/sbin/ldconfig


# Libunwind
CFLAGS =-fPIC./configure
Make CFLAGS =-fPIC & make CFLAGS =-fPIC install


# Gperftools
./Configure -- enable-frame-pointers
Make & make install
/Sbin/ldconfig


# Mysql 5.5
Groupadd mysql-g 1002
Useradd mysql-u 1002-g mysql-s/sbin/nologin


Rm-f CMakeCache.txt
Cmake \
.-DCMAKE_INSTALL_PREFIX =/data/service/mysql \
-DMYSQL_DATADIR =/data/mysql \
-DSYSCONFDIR =/data/service/mysql/etc \
-DMYSQL_UNIX_ADDR =/tmp/mysql. sock \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_FEDERATED_STORAGE_ENGINE = 1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 \
-DWITH_EXAMPLE_STORAGE_ENGINE = 1 \
-DWITH_PARTITION_STORAGE_ENGINE = 1 \
-DWITH_ARCHIVE_STORAGE_ENGINE = 1 \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE = 1 \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_EXTRA_CHARSETS = all \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_TCP_PORT = 3306 \
-DWITH_DEBUG = 0
Make & make install


Ln-s/data/service/mysql/lib/data/service/mysql/lib64
Echo "/data/service/mysql/lib64/" >> \
/Etc/ld. so. conf. d/service_lib.conf &/sbin/ldconfig
Mkdir-p/data/service/mysql/etc & mkdir-p/data/mysql
Cp-f support-files/my-medium.cnf/data/service/mysql/etc/my. cnf
# Add gperftools
Sed-I's/executing \ mysqld_safe $/& \ nexport \ LD_PRELOAD = "\/usr \/local \/lib \/libtcmalloc. so "/'\
/Data/service/mysql/bin/mysqld_safe


Cp-f support-files/mysql. server/data/service/mysql/mysqld
Chmod 755/data/service/mysql/mysqld
Chown-R mysql. mysql/data/mysql


Vim/data/service/mysql/etc/my. cnf
[Mysqld]
Pid-file =/data/mysql/mysqld. pid
Datadir =/data/mysql


Max_connections = 500
Max_connect_errorrs = 10000
Slow_query_log = 1
Slow_query_log_file =/data/mysql/slowsql. log
Long_query_time = 2
Log-queries-not-using-indexes


Innodb_file_per_table = 1
Innodb_data_home_dir =/data/mysql
Innodb_data_file_path = ibdata1: 10 M: autoextend: max: 2000 M
Innodb_log_group_home_dir =/data/mysql
Innodb_file_per_table = 1
Innodb_buffer_pool_size = 256 M
Innodb_additional_mem_pool_size = 2 M
Innodb_log_buffer_size = 8 M
Innodb_log_file_size = 256 M
Innodb_log_files_in_group = 3
Sync_binlog = 1
Innodb_flush_log_at_trx_commit = 0
Innodb_lock_wait_timeout = 50


Log-bin = mysql-bin
Binlog_format = mixed
Expire_logs_days = 7


[Mysqld_safe]
Log-error =/data/mysql. log


/Data/service/mysql/scripts/mysql_install_db \
-- User = mysql -- basedir =/data/service/mysql -- datadir =/data/mysql


# Mysql5.1
./Configure \
-- Prefix =/data/service/mysql \
-- Localstatedir =/data/mysql \
-- Sysconfdir =/data/service/mysql/etc \
-- With-mysqld-user = mysql \
-- Without-debug \
-- With-big-tables \
-- With-unix-socket-path =/tmp/mysql. sock \
-- With-charset = gbk \
-- With-collation = gbk_chinese_ci \
-- With-extra-charsets = all \
-- With-plugins = partition \
-- Enable-static \
-- With-client-ldflags =-all-static \
-- With-tcp-port = 3306


/Data/service/mysql/mysqld start
/Data/service/mysql/mysqld restart
#/Data/service/mysql/bin/mysqladmin-uroot password
/Data/service/mysql/mysqld stop


# Libmcrypt
./Configure -- prefix =/data/service/common/libmcrypt
Make & make install
Ln-s/data/service/common/libmcrypt/lib/data/service/common/libmcrypt/lib64
Echo "/data/service/common/libmcrypt/lib64" >> \
/Etc/ld. so. conf. d/service_lib.conf & ldconfig


# Mhash
./Configure -- prefix =/data/service/common/mhash
Make & make install
Ln-s/data/service/common/mhash/lib/data/service/common/mhash/lib64
Echo "/data/service/common/mhash/lib64" >> \
/Etc/ld. so. conf. d/service_lib.conf & ldconfig


# Mcrypt
# LD_LIBRARY_PATH =/data/service/common/libmcrypt/lib:/data/service/common/mhash/lib \
LDFLAGS = "-L/data/service/common/mhash/lib/-I/data/service/common/mhash/include /"\
CFLAGS = "-I/data/service/common/mhash/include /"\
./Configure -- prefix =/data/service/common/mcrypt \
-- With-libmcrypt-prefix =/data/service/common/libmcrypt
Make & make install
Ln-s/data/service/common/mcrypt/lib/data/service/common/mcrypt/lib64
Echo "/data/service/common/mcrypt/lib64" >> \
/Etc/ld. so. conf. d/service_lib.conf & ldconfig


# Libpng
# In the following sentence, the test cannot be executed. Otherwise, the following error is reported and cannot be installed under/usr/lib/libpng /.
# Cp scripts/makefile. linux makefile
./Configure -- prefix =/data/service/common/libpng -- enable-shared -- enable-static
Make & make install
Ln-s/data/service/common/libpng/lib/data/service/common/libpng/lib64
Echo "/data/service/common/libpng/lib64" >> \
/Etc/ld. so. conf. d/service_lib.conf & ldconfig


# Freetype
./Configure -- prefix =/data/service/common/freetype -- enable-shared -- enable-static
Make & make install
Ln-s/data/service/common/freetype/lib/data/service/common/freetype/lib64
Echo "/data/service/common/freetype/lib64" >> \
/Etc/ld. so. conf. d/service_lib.conf & ldconfig


# Libjpeg
./Configure -- prefix =/data/service/common/libjpeg -- enable-shared -- enable-static
Make & make install
Ln-s/data/service/common/libjpeg/lib/data/service/common/libjpeg/lib64
Echo "/data/service/common/libjpeg/lib64" >> \
/Etc/ld. so. conf. d/service_lib.conf & ldconfig


# Gd
Yum install libXpm-devel fontconfig-devel
PATH =/data/service/common/libpng/bin/: $ PATH \
LDFLAGS = "-L/data/service/common/libpng/lib /"\
CFLAGS = "-I/data/service/common/libpng/include /"\
./Configure -- prefix =/data/service/common/gd \
-- Enable-shared -- enable-static \
-- With-png =/data/service/common/libpng \
-- With-freetype =/data/service/common/freetype \
-- With-jpeg =/data/service/common/libjpeg
Make & make install
Ln-s/data/service/common/gd/lib/data/service/common/gd/lib64
Echo "/data/service/common/gd/lib64" >> \
/Etc/ld. so. conf. d/service_lib.conf & ldconfig


# Pcre
./Configure -- prefix =/data/service/common/pcre \
-- Enable-shared -- enable-static
Make & make install
Ln-s/data/service/common/pcre/lib/data/service/common/pcre/lib64
Echo "/data/service/common/pcre/lib64" >> \
/Etc/ld. so. conf. d/service_lib.conf & ldconfig


# Php5.3
./Configure \
-- Prefix =/data/service/phpfpm \
-- With-config-file-path =/data/service/phpfpm/etc \
-- With-libdir = lib64 \
-- With-mysql = mysqlnd \
-- With-mysqli = mysqlnd \
-- With-pdo-mysql = mysqlnd \
-- With-mcrypt =/data/service/common/libmcrypt \
-- With-mhash =/data/service/common/mhash \
-- With-gd =/data/service/common/gd \
-- With-pcre-dir =/data/service/common/pcre \
-- With-freetype-dir =/data/service/common/freetype \
-- With-jpeg-dir =/data/service/common/libjpeg \
-- With-png-dir =/data/service/common/libpng \
-- With-openssl \
-- With-zlib \
-- With-curl \
-- With-curlwrappers \
-- With-xmlrpc \
With-bz2 \
-- With-gettext \
-- With-xpm-dir \
-- Enable-fpm \
-- Enable-ftp \
-- Enable-sockets \
-- Enable-xml \
-- Enable-bcmath \
-- Enable-shmop \
-- Enable-sysvsem \
-- Enable-inline-optimization \
-- Enable-mbregex \
-- Enable-mbstring \
-- Enable-gd-native-ttf \
-- Enable-sockets \
-- Enable-zip \
-- Enable-soap \
-- Enable-pcntl \
-- Disable-rpath


Make & make install
Mkdir-p/data/service/phpfpm/etc
Cp-f php. ini-production/data/service/phpfpm/etc/php. ini
Sed-I '$ a \ nextension_dir = "/data/service/phpfpm/lib/php/extensions/no-debug-non-zts-20090626 /"'\
/Data/service/phpfpm/etc/php. ini


# Php5.2
Http://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz wget-4
./Configure -- prefix =/data/service/common/autoconf_2.13 \
Make & make install


Http://cn2.php.net/distributions/php-5.2.17.tar.gz wget-4
Http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz wget-4
Https://raw.github.com/laruence/laruence.github.com/master/php-5.2-max-input-vars/php-5.2.17-max-input-vars.patch wget-4
Gzip-d php-5.2.17-fpm-0.5.14.diff.gz
Tar zxf php-5.2.17.tar.gz
Cd php-5.2.17
Patch-p1 <../php-5.2.17-fpm-0.5.14.diff
Patch-p1 <../php-5.2.17-max-input-vars.patch
Rm-rf configure \
& PHP_AUTOCONF = "/data/service/common/autoconf_2.13/bin/autoconf "\
PHP_AUTOHEADER = "/data/service/common/autoconf_2.13/bin/autoheader "\
./Buildconf -- force


./Configure -- prefix =/data/service/phpfpm_52 \
-- With-config-file-path =/data/service/phpfpm_52/etc \
-- With-libdir = lib64 \
-- With-mysql =/data/service/mysql \
-- With-mysqli =/data/service/mysql/bin/mysql_config \
-- With-pdo-mysql =/data/service/mysql \
-- With-mcrypt =/data/service/common/libmcrypt \
-- With-mhash =/data/service/common/mhash \
-- With-gd =/data/service/common/gd \
-- With-freetype-dir =/data/service/common/freetype \
-- With-jpeg-dir =/data/service/common/libjpeg \
-- With-png-dir =/data/service/common/libpng \
-- With-openssl \
-- With-zlib \
-- With-curl \
-- With-curlwrappers \
-- With-xmlrpc \
With-bz2 \
-- With-xpm-dir \
-- Enable-fpm \
-- Enable-fastcgi \
-- Enable-force-cgi-redirect \
-- Enable-ftp \
-- Enable-sockets \
-- Enable-xml \
-- Enable-bcmath \
-- Enable-shmop \
-- Enable-inline-optimization \
-- Enable-mbregex \
-- Enable-mbstring \
-- Enable-gd-native-ttf \
-- Enable-sockets \
-- Enable-zip \
-- Enable-soap \
-- Enable-pcntl \
-- Disable-rpath
Make & make install
Mkdir-p/data/service/phpfpm_52/etc
Cp-f php. ini-recommended/data/service/phpfpm_52/etc/php. ini
Cp sapi/cgi/fpm/php-fpm/data/service/phpfpm_52/bin/php-fpm & chmod 755/data/service/phpfpm_52/bin/php-fpm
Sed-I '$ a \\ nextension_dir = "/data/service/phpfpm_52/lib/php/extensions/no-debug-non-zts-20060613/"'/data/service/phpfpm_52/etc/php. ini
Short_open_tag = On


# Memcached/tar.gz
./Configure -- prefix =/data/service/memcached
Make & make install


# Libmemcached
./Configure -- prefix =/data/service/common/libmemcached \
-- With-memcached =/data/service/memcached
Make & make install
Ln-s/data/service/common/libmemcached/lib/data/service/common/libmemcached/lib64


# Memcache. so/tgz php_memcache
/Data/service/phpfpm/bin/phpize \
&./Configure \
-- Enable-memcache \
-- With-php-config =/data/service/phpfpm/bin/php-config
Make & make install
Sed-I '$ a \; extension = memcache. so'/data/service/phpfpm/etc/php. ini
# Php5.2
/Data/service/php/bin/phpize \
&./Configure \
-- Enable-memcache \
-- With-php-config =/data/service/php/bin/php-config
Make & make install
Sed-I '$ a \; extension = memcache. so'/data/service/php/etc/php. ini


# Memcached. so/tgz zlib/php_memcached
/Data/service/php/bin/phpize \
&./Configure \
-- With-php-config =/data/service/php/bin/php-config \
-- Enable-memcached \
-- With-libmemcached-dir =/data/service/common/libmemcached
Make & make install
Sed-I '$ a \ extension = memcached. so'/data/service/php/etc/php. ini
Sed-I "s # session. save_handler \=\ files #; session. save_handler \=\ files # g"/data/service/phpfpm/etc/php. ini
Sed-I '$ a \; session. save_handler = memcached \ n; session. save_path = "ip: port"'/data/service/phpfpm/etc/php. ini
# Php5.2
/Data/service/phpfpm_52/bin/phpize \
&./Configure \
-- With-php-config =/data/service/phpfpm_52/bin/php-config \
-- Enable-memcached \
-- With-libmemcached-dir =/data/service/common/libmemcached
Make & make install
Sed-I '$ a \ extension = memcached. so'/data/service/phpfpm_52/etc/php. ini
Sed-I "s # session. save_handler \=\ files #; session. save_handler \=\ files # g"/data/service/phpfpm_52/etc/php. ini
Sed-I '$ a \; session. save_handler = memcached \ n; session. save_path = "ip: port"'/data/service/phpfpm_52/etc/php. ini


# Eaccelerator
/Data/service/phpfpm/bin/phpize \
&./Configure \
-- Enable-eaccelerator = shared \
-- With-php-config =/data/service/phpfpm/bin/php-config
Make & make install
Sed-I '$ a \; extension = eaccelerator. so'/data/service/phpfpm/etc/php. ini
# Php5.2
/Data/service/php/bin/phpize \
&./Configure \
-- Enable-eaccelerator = shared \
-- With-php-config =/data/service/php/bin/php-config
Make & make install
Sed-I '$ a \; extension = eaccelerator. so'/data/service/php/etc/php. ini


# APC
/Data/service/phpfpm/bin/phpize \
&./Configure \
-- Enable-eaccelerator = shared \
-- With-php-config =/data/service/phpfpm/bin/php-config
Make & make install
Sed-I '$ a \; extension = eaccelerator. so'/data/service/phpfpm/etc/php. ini


# ZendGuardLoader php5.3
Cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader. so \
/Data/service/phpfpm/lib/php/extensions/no-debug-non-zts-20090626/
Sed-I '$ a \ n \; [Zend] \ n; zend_extension = "/data/service/phpfpm/lib/php/extensions/no-debug-non-zts-20090626/ZendGuardLoader. so "\ n; zend_loader.enable = 1 \ n; zend_loader.disable_licensing = 0 \ n; token = 3 \ n; zend_loader.license_path = \ n'/data/service/phpfpm/etc/php. ini


# ZendOptimizer php5.2
Cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer. so/data/service/phpfpm_52/lib/php/extensions/no-debug-non-zts-20060613/
Sed-I '$ a \ n \; [Zend] \ n; zend_extension = "/data/service/phpfpm_52/lib/php/extensions/no-debug-non-zts-20060613/ZendOptimizer. so "\ n; zend_loader.enable = 1 \ n; zend_loader.disable_licensing = 0 \ n; token = 3 \ n; zend_loader.license_path = \ n'/data/service/phpfpm_52/etc/php. ini


# Nginx
Groupadd www-g 1001
Useradd www-u 1001-g www-s/sbin/nologin


./Configure \
-- Prefix =/data/service/nginx \
With-http_stub_status_module \
-- With-pcre = ../pcre-8.32 \
With-http_ssl_module \
With-google_perftools_module
Make & make install


# Vsftpd
Vi defs. h
Set/etc/vsftpd. conf/data/service/vsftpd/etc/vsftpd. conf
Vi builddefs. h
Change # undef VSF_BUILD_TCPWRAPPERS to # define VSF_BUILD_TCPWRAPPERS
Change # undef VSF_BUILD_SSL to # define VSF_BUILD_SSL
Make


Mkdir-p/data/service/vsftpd/sbin/data/service/vsftpd/man/data/service/vsftpd/etc/virtual
Cp vsftpd/data/service/vsftpd/sbin/vsftpd \
& Chmod 755/data/service/vsftpd/sbin/vsftpd
Cp vsftpd.8/data/service/vsftpd/man/vsftpd.8 \
& Chmod 644/data/service/vsftpd/man/vsftpd.8
Cp vsftpd. conf.5/data/service/vsftpd/man/vsftpd. conf.5 \
& Chmod 644/data/service/vsftpd/man/vsftpd. conf.5
Cp vsftpd. conf/data/service/vsftpd/etc/vsftpd. conf. default \
& Chmod 644/data/service/vsftpd/etc/vsftpd. conf. default
Cp RedHat/vsftpd. pam/data/service/vsftpd/etc/vsftpd. pam \
& Chmod 644/data/service/vsftpd/etc/vsftpd. pam
Echo-e "user \ npassword \ n">/data/service/vsftpd/etc/user_pass
Echo "user">/data/service/vsftpd/etc/user_list
Echo "/usr/bin/db_load-T-t hash-f/data/service/vsftpd/etc/user_pass/data/service/vsftpd/etc/login. db "\
>/Data/service/vsftpd/sbin/pass. sh
Chmod 755/data/service/vsftpd/sbin/pass. sh
Echo "auth required/lib64/security/pam_userdb.so db =/data/service/vsftpd/etc/login">/etc/pam. d/vsftpd
Echo "account required/lib64/security/pam_userdb.so db =/data/service/vsftpd/etc/login">/etc/pam. d/vsftpd


# Tokyo cabinet
./Configure -- prefix =/data/service/common/tokyocabinet
Make & make install
# Tokyo tyrant
./Configure -- prefix =/data/service/tokyotyrant -- with-tc =/data/service/common/tokyocabinet
Make & make install
/Data/service/tokyotyrant/bin/ttserver-port 11213-thnum 8-dmn-pid/data/ttdb/ttserver. pid-log/data/ttdb/ttserver. log-le-ulog/data/ttdb/-ulim 256 m-sid 1-rts/data/ttdb/ttserver. rts/data/ttdb/database. tcb # lmemb = 1024 # nmemb2048 # bnum0000000


/Data/service/memcached/bin/memcached-d-u www-c 64-p 11212

Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04

Build and install the LNMP production environment in CentOS 6.4

Practical Production Environment-LNMP architecture compilation and installation + SSL encryption implementation

LNMP full-featured compilation and installation for CentOS 6.3 notes

Install LNMP in CentOS 6.3 (PHP 5.4, MyySQL5.6)

Nginx startup failure occurs during LNMP deployment.

Ubuntu install Nginx php5-fpm MySQL (LNMP environment setup)

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.