程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> PHP基礎知識 >> 一鍵安裝lnmp環境腳本

一鍵安裝lnmp環境腳本

編輯:PHP基礎知識
 

◾安裝包的准備(nginx,mysql,php,以用所需的其他包),本例采用直接用rsync同步包服務器上的安裝包使用命令#rsync -auqz rsync-server::soft/lnmp /usr/local/src同步到本地的/usr/local/src/lnmp目錄下.
◾編寫安裝腳本 ~/sh/lnmp.sh
#!/bin/bash
cd /usr/local/src/lnmp#安裝mysql
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
tar xzvf mysql-5.1.31.tar.gz
cd mysql-5.1.31/
./configure --prefix=/usr/local/mysql --with-extra-charset=all --without-isam --exec-prefix=/usr/local/mysql --localstatedir=/usr/lo
cal/mysql/var --sysconfdir=/usr/local/mysql/etc --with-tcp-port=3306 --with-innodb --with-partition
make
make install
cd /usr/local/mysql/
chown -R mysql .
chgrp -R mysql .
cd /usr/local/src/lamp/mysql-5.1.31/support-files
cp my-medium.cnf /etc/my.cnf
sed -i 's/skip-federated/#skip-federated/g' /etc/my.cnf#注釋一個選項
chown -R mysql:mysql var
chmod 755 var
cd /usr/local/src/lamp/sql-5.1.31/support-files/
cp mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
rm -rf /usr/local/mysql/var/*
/usr/local/mysql/bin/mysql_install_db --user=mysql
service mysqld start

#安裝nginx
cd /usr/local/src/lnmp
/usr/sbin/groupadd www
/usr/sbin/useradd -g www -d /dev/null -s /sbin/nologin www
tar zxvf pcre-8.00.tar.gz
cd pcre-8.00
./configure
make
make install
cd ../
mkdir -p /var/log/nginx
chmod +w /var/log/nginx
chown -R www:www /var/log/nginx
tar zxvf nginx-0.6.37.tar.gz
cd nginx-0.6.37
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-openssl=/usr/local
make
make install
make clean
rm -rf /usr/local/nginx/conf/nginx.conf
rm -rf /etc/init.d/nginx
cp /root/sh/nginx.conf /usr/local/nginx/conf/nginx.conf
cp /root/sh/nginx /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
service nginx start
service nginx test
service nginx reload
cd ../
tar -xzvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install
cd ../
tar -xzvf libpng-1.2.8-config.tar.gz
cd libpng-1.2.8-config
mkdir -p /usr/local/libpng
./configure --prefix=/usr/local/libpng
make
make install
cd ../
tar -xzvf freetype-2.1.10.tar.gz
cd freetype-2.1.10
./configure --prefix=/usr/local/freetype
make
make install
cd ../
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
CFLAGS="-O3 -fPIC" ./configure
make
make install-lib
cd ../tar -xzvf libxml2-2.7.6.tar.gz
cd libxml2-2.7.6
mkdir -p /usr/local/libxml2
./configure --prefix=/usr/local/libxml2
make
make install
cp xml2-config /usr/bin
cd ../
tar -xzvf gd-2.0.33.tar.gz
cd gd-2.0.33
mkdir -p /usr/local/gd
./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6 --with-freetype=/usr/local/freetype --with-png=/usr/local/libpng --w
ith-zlib=/usr/local/zlib
make
make install
cd ../

tar -xzvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/libiconv
make
make install
cd ../

tar -zxf libxslt-1.1.22.tar.gz
cd libxslt-1.1.22
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
make
make install
cd ../

tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure --prefix=/usr/local/libmcrypt
make
make install
cd ../

tar -xzvf php-5.2.11.tar.gz
gzip -cd php-5.2.11-fpm-0.5.13.diff.gz | patch -d php-5.2.11 -p1
cd php-5.2.11
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php/etc --enable-gd --enable-gd
-native-ttf --with-jpeg-dir=/usr/local/jpeg6 --with-png=/usr/local/libpng --with-ttf --with-zlib=/usr/local/zlib --with-freetype-dir
=/usr/local/freetype --enable-magic-quotes --with-mysql-sock=/tmp/mysql.sock --with-gd=/usr/local/gd --with-iconv=/usr/local/libicon
v --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --enable-soap --with-xsl=/usr/local/libxslt --enable-xslt --with-mc
rypt=/usr/local/libmcrypt --enable-force-cgi-redirect --enable-ftp --enable-soap --with-openssl --enable-pcntl --enable-sockets --en
able-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-op
timization --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-l
dap --with-ldap-sasl
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/php/etc/php.ini
rm -rf /usr/lcaol/php/sbin/php-fpm
cp /root/sh/php-fpm /usr/lcaol/php/sbin/php-fpm
rm -rf /usr/local/php/etc/php-fpm.conf
cp /root/sh/php-fpm.conf /usr/local/php/etc/php-fpm.conf
ln -s /usr/local/php/sbin/php-fpm /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
service php-fpm reload
cd ../

mkdir -p /data/httpd
chown -R <a href="http://www.www">www.www</a> /data
echo '<!--p phpinfo()-->' > /data/httpd/info.php
◾保存退出
運行腳本~/sh/lnmp.sh
◾測試http://ip/inofo.php
浏覽正常表示成功.

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved