lnmp平臺搭建

 安裝包以及腳本地址

http://pan.baidu.com/share/link?shareid=56760&uk=3341197103

#!/bin/bash

##############################指定安裝路徑#############################

path_mysql=/usr/local/mysql

path_php=/usr/local/php

path_nginx=/usr/local/nginx

path_log=/var/log #####log統一制定到/var/log目錄下

########################################################  準備 ##############################################

mkdir /etc/yum.repos.d/backup

mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/

touch /etc/yum.repos.d/ftp.repo

echo -ne "[base]\nname=Server\nbaseurl=ftp://192.168.1.233/pub/yum/CentOS\ngpgcheck=0 " > /etc/yum.repos.d/ftp.repo

########################將YUM源修改成本地FTP源############################

yum -y install gcc gcc-c++ screen autoconf automake libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libtiff libtiff-devel gettext gettext-devel pam pam-devel fontconfig-devel libXpm-devel libtool ncurses-devel flex bison 

groupadd mysql

useradd -g mysql mysql

mkdir $path_log/nginx

mkdir $path_log/mysql

mkdir $path_log/php

###########創建LOG存放目錄##################

chown -R mysql:mysql $path_log/mysql

cd /tmp/lnmp

rpm -ivh perl-DBI-1.52-2.el5.x86_64.rpm mysql-devel-5.0.77-4.el5_6.6.x86_64.rpm --force --nodeps

##########################################################  一些依賴包的安裝##########################################

#cd /tmp/lnmp

tar -zxvf libiconv-1.14.tar.gz 

cd libiconv-1.14

make clean

./configure --prefix=/usr/local

make

make install

cd ..

tar -zxvf libmcrypt-2.5.7.tar.gz 

cd libmcrypt-2.5.7

make clean

./configure

make

make install

/sbin/ldconfig 

cd libltdl/

./configure --enable-ltdl-install

make 

make install

cd ../..

tar -jxvf mhash-0.9.9.9.tar.bz2

cd mhash-0.9.9.9

make clean

./configure

make

make install

cd ..

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

ln -s /usr/local/lib/libmcrypt.so.4.4.7 /usr/lib/libmcrypt.so.4.4.7

ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a

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

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

cp /tmp/lnmp/mhash-0.9.9.9/mhash-config.h /usr/local/include/

tar -zxvf mcrypt-2.6.4.tar.gz 

cd mcrypt-2.6.4

make clean

/sbin/ldconfig 

./configure

make

make install

cd ..

####################################   mysql安裝 ################

#cd /tmp/lnmp

mkdir -p /data/mysql/var

tar -zxvf Percona-Server-5.1.58.tar.gz

cd Percona-Server-5.1.58/

make clean

./configure --prefix=$path_mysql --localstatedir=/data/mysql/var  --with-charset=utf8 --with-extra-charsets=complex --with-pthread --enable-thread-safe-client --with-ssl --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-plugins=partition,federated,innobase,csv,myisam,innodb_plugin --enable-shared --enable-assembler

make && make install

rm -f /etc/my.cnf

cp /support-files/my-medium.cnf.sh /etc/my.cnf 

sed -i "s!myisam_sort_buffer_size = 8M!\nlog-error =$path_log/mysql/mysql_error.log \nlog-bin=$path_log/mysql/binlog \nbasedir=$path_mysql \ndatadir=/data/mysql/var!" /etc/my.cnf

#####################修改MYSQL配置文件############################

cp support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

ln -s $path_mysql/bin/* /usr/local/bin/

ln -s $path_mysql/lib/mysql/lib* /usr/lib/

chown -R root.mysql $path_mysql

chown -R mysql.mysql $path_mysql/var

chown -R mysql.mysql /data/mysql

$path_mysql/bin/mysql_install_db --basedir=$path_mysql --datadir=/data/mysql/var/ --user=mysql &

service mysqld start

cd ..

##################################  PHP安裝#################

tar -jxvf php-5.4.4.tar.bz2

gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.4.4 -p1

cd ./php-5.4.4/

make clean

./configure --prefix=$path_php --with-config-file-path=$path_php/etc --with-mysql=$path_mysql --with-mysqli=$path_mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap

make ZEND_EXTRA_LIBS='-liconv'

make install

cp php.ini-production $path_php/etc/php.ini 

cp $path_php/etc/php-fpm.conf.default $path_php/etc/php-fpm.conf 

ln -s $path_php/bin/php /usr/bin/

#####################################   PHP擴展包安裝############################

cd ..

tar -zxvf memcache-2.2.5.tgz 

cd memcache-2.2.5

make clean

$path_php/bin/phpize

./configure --with-php-config=$path_php/bin/php-config

make

make install

cd ..

ln -s $path_mysql/include/mysql/* /usr/local/include/

tar -zxvf PDO_MYSQL-1.0.2.tgz 

cd PDO_MYSQL-1.0.2

make clean

$path_php/bin/phpize

./configure --with-php-config=$path_php/bin/php-config --with-pdo-mysql=$path_mysql

make 

make install

cd ..

tar -jxvf ImageMagick-6.7.9-3.tar.bz2

cd ImageMagick-6.7.9-3

make clean

./configure --prefix=/usr/local/ImageMagick

make

make install

yum -y install gtk+-devel

export PKG_CONFIG_PATH=/usr/local/ImageMagick/lib/pkgconfig/

cd ..

tar -zxvf imagick-3.1.0RC2.tgz

cd imagick-3.1.0RC2

make clean

$path_php/bin/phpize

./configure --with-php-config=$path_php/bin/php-config --with-imagick=/usr/local/ImageMagick

make

make install

cd ..

sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\nextension = "imagick.so"\n#' $path_php/etc/php.ini

sed -i 's#output_buffering = Off#output_buffering = On#' $path_php/etc/php.ini

sed -i "s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g" $path_php/etc/php.ini

sed -i "s#; cgi.fix_pathinfo=0#cgi.fix_pathinfo=0#g" $path_php/etc/php.ini

sed -i 's#extension_dir = "./"#extension_dir =  "/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/"\nextension = "memcache.so"\nextension = 

"pdo_mysql.so"\nextension = "imagick.so"\n#' $path_php/etc/php.ini

sed -i 's#output_buffering = Off#output_buffering = On#' $path_php/etc/php.ini

sed -i "s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g" $path_php/etc/php.ini

sed -i "s#; cgi.fix_pathinfo=0#cgi.fix_pathinfo=0#g" $path_php/etc/php.ini

##########################################  nginx安裝###############

tar -zxvf pcre-8.10.tar.gz

cd pcre-8.10/

make clean

./configure

make && make install

cd ../

tar -zxvf nginx-1.2.1.tar.gz 

cd ./nginx-1.2.1/

./configure --prefix=$path_nginx --with-http_stub_status_module --with-http_ssl_module

make && make install

touch $path_nginx/html/index.php

echo -ne "<?php\nphpinfo();\n?>" > $path_nginx/html/index.php

sed -i "s/index.html index.htm;/index.php &/" $path_nginx/conf/nginx.conf

sed -i "47 a#\nlocation ~ \\\.php$ {\nfastcgi_pass 127.0.0.1:9000;\nfastcgi_index index.php;\nfastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/\$fastcgi_script_name;\ninclude fastcgi_params;\ninclude fastcgi.conf;}#" $path_nginx/conf/nginx.conf

echo "$path_nginx/sbin/nginx" >> /etc/rc.d/rc.local

#####################################  啓動   ###########################

killall nginx

killall php-fpm

$path_php/sbin/php-fpm

$path_nginx/sbin/nginx

本文是基於張宴版本的LNMP的修改版

張宴LNMP博客http://blog.s135.com/nginx_php_v6/

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章