#!/bin/bash # User Install LNMP # Date:2014-8-31 # Blog: ########## function ########## depend_pkg () { yum install -y gcc gcc-c++ wget cmake curl-devel kernel-headers glibc glibc-headers zlib zlib-devel openssl openssl-devel pcre-devel perl compat* php-common ncurses-devel libtool* libxml2 libxml2-devel } cat <<END 1.[install nginx1.6] 2.[install mysql5.5] 3.[install php5.4] END read -p "Please input number : " NUM case $NUM in 1) ########## Install Depend Pkg ########## depend_pkg; ########## Install nginx ########## WorkDIR=/usr/local/src NGINXDIR=/usr/local/NGINX1.6 groupadd nginx useradd -g nginx -s /sbin/nologin nginx cd $WorkDIR wget -c http://nginx.org/download/nginx-1.6.3.tar.gz tar -zxvf nginx-1.6.3.tar.gz cd nginx-1.6.3 ./configure --prefix=/usr/local/nginx1.6 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module make && make install if [ $? -eq 0 ];then cp /usr/local/nginx1.6/sbin/nginx /etc/rc.d/init.d/nginx # 加入service echo "/usr/local/nginx1.6/sbin/nginx" >> /etc/rc.d/rc.local # 设置开机启动 service nginx # 启动nginx [ $? -eq 0 ] && echo "nginx install success." || echo "nginx install failed." else # nginx启动是否成功 echo "------ nginx install failed. ------" exit 1 fi ;; 2) ########## Install Depend Pkg ########## depend_pkg; ########## Install Mysql ########## /usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql -s /sbin/nologin mysql WorkDIR=/usr/local/src MYSQLDIR=/usr/local/mysql5.6 cd /usr/local/src [ -f "mysql-5.6.10.tar.gz" ] || wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz tar zxvf mysql-5.6.10.tar.gz cd mysql-5.6.10 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.6 \ -DSYSCONFDIR=/usr/local/mysql5.6/etc \ -DMYSQL_DATADIR=/usr/local/mysql5.6/data \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci make && make install if [ $? -eq 0 ];then /usr/local/mysql5.6/scripts/mysql_install_db \ --basedir=/usr/local/mysql5.6 --datadir=/usr/local/mysql5.6/data/ --user=mysql 1>/dev/null mkdir /usr/local/mysql5.6/etc cd /usr/local/mysql5.6 cp support-files/my-default.cnf /usr/local/mysql5.6/etc/my.cnf cp support-files/mysql.server /etc/rc.d/init.d/mysqld rm -rf /etc/my.cnf #echo "PATH=$PATH:$MYSQLDIR/bin" >> /etc/profile #. /etc/profile chmod +x /etc/init.d/mysqld chown -R root.mysql /usr/local/mysql5.6/ chown -R mysql.mysql /usr/local/mysql5.6/data/ service mysqld start chkconfig mysqld on [ $? -eq 0 ] && echo "MySQL install success." || echo "MySQL install failed." else echo "------mysql cmake failed.------" exit 1 fi ;; 3) ########## Install Depend Pkg ########## depend_pkg; ########## Install GD ########## yum install gd php-gd freetype freetype-devel libpng libpng-devel libjpeg* -y ########## Install PHP ########## WorkDIR=/usr/local/src PHPDIR=/usr/local/php5.4 PHPCONF=/usr/local/php5.4/etc/php.ini cd $WorkDIR [ -f "php-5.4.31.tar.gz" ] || wget http://cn2.php.net/distributions/php-5.4.31.tar.gz tar zxvf php-5.4.31.tar.gz cd php-5.4.31 ./configure --prefix=/usr/local/php5.4 \ --with-config-file-path=/usr/local/php5.4/etc \ --with-mysql=/usr/local/mysql5.6 \ --with-mysqli=/usr/local/mysql5.6/bin/mysql_config \ --with-mysql-sock=/tmp/mysql.sock \ --with-pdo-mysql=/usr/local/mysql5.6 \ --with-gd -with-zlib -with-iconv -enable-zip -enable-pdo \ --enable-xml -with-openssl -with-curl -enable-bcmath \ --enable-ftp -enable-xml -with-openssl -with-curl \ --enable-bcmath -enable-ftp -enable-mbstring -enable-fpm \ --with-fpm-user=nginx -with-fpm-group=nginx -enable-shmop \ --enable-sysvsem -enable-mbregex -enable-gd-native-ttf \ --enable-pcntl -enable-sockets -with-xmlrpc -enable-soap \ --without-pear -with-gettext -enable-session make && make install if [ $? -eq 0 ];then cp php.ini-production /usr/local/php5.4/etc/php.ini echo "data.timezone = Asia\Shanghai" >> /usr/local/php5.4/etc/php.ini sed -i 's/upload_max_filesize = 2M/ upload_max_filesize = 50M/g' /usr/local/php5.4/etc/php.ini sed -i 's/display_errors = Off/display_errors = On/g' /usr/local/php5.4/etc/php.ini cp /usr/local/php5.4/etc/php-fpm.conf.default /usr/local/php5.4/etc/php-fpm.conf sed -i "25 s/^.//" /usr/local/php5.4/etc/php-fpm.conf cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/rc.d/init.d/php-fpm service php-fpm start chkconfig php-fpm on sed -i "s/#user nobody;/user nginx nginx;/" /usr/local/nginx1.6/conf/nginx.conf sed -i "s/worker_processes 1;/worker_processes 4;/" /usr/local/nginx1.6/conf/nginx.conf sed -i "5 s/^.//" /usr/local/nginx1.6/conf/nginx.conf sed -i "15 s/^/pid logs\/nginx.pid;/" /usr/local/nginx1.6/conf/nginx.conf sed -i "45 s/index index.html index.htm/index index.php index.html index.htm/" /usr/local/nginx1.6/conf/nginx.conf sed -i "65 s/#//" /usr/local/nginx1.6/conf/nginx.conf sed -i "66 s/#//" /usr/local/nginx1.6/conf/nginx.conf sed -i "67 s/#//" /usr/local/nginx1.6/conf/nginx.conf sed -i "68 s/#//" /usr/local/nginx1.6/conf/nginx.conf sed -i "69 s/#//" /usr/local/nginx1.6/conf/nginx.conf sed -i "70 s/#//" /usr/local/nginx1.6/conf/nginx.conf sed -i "71 s/#//" /usr/local/nginx1.6/conf/nginx.conf sed -i "69 s/scripts$fastcgi_script_name/usr\/local\/nginx1.6\/html$fastcgi_script_name/" /usr/local/nginx1.6/conf/nginx.conf chown -R nginx /usr/local/nginx1.6/html chmod 744 -R /usr/local/nginx1.6/html [ $? -eq 0 ] && echo "PHP install success." || echo "PHP install failed." else echo "------ php make failed. ------" exit 1 fi ;; *) echo "Please input number 1 2 3." esac
centos6.5 安装LNMP
精选 转载xiexiaojun 博主文章分类:【工具使用】
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
CentOS安装DataX
datax安装
datax -
yum搭建lnmp环境(CentOS6.5)
web应用
web应用 lnmp