首页 > 代码库 > LNMP脚本安装
LNMP脚本安装
#!/bin/bash
#nginx:nginx-1.8.0.tar.gz
#mysql:mysql-5.5.50.tar.gz
#php:php-5.5.31.tar.gz
#the software package
dir = /software
if [ ! -f $dir ];then
mkdir $dir
fi
#configure epel source
cd $dir
wget http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm
rpm -ivh epel-release-latest-6.noarch.rpm
yum repolist
#Install the development packages
yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype*
#close iptables and selinux
service iptables stop
sed -i ‘s/SELINUX=enforcing/SELINUX=diabled/g‘ /etc/sysconfig/selinux
setenforce 0
#install and configure mysql server
cd $dir
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.50.tar.gz
if ! id mysql &> /deve/null;then
useradd -d /usr/local/mysql -s /sbin/nologin mysql
fi
mkdir -p /mydata/data
mkdir -p /mydata/log
chown -R mysql.mysql /mydata/data
chown -R mysql.mysql /mydata/log
chmod 750 /mydata/data
chmod 750 /mydata/log
tar xf mysql-5.5.50.tar.gz
cd mysql-5.5.50
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/mydata/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DSYSCONFDIR=/etc \
-DWITH_SSL=yes
sed -i ‘s@datadir=/var/lib/mysql@datadir=/mydata/data@g‘ /etc/my.cnf
sed -i ‘s@socket=/var/lib/mysql/mysql.sock@socket=/tmp/mysql.sock@g‘ /etc/my.cnf
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
cd /usr/local/mysql
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
service mysqld start
echo "PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
mysqladmin -u root password Lsf@8816 #setting mysql root password
#install and configure nginx 1.8.1
#Install the prerequisite
yum -y install gcc openssl-devel pcre-devel zlib-devel
cd $dir
groupadd nginx
useradd -g nginx -s /sbin/nologin nginx
wget http://nginx.org/download/nginx-1.8.1.tar.gz
tar xf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-debug --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi && make && make install
mkdir -p /var/tmp/nginx/client
/usr/local/nginx/sbin/nginx
#install and configure php
yum -y install gcc gcc-c++ autoconf 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 e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN pcre-devel
cd $dir
wget http://mirrors.sohu.com/php/php-5.5.31.tar.gz
tar xf php-5.5.31.tar.gz
cd php-5.4.25
./configure --prefix=/usr/local/php5 --enable-fpm --with-libxml-dir=/usr/local/lib --with-zlib-dir=/usr/local/lib --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --enable-soap --enable-sockets --enable-xml --enable-mbstring --with-png-dir=/usr/local --with-jpeg-dir=/usr/local --with-curl=/usr/lib --with-freetype-dir=/usr/include/freetype2/freetype/ --enable-bcmath --enable-zip --enable-maintainer-zts && make && make install
cp php.ini-development /etc/php.ini
echo "error_log = /usr/local/nginx/logs/php_error.log" >> /etc/php.ini
echo "date.timezone=PRC" >> /etc/php.ini
cd /usr/local/php5/etc/
cp php-fpm.conf.default php-fpm.conf
/usr/local/php5/sbin/php-fpm
LNMP脚本安装