#!/bin/bash
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, please use root to install lnmp"
exit 1
fi
clear
echo "========================================================================="
echo "LNMP V0.3 for CentOS/RadHat Linux VPS Written by Licess"
echo "========================================================================="
echo "A tool to auto-compile & install Nginx+MySQL+PHP on Linux "
echo "For more information please visit http://blog.licess.cn/lnmp/"
echo ""
echo ""
echo "The path of some dirs:"
echo "mysql dir: /usr/local/mysql"
echo "php dir: /usr/local/php"
echo "nginx dir: /usr/local/nginx"
echo "web dir /home/wwwroot"
echo ""
echo "========================================================================="
cur_dir=$(pwd)
if [ "$1" != "--help" ]; then
domain="www.lnmp.org"
echo "Please input domain:"
read -p "(Default domain: www.lnmp.org):" domain
if [ "$domain" = "" ]; then
domain="www.lnmp.org"
fi
echo "==========================="
echo domain="$domain"
echo "==========================="
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "Press any key to start..."
char=`get_char`
yum -y remove httpd
yum -y update
yum -y install patch make gcc gcc-c++ gcc-g77 flex bison
yum -y install libtool libtool-libs autoconf kernel-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel
yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
yum -y install glib2 glib2-devel bzip2
yum -y install bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs
yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
yum -y install openssl openssl-devel vim-minimal sendmail
yum -y install fonts-chinese scim-chewing scim-pinyin scim-tables-chinese
cd $cur_dir
wget -c http://soft.vpser.net/web/libiconv/libiconv-1.13.tar.gz
tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure --prefix=/usr/local
make && make install
cd ../
cd $cur_dir
wget -c http://soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make && make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make && make install
cd ../../
cd $cur_dir
wget -c http://soft.vpser.net/web/mhash/mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./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.8 /usr/lib/libmcrypt.so.4.4.8
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
cd $cur_dir
wget -c http://soft.vpser.net/web/mcrypt/mcrypt-2.6.8.tar.gz
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make && make install
cd ../
echo "============================mysql install=================================="
cd $cur_dir
wget -c http://soft.vpser.net/datebase/mysql/mysql-5.1.35.tar.gz
tar -zxvf mysql-5.1.35.tar.gz
cd mysql-5.1.35
./configure --prefix=/usr/local/mysql --enable-assembler --with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile
make && make install
cd ../
groupadd mysql
useradd -g mysql mysql
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/.
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --level 345 mysql on
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
echo "/usr/local/lib" >>/etc/ld.so.conf
ldconfig
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
/etc/init.d/mysql start
/usr/local/mysql/bin/mysqladmin -u root password root
/etc/init.d/mysql restart
/etc/init.d/mysql stop
chkconfig mysql-ndb off
chkconfig mysql-ndb-mgm off
echo "============================mysql intall finished========================="
echo "============================php+eaccelerator install======================"
cd $cur_dir
wget -c http://soft.vpser.net/web/php/php-5.2.10.tar.gz
wget -c http://soft.vpser.net/web/phpfpm/php-5.2.10-fpm-0.5.11.diff.gz
tar zxvf php-5.2.10.tar.gz
gzip -cd php-5.2.10-fpm-0.5.11.diff.gz | patch -d php-5.2.10 -p1
cd php-5.2.10/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/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-xmlrpc --enable-zip --enable-ftp --without-pear --with-mime-magic=/usr/share/file/magic.mime
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/php/etc/php.ini
cd ../
cd $cur_dir
wget -c http://soft.vpser.net/web/memcache/memcache-2.2.5.tgz
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\n#' /usr/local/php/etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/php/etc/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /usr/local/php/etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /usr/local/php/etc/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /usr/local/php/etc/php.ini
if [ `uname -m` = 'x86_64' ]; then
wget -c http://soft.vpser.net/web/zend/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
mkdir -p /usr/local/zend/
cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/
else
wget -c http://soft.vpser.net/web/zend/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
mkdir -p /usr/local/zend/
cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/
fi
cat >>/usr/local/php/etc/php.ini<<EOF
[Zend Optimizer]
zend_optimizer.optimization_level=1
zend_extension="/usr/local/zend/ZendOptimizer.so"
EOF
groupadd www
useradd -g www www
mkdir -p /home/wwwroot
chmod +w /home/wwwroot
mkdir -p /home/wwwroot/logs
chmod 777 /home/wwwroot/logs
chown -R www:www /home/wwwroot
rm -f /usr/local/php/etc/php-fpm.conf
cp conf/php-fpm.conf /usr/local/php/etc/php-fpm.conf
echo "ulimit -SHn 51200" >/root/run.sh
echo "/usr/local/php/sbin/php-fpm start" >>/root/run.sh
echo "============================php+eaccelerator install finished======================"
echo "============================nginx install================================="
cd $cur_dir
wget -c http://soft.vpser.net/web/pcre/pcre-7.9.tar.gz
tar zxvf pcre-7.9.tar.gz
cd pcre-7.9/
./configure
make && make install
cd ../
wget -c http://soft.vpser.net/web/nginx/nginx-0.7.63.tar.gz
tar zxvf nginx-0.7.63.tar.gz
cd nginx-0.7.63/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../
rm -f /usr/local/nginx/conf/nginx.conf
cd $cur_dir
cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf
cp conf/dabr.conf /usr/local/nginx/conf/dabr.conf
cp conf/discuz.conf /usr/local/nginx/conf/discuz.conf
cp conf/sablog.conf /usr/local/nginx/conf/sablog.conf
cp conf/typecho.conf /usr/local/nginx/conf/typecho.conf
cp conf/wordpress.conf /usr/local/nginx/conf/wordpress.conf
sed -i 's/www.lnmp.org/'$domain'/g' /usr/local/nginx/conf/nginx.conf
rm -f /usr/local/nginx/conf/fcgi.conf
cp conf/fcgi.conf /usr/local/nginx/conf/fcgi.conf
echo "/usr/local/nginx/sbin/nginx" >>/root/run.sh
chmod 777 /root/run.sh
/etc/init.d/mysql start
/root/run.sh
echo "============================nginx install finished================================="
cat >/home/wwwroot/phpinfo.php<<eof
<?
phpinfo();
?>
eof
wget -c http://soft.vpser.net/prober/prober2.tar.gz
tar zxvf prober2.tar.gz
mv prober2.php /home/wwwroot/p.php
echo "============================phpMyAdmin install================================="
wget -c http://soft.vpser.net/datebase/phpmyadmin/phpmyadmin.tar.gz
#phpmyadmin
tar zxvf phpmyadmin.tar.gz
mv phpmyadmin /home/wwwroot/
echo "============================phpMyAdmin install finished================================="
echo "============================add nginx and php-fpm on startup============================"
echo "ulimit -SHn 51200" >>/etc/rc.local
echo "/usr/local/php/sbin/php-fpm start" >>/etc/rc.local
echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local
echo "===========================add nginx and php-fpm on startup finished===================="
#set timezone
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
clear
echo "========================================================================="
echo "LNMP V0.3 for CentOS/RadHat Linux VPS Written by Licess "
echo "========================================================================="
echo ""
echo "For more information please visit http://blog.licess.cn/lnmp/"
echo ""
echo "run nginx+php-cgi: /root/run.sh"
echo "default mysql root password:root"
echo "phpinfo test: http://domain.name/phpinfo.php"
echo "phpMyAdmin test: http://domain.name/phpmyadmin"
echo "Prober : http://domain.name/prober.php"
echo "The path of some dirs:"
echo "mysql dir: /usr/local/mysql"
echo "php dir: /usr/local/php"
echo "nginx dir: /usr/local/nginx"
echo "web dir /home/wwwroot"
echo ""
echo "========================================================================="
fi
分享到:
相关推荐
首先,"CentOS6.5 LNMP环境搭建Shell脚本"是自动化安装和配置这四个组件的关键。通过运行一个精心编写的Shell脚本,可以大大简化这个过程,节省时间和精力。通常,这种脚本会包括以下步骤: 1. 更新系统:使用`yum ...
### Centos 7.4 LNMP架构部署GLPI 9.4.3 #### 一、准备工作 在开始部署之前,我们需要确保系统已准备好并安装了必要的软件包。本指南将帮助您通过以下步骤在Centos 7.4上设置LNMP (Linux Nginx MySQL PHP) 架构,...
支持ssl,curl开启ssl支持,环境为nginx1.8.1+php5.6+mysql5.5,使用时请在根目录创建一个data目录,然后将源码包以及shell脚本复制到该目录,给install*文件可执行权限,然后依次执行对应脚本文件即可。
`lnmp_shell` 脚本集合了安装、配置和管理LNAMP环境所需的多个命令,通过执行单一脚本就能完成整个环境的搭建,极大地提高了效率。 ### 3. lnmp_shell 脚本功能 - **自动安装**: 脚本会自动检测你的系统类型,并...
支持ssl,curl开启ssl支持,环境为nginx1.8.1+php5.6+mysql5.5,使用时请在根目录创建一个data目录,然后将源码包以及shell脚本复制到该目录,给install*文件可执行权限,然后依次执行对应脚本文件即可。
为了简化MySQL的安装过程,本文提供了一个名为`mysql_install.sh`的Shell脚本。该脚本自动执行了大部分MySQL的安装步骤,包括创建数据目录、设置用户权限、编译安装MySQL等。 **mysql_install.sh 内容示例** ```...
支持ssl,curl开启ssl支持,环境为nginx1.8.1+php5.6+mysql5.5,使用时请在根目录创建一个data目录,然后将源码包以及shell脚本复制到该目录,给install*文件可执行权限,然后依次执行对应脚本文件即可。
3.2 `cnl_install-lnmp_init.sh`:这是初始化脚本,包含了安装前的准备工作,如确定系统架构,关闭Selinux(为了简化安装过程),安装必要的构建工具和依赖库,以及添加阿里云的EPEL仓库以便获取最新软件包。...
LNMP一键安装包是一个用Linux Shell编写的可以为CentOS/RadHat、Debian/Ubuntu VPS(VDS)或独立主机安装LNMP(Nginx、MySQL、PHP、phpMyAdmin)生产环境的Shell程序。 我们为什么需要它? 编译安装需要输入大量...
支持ssl,curl开启ssl支持,环境为nginx1.8.1+php5.6+mysql5.5,使用时请在根目录创建一个data目录,然后将源码包以及shell脚本复制到该目录,给install*文件可执行权限,然后依次执行对应脚本文件即可。
5. 创建Nextcloud数据库和用户:登录MySQL或MariaDB shell,然后执行SQL命令创建数据库和用户,并赋予相应权限。 6. 配置Nextcloud:在浏览器中访问`http://yourdomain/nextcloud`,按照屏幕提示进行初始安装,输入...
支持ssl,curl开启ssl支持,环境为nginx1.8.1+php5.6+mysql5.5,使用时请在根目录创建一个data目录,然后将源码包以及shell脚本复制到该目录,给install*文件可执行权限,然后依次执行对应脚本文件即可。
- **适用环境**:适用于 CentOS 7.2 或 RHEL 7.2。 - **操作流程**: - 使用 `yum` 安装 Nginx、MySQL 和 PHP。 - 启动并设置 Nginx 和 MySQL 服务开机自启。 ```bash yum -y install httpd mariadb mariadb-...
了解shell命令行的基本用法,如ls、cd、mkdir、rm等,以及使用vi或nano编辑文本文件,是Linux运维的基本功。 接下来,我们关注Nginx。Nginx以其事件驱动的非阻塞I/O模型,能够在处理大量并发连接时保持低资源消耗。...
12. **检测用户权限**:通过比较`$USER`变量与"root"的值来判断用户是否为管理员,是的话就执行`yum install vsftpd`,否则显示权限不足的信息。这种方法可以使用字符串比较或UID比较。 13. **自动创建用户并设置...
4. **一键部署LNMP**:使用`yum`包管理器安装LNMP(Linux + Nginx + MariaDB + PHP),适用于CentOS 7.2或RHEL 7.2: ```bash yum -y install httpd mariadb mariadb-devel mariadb-server php php-mysql ...
本教程将详细介绍如何在Red Hat 7或CentOS 7及其以上版本上,通过源码编译的方式,一键部署Zabbix包括Proxy组件,并集成LNMP(Linux + Nginx + MySQL + PHP)环境。这种方式的好处在于能够灵活地定制配置,适应特定...
- **Apache**:使用`sudo apt-get install apache2`(Ubuntu/Debian)或`yum install httpd`(CentOS/RHEL)。 - **Nginx**:使用`sudo apt-get install nginx`(Ubuntu/Debian)或`yum install nginx`(CentOS/...
根据提供的文件信息,本文将详细解释如何在CentOS 6.3系统上搭建PHP5.4+Nginx1.3.9+Mysql5.5.21的Web环境(通常被称为LNMP栈)。该环境适合用于开发和部署基于PHP的应用程序。 ### 一、准备工作 #### 安装必要的...
2. Linux发行版:讲解各种流行的Linux发行版,如Ubuntu、CentOS、Debian等的区别及其应用领域。 3. Linux与其他操作系统对比:对比Linux与Windows、Mac OS在系统架构和使用习惯上的差异。 **第二学时:Linux安装** ...