Skip to content

Instantly share code, notes, and snippets.

@fire9
Created December 24, 2017 16:28
Show Gist options
  • Save fire9/21ebc23c18e91fd0083a3c60440a3329 to your computer and use it in GitHub Desktop.
Save fire9/21ebc23c18e91fd0083a3c60440a3329 to your computer and use it in GitHub Desktop.
centOS_LNMP环境安装

lnmp环境安装

CentOS Version Only.

关闭Selinux

# setenforce 0

setup CentOS epel repo

# CentOS 5.x 64-bit
# rpm -Uvh "http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm"
# CentOS 5.x 64-bit
# rpm -Uvh "http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"

编辑[epel]下的baseurl前的#号去掉,mirrorlist前添加#号。正确配置如下:

vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

想暂停使用EPEL,在下面的文件中设置enabled=0即可.

Runing

# yum makecache

安装和更新相关包

# yum update -y
# yum groupinstall "Development Tools" -y
# yum install -y libaio-devel mhash-devel libmcrypt-devel libxml2-devel libyaml-devel  mcrypt mhash-devel libaio libmcrypt libyaml mhash zlib-devel wget python-setuptools openssl openssl-devel openssl098e module-assistant build-essential fakeroot dh-make debconf linux-libc-dev dkms module-init-tools libpcre3-dev libbz2-dev libreadline-dev libssl-dev  libcurl4-gnutls-dev libexpat1-dev gettext libaio-dev libncurses5-dev libaio-dev libaio1 libaio1-dbg libsnmp-dev autoconf snmp snmpd libsasl2-dev curl git-core python-software-properties libssl-dev libreadline6-dev libyaml-dev libpng++-dev libjpeg62-dev libfreetype6-dev libmcrypt-dev libxml2-dev libmhash-dev mcrypt libopenipmi-dev libgsnmp0-dev libssl-dev screen vim libmcrypt-devel.x86_64 libmcrypto-devel.x86_64 libmcrypt.x86_64 libmcrypto.x86_64 libxml2-devel.x86_64 libcurl-devel.x86_64 mhash-devel.x86_64 mhash.x86_64 mcrypt.x86_64 gcc gcc-c++  flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libtiff-devel pam-devel openssl-devel gettext-devel pcre-devel zlib-devel glibc-devel curl-devel libidn-devel openssl-devel net-snmp-devel rpm-devel OpenIPMI-devel libpng-devel.x86_64  libjpeg-turbo-devel.x86_64 freetype-devel.x86_64 fontconfig-devel.x86_64 libXpm-devel.x86_64 libxslt-devel.x86_64 libpng-devel.x86_64 libXpm-devel.x86_64 freetype-devel.x86_64 libjpeg-turbo-devel.x86_64 fontconfig-devel.x86_64 readline-devel.x86_64 valgrind-devel.x86_64 libicu-devel.x86_64 perl-CPAN.x86_64 ImageMagick-devel.x86_64 libicu-devel.x86_64 re2c.x86_64 

下载相关软件

# wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
# wget https://www.kernel.org/pub/software/scm/git/git-manpages-2.0.2.tar.gz
# wget https://www.kernel.org/pub/software/scm/git/git-2.0.2.tar.gz
# wget http://luajit.org/download/LuaJIT-2.0.3.tar.gz
# wget http://www.percona.com/redir/downloads/Percona-Server-5.5/Percona-Server-5.5.33-31.1/binary/linux/x86_64/Percona-Server-5.5.33-rel31.1-566.Linux.x86_64.tar.gz
# wget http://tengine.taobao.org/download/tengine-2.0.3.tar.gz
# wget https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
# wget http://download.redis.io/releases/redis-2.8.9.tar.gz
# wget http://downloads.sourceforge.net/pcre/pcre-8.35.tar.bz2
# wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
# wget http://mirrors.sohu.com/php/php-5.3.28.tar.gz
# git clone https://github.com/simpl/ngx_devel_kit.git
# git clone https://github.com/agentzh/set-misc-nginx-module.git
# git clone https://github.com/chaoslawful/lua-nginx-module.git
# git clone https://github.com/agentzh/headers-more-nginx-module.git
# git clone https://github.com/agentzh/echo-nginx-module.git
# git clone https://github.com/pagespeed/ngx_pagespeed.git
# cd ngx_pagespeed
# wget https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
# tar -xzvf 1.8.31.4.tar.gz # expands to psol/
# cd ../

创建相关用户

# groupadd www
# useradd -g www -s /sbin/nologin -d /dev/null www
# groupadd mysql
# useradd -g mysql -s /sbin/nologin -d /dev/null mysql

安装相关程序

Install PCRE

# tar zxvf pcre-8.3.5.tar.gz
# cd pcre-8.3.5
# ./configure --enable-pcre16 --enable-pcre32 --enable-jit --enable-rebuild-chartables --enable-utf8 # --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-pcretest-libreadline --enable-valgrind
# cd ../

Install Jemalloc

# tar jxvf jemalloc-3.6.0.tar.bz2
# cd jemalloc-3.6.0
# ./configure --prefix=/usr/local/jemalloc --enable-ivsalloc --enable-mremap -enable-xmalloc -enable-lazy-lock
# make
# make install
# cd ../

Install LuaJIT

# tar zxvf LuaJIT-2.0.3.tar.gz
# cd LuaJIT-2.0.3
# make
# make install
# cd ../
# echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
# echo "export LUAJIT_LIB=/usr/local/lib/"  >> /etc/profile
# echo "export LUAJIT_INC=/usr/local/include/luajit-2.0/" >> /etc/profile

Install Percona MySQL Server

# tar zxvf Percona-Server-5.5.33-rel31.1-566.Linux.x86_64 -C /usr/local/
# cd /usr/local/
# ln -s Percona-Server-5.5.33-rel31.1-566.Linux.x86_64/ mysql
# cd mysql/
# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb/
# chown -R root .
# chgrp -R mysql .
# chown -R mysql:mysql /data/mysqldb
# cd support-files/
# cp mysql.server /etc/init.d/mysql
# cd lib/
# cp -r -p -a * /usr/lib64/
# cp -r -p -a * /usr/local/lib64/
# cd ../include/
# cp -r -p -a * /usr/include/
# cp -r -p -a * /usr/local/include/
# cd ../

Install redis

# tar -xzvf redis-2.8.9.tar.gz
# cd redis-2.8.9
# make && make install
# cp redis.conf /etc/
# cd ../
# redis-server /etc/redis.conf

Install Php5.2.28

# tar zxvf php-5.3.28.tar.gz
# cd php-5.3.28/
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc  --with-iconv-dir # --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml # --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-fpm --with-snmp --with-gettext --enable-zend-multibyte --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-snmp --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd
# make
# make install
# cp php.ini-production /usr/local/php/etc/php.ini
# cd ../

Install eaccelerator

git clone https://github.com/eaccelerator/eaccelerator.git
cd eaccelerator/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
mkdir /usr/local/eaccelerator_cache

Install redis client

# git clone https://github.com/nrk/phpiredis.git
# git clone https://github.com/redis/hiredis.git
# cd hiredis && make && make install && cd ../
# cd phpiredis
# /usr/local/php/bin/phpize
# ./configure  --with-php-config=/usr/local/php/bin/php-config --enable-phpiredis
# make && make install
# cd ../

Install Tengine

# tar zxvf tengine-2.0.3.tar.gz
# cd tengine-2.0.3
# ./configure --prefix=/usr/local/nginx --with-file-aio  --with-http_spdy_module  --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_slice_module  --with-http_gunzip_module --with-http_gzip_static_module --with-http_concat_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module   --with-http_sysguard_module --with-http_lua_module  --with-pcre --with-jemalloc --add-module=../echo-nginx-module --add-module=../headers-more-nginx-module --add-module=../ngx_devel_kit --add-module=../ngx_pagespeed --add-module=../set-misc-nginx-module
# make && make install && cd ../

安装监控代理

new relic 安装

# rpm -Uvh http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
# yum install newrelic-sysmond
# nrsysmond-config --set license_key=5ac06948039f8f91a52004905a4e34acf7f3b7f7
# /etc/init.d/newrelic-sysmond start

About

if don't find libmcrypt library.

# rpm -ivh http://pkgs.repoforge.org/libmcrypt/libmcrypt-2.5.7-1.2.el6.rf.x86_64.rpm
# rpm -ivh http://pkgs.repoforge.org/libmcrypt/libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment