Skip to content

Instantly share code, notes, and snippets.

@LeoOnTheEarth
Created June 26, 2015 07:00
Show Gist options
  • Save LeoOnTheEarth/678f0219bbc89dce4397 to your computer and use it in GitHub Desktop.
Save LeoOnTheEarth/678f0219bbc89dce4397 to your computer and use it in GitHub Desktop.
Install LNMP (Linux Nginx MongoDB PHP)
PHP_MIRROR_URL="http://tw1.php.net/get/php-5.4.9.tar.bz2/from/this/mirror"
PHP_VERSION="5.4.9"
cd /etc/yum.repos.d
echo "安裝 vi /etc/yum.repos.d/nginx.repo"
echo "[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
gpgcheck=0
enabled=1" > /etc/yum.repos.d/nginx.repo
echo "安裝 vi /etc/yum.repos.d/10gen.repo"
echo "[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1" > /etc/yum.repos.d/10gen.repo
echo "安裝基本元件"
yum -y groupinstall "Development Tools"
yum -y install \
man \
vim-enhanced \
wget \
crontabs \
telnet \
ftp \
ntpdate \
gcc \
make \
lua \
lua-devel \
lua-static \
nginx \
mongo-10gen \
mongo-10gen-server \
memcached \
mysql \
mysql-devel \
mysql-libs \
mysql-server \
libxml2-devel \
httpd-devel \
libXpm-devel \
gmp-devel \
libicu-devel \
t1lib-devel \
aspell-devel \
openssl-devel \
bzip2-devel \
libcurl-devel \
libjpeg-devel \
libvpx-devel \
libpng-devel \
freetype-devel \
readline-devel \
libtidy-devel \
libxslt-devel \
libc-client-devel
echo "複製 lua 的 source code 到 /usr/include/lua 資料夾"
mkdir /usr/include/lua
\cp /usr/include/lua.h /usr/include/lua/
\cp /usr/include/lua.hpp /usr/include/lua/
\cp /usr/include/luaconf.h /usr/include/lua/
\cp /usr/include/lualib.h /usr/include/lua/
echo "準備安裝 PHP"
mkdir ~/_build
cd ~/_build
echo "安裝 libmcrypt-devel"
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm # Verifies the package
rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm
yum --enablerepo=rpmforge -y install libmcrypt-devel htop
echo "安裝最新的 libmemcached"
cd /etc/yum.repos.d
curl http://rpms.famillecollet.com/enterprise/remi.repo > /etc/yum.repos.d/remi.repo
yum --enablerepo=remi -y install libmemcached libmemcached-devel
echo "下載 PHP source code"
echo "wget $PHP_MIRROR_URL"
cd ~/_build
wget $PHP_MIRROR_URL
tar jxf php-$PHP_VERSION.tar.bz2
mv ~/_build/php-$PHP_VERSION ~/_build/php
echo "下載 PHP lua extension source code"
cd ~/_build/php/ext
wget http://pecl.php.net/get/lua-1.0.0.tgz
tar -xf lua-1.0.0.tgz
\rm lua-1.0.0.tgz
mv lua-1.0.0 lua
echo "下載 PHP memcache extension source code"
wget http://pecl.php.net/get/memcache-3.0.6.tgz
tar -xf memcache-3.0.6.tgz
\rm memcache-3.0.6.tgz
mv memcache-3.0.6 memcache
echo "下載 PHP memcached extension source code"
wget http://pecl.php.net/get/memcached-2.0.1.tgz
tar -xf memcached-2.0.1.tgz
\rm memcached-2.0.1.tgz
mv memcached-2.0.1 memcached
echo "下載 PHP apc extension source code"
wget http://pecl.php.net/get/APC-3.1.10.tgz
tar -xf APC-3.1.10.tgz
\rm APC-3.1.10.tgz
mv APC-3.1.10 apc
echo "下載 PHP mongo extension source code"
wget http://pecl.php.net/get/mongo-1.2.10.tgz
tar -xf mongo-1.2.10.tgz
\rm mongo-1.2.10.tgz
mv mongo-1.2.10 mongo
echo "下載 PHP uploadprogress extension source code"
wget http://pecl.php.net/get/uploadprogress-1.0.3.1.tgz
tar -xf uploadprogress-1.0.3.1.tgz
\rm uploadprogress-1.0.3.1.tgz
mv uploadprogress-1.0.3.1 uploadprogress
echo "下載 PHP igbinary extension source code"
wget http://pecl.php.net/get/igbinary-1.1.1.tgz
tar -xf igbinary-1.1.1.tgz
\rm igbinary-1.1.1.tgz
mv igbinary-1.1.1 igbinary
echo "編譯 PHP 開始..."
cd ~/_build/php
\rm -rf configure autom4te.cache
./buildconf --force
./configure \
--prefix=/usr/local/php \
--with-libdir=lib64 \
--enable-fpm \
--with-layout=PHP \
--disable-short-tags \
--with-libxml-dir=/usr \
--with-openssl \
--with-kerberos \
--with-zlib \
--with-zlib-dir=/usr \
--enable-apc \
--enable-apc-filehits \
--disable-apc-pthreadmutex \
--enable-apc-spinlocks \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-curlwrappers \
--enable-exif \
--enable-ftp \
--with-gd \
--with-vpx-dir=/usr \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-xpm-dir=/usr \
--with-freetype-dir=/usr \
--with-t1lib=/usr \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-igbinary \
--enable-intl \
--with-icu-dir=/usr \
--with-lua \
--enable-mbstring \
--with-mcrypt \
--enable-memcached \
--enable-memcached-igbinary \
--enable-mongo \
--with-mysql \
--with-mysqli \
--enable-pcntl \
--with-pdo-mysql \
--with-pspell \
--with-readline \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvshm \
--with-tidy=/usr \
--enable-uploadprogress \
--with-xmlrpc \
--with-xsl \
--enable-zip \
--enable-memcache \
--enable-mysqlnd
make && make install
ln -s /usr/local/php/bin/php /usr/bin/php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment