Слияние кода завершено, страница обновится автоматически
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# 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
cur_dir=$(pwd)
Stack=$1
if [ "${Stack}" = "" ]; then
Stack="lnmp"
else
Stack=$1
fi
LNMP_Ver='1.3'
. lnmp.conf
. include/main.sh
. include/init.sh
. include/mysql.sh
. include/mariadb.sh
. include/php.sh
. include/nginx.sh
. include/apache.sh
. include/end.sh
Get_Dist_Name
if [ "${DISTRO}" = "unknow" ]; then
Echo_Red "Unable to get Linux distribution name, or do NOT support the current distribution."
exit 1
fi
clear
echo "+------------------------------------------------------------------------+"
echo "| LNMP V${LNMP_Ver} for ${DISTRO} Linux Server, Written by Licess |"
echo "+------------------------------------------------------------------------+"
echo "| A tool to auto-compile & install LNMP/LNMPA/LAMP on Linux |"
echo "+------------------------------------------------------------------------+"
echo "| For more information please visit http://www.lnmp.org |"
echo "+------------------------------------------------------------------------+"
#------------------------- start customer methods start -------------------------------------------------
Check_LAP_Install()
{
Check_PHP_Files
Check_Apache_Files
if [[ "${isPHP}" = "ok" && "${isApache}" = "ok" ]]; then
Print_Sucess_Info
else
Print_Failed_Info
fi
}
Check_LNP_Install()
{
Check_Nginx_Files
Check_PHP_Files
if [[ "${isNginx}" = "ok" && "${isPHP}" = "ok" ]]; then
Print_Sucess_Info
else
Print_Failed_Info
fi
}
Check_LM_Install()
{
Check_DB_Files
if [ "${isDB}" = "ok" ]; then
Print_Sucess_Info
else
Print_Failed_Info
fi
}
Check_LN_Install()
{
Check_Nginx_Files
if [ "${isNginx}" = "ok" ]; then
Print_Sucess_Info
else
Print_Failed_Info
fi
}
Restart_PHP()
{
if [ -s /usr/local/apache/bin/httpd ] && [ -s /usr/local/apache/conf/httpd.conf ] && [ -s /etc/init.d/httpd ]; then
echo "Restarting Apache......"
/etc/init.d/httpd restart
else
echo "Restarting php-fpm......"
/etc/init.d/php-fpm restart
fi
}
Add_LAP_Startup()
{
StartUp httpd
/etc/init.d/httpd start
}
Add_LNP_Startup(){
echo "Add Startup and Starting LNP..."
\cp ${cur_dir}/conf/lnmp /bin/lnmp
chmod +x /bin/lnmp
StartUp nginx
/etc/init.d/nginx start
StartUp php-fpm
/etc/init.d/php-fpm start
if [ "${PHPSelect}" = "1" ]; then
sed -i 's#/usr/local/php/var/run/php-fpm.pid#/usr/local/php/logs/php-fpm.pid#' /bin/lnmp
fi
}
Add_LN_Startup()
{
StartUp nginx
/etc/init.d/nginx start
}
Add_LM_Startup()
{
if [[ "${DBSelect}" = "4" || "${DBSelect}" = "5" ]]; then
StartUp mariadb
/etc/init.d/mariadb start
sed -i 's#/etc/init.d/mysql#/etc/init.d/mariadb#' /bin/lnmp
else
StartUp mysql
/etc/init.d/mysql start
fi
}
Install_Nginx_Only()
{
Echo_Blue "[+] Installing ${Nginx_Ver}... "
groupadd www
useradd -s /sbin/nologin -g www www
Tar_Cd ${Nginx_Ver}.tar.gz ${Nginx_Ver}
if echo ${Nginx_Ver} | grep -Eqi 'nginx-[0-1].[5-8].[0-9]' || echo ${Nginx_Ver} | grep -Eqi 'nginx-1.9.[1-4]$'; then
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_spdy_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module ${NginxMAOpt} ${Nginx_Modules_Options}
else
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module ${NginxMAOpt} ${Nginx_Modules_Options}
fi
make && make install
cd ../
ln -sf /usr/local/nginx/sbin/nginx /usr/bin/nginx
rm -f /usr/local/nginx/conf/nginx.conf
cd ${cur_dir}
\cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf
sed -i 'include enable-php.conf;/d' /usr/local/nginx/conf/nginx.conf
\cp conf/rewrite/dabr.conf /usr/local/nginx/conf/dabr.conf
\cp conf/rewrite/none.conf /usr/local/nginx/conf/none.conf
\cp conf/pathinfo.conf /usr/local/nginx/conf/pathinfo.conf
\cp conf/enable-ssl-example.conf /usr/local/nginx/conf/enable-ssl-example.conf
mkdir -p ${Default_Website_Dir}
chmod +w ${Default_Website_Dir}
mkdir -p /home/wwwlogs
chmod 777 /home/wwwlogs
chown -R www:www ${Default_Website_Dir}
mkdir /usr/local/nginx/conf/vhost
if [ "${Default_Website_Dir}" != "/home/wwwroot/default" ]; then
sed -i "s#/home/wwwroot/default#${Default_Website_Dir}#g" /usr/local/nginx/conf/nginx.conf
fi
if [ "${Stack}" = "lnmp" ]; then
cat >${Default_Website_Dir}/.user.ini<<EOF
open_basedir=${Default_Website_Dir}:/tmp/:/proc/
EOF
chmod 644 ${Default_Website_Dir}/.user.ini
chattr +i ${Default_Website_Dir}/.user.ini
fi
\cp init.d/init.d.nginx /etc/init.d/nginx
chmod +x /etc/init.d/nginx
if [ "${SelectMalloc}" = "3" ]; then
mkdir /tmp/tcmalloc
chown -R www:www /tmp/tcmalloc
sed -i '/nginx.pid/a\
google_perftools_profiles /tmp/tcmalloc;' /usr/local/nginx/conf/nginx.conf
fi
}
Install_PHPMemcache()
{
echo "Install memcache php extension..."
cd ${cur_dir}/src
if echo "${Cur_PHP_Version}" | grep -Eqi '^7.';then
rm -rf pecl-memcache
git clone https://github.com/websupport-sk/pecl-memcache.git
cd pecl-memcache
else
Download_Files ${Download_Mirror}/web/memcache/${PHPMemcache_Ver}.tgz ${PHPMemcache_Ver}.tgz
Tar_Cd ${PHPMemcache_Ver}.tgz ${PHPMemcache_Ver}
fi
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
}
Install_PHPMemcached()
{
echo "Install memcached php extension..."
cd ${cur_dir}/src
Get_Dist_Name
if [ "$PM" = "yum" ]; then
yum install cyrus-sasl-devel -y
Get_Dist_Version
if echo "${CentOS_Version}" | grep -Eqi '^5.'; then
yum install gcc44 gcc44-c++ libstdc++44-devel -y
export CC="gcc44"
export CXX="g++44"
fi
elif [ "$PM" = "apt" ]; then
apt-get install libsasl2-2 sasl2-bin libsasl2-2 libsasl2-dev libsasl2-modules -y
fi
Download_Files ${Download_Mirror}/web/libmemcached/${Libmemcached_Ver}.tar.gz
Tar_Cd ${Libmemcached_Ver}.tar.gz ${Libmemcached_Ver}
./configure --prefix=/usr/local/libmemcached --with-memcached
make && make install
cd ../
if echo "${Cur_PHP_Version}" | grep -Eqi '^7.';then
cd ${cur_dir}/src
rm -rf php-memcached
git clone -b php7 https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached
else
Download_Files ${Download_Mirror}/web/php-memcached/${PHPMemcached_Ver}.tgz ${PHPMemcached_Ver}.tgz
Tar_Cd ${PHPMemcached_Ver}.tgz ${PHPMemcached_Ver}
fi
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcached --with-libmemcached-dir=/usr/local/libmemcached
make && make install
cd ../
}
Init_Install()
{
Press_Install
Print_APP_Ver
Print_Sys_Info
Check_Hosts
if [ "${DISTRO}" = "RHEL" ]; then
RHEL_Modify_Source
fi
Get_Dist_Version
if [ "${DISTRO}" = "Ubuntu" ]; then
Ubuntu_Modify_Source
fi
Set_Timezone
if [ "$PM" = "yum" ]; then
CentOS_InstallNTP
CentOS_RemoveAMP
CentOS_Dependent
elif [ "$PM" = "apt" ]; then
Deb_InstallNTP
Xen_Hwcap_Setting
Deb_RemoveAMP
Deb_Dependent
fi
Disable_Selinux
Check_Download
Install_Autoconf
Install_Libiconv
Install_Libmcrypt
Install_Mhash
Install_Mcrypt
Install_Freetype
Install_Curl
Install_Pcre
Install_Icu4c
if [ "${SelectMalloc}" = "2" ]; then
Install_Jemalloc
elif [ "${SelectMalloc}" = "3" ]; then
Install_TCMalloc
fi
if [ "$PM" = "yum" ]; then
CentOS_Lib_Opt
elif [ "$PM" = "apt" ]; then
Deb_Lib_Opt
Deb_Check_MySQL
fi
if [ "${DBSelect}" = "1" ]; then
Install_MySQL_51
elif [ "${DBSelect}" = "2" ]; then
Install_MySQL_55
elif [ "${DBSelect}" = "3" ]; then
Install_MySQL_56
elif [ "${DBSelect}" = "4" ]; then
Install_MariaDB_5
elif [ "${DBSelect}" = "5" ]; then
Install_MariaDB_10
elif [ "${DBSelect}" = "6" ]; then
Install_MySQL_57
fi
TempMycnf_Clean
}
LNMP_Stack()
{
Init_Install
if [ "${PHPSelect}" = "1" ]; then
Install_PHP_52
elif [ "${PHPSelect}" = "2" ]; then
Install_PHP_53
elif [ "${PHPSelect}" = "3" ]; then
Install_PHP_54
elif [ "${PHPSelect}" = "4" ]; then
Install_PHP_55
elif [ "${PHPSelect}" = "5" ]; then
Install_PHP_56
elif [ "${PHPSelect}" = "6" ]; then
Install_PHP_7
fi
LNMP_PHP_Opt
Install_Nginx
Creat_PHP_Tools
Add_LNMP_Startup
Check_LNMP_Install
}
LNMPA_Stack()
{
Apache_Selection
Init_Install
if [ "${ApacheSelect}" = "1" ]; then
Install_Apache_22
else
Install_Apache_24
fi
if [ "${PHPSelect}" = "1" ]; then
Install_PHP_52
elif [ "${PHPSelect}" = "2" ]; then
Install_PHP_53
elif [ "${PHPSelect}" = "3" ]; then
Install_PHP_54
elif [ "${PHPSelect}" = "4" ]; then
Install_PHP_55
elif [ "${PHPSelect}" = "5" ]; then
Install_PHP_56
elif [ "${PHPSelect}" = "6" ]; then
Install_PHP_7
fi
Install_Nginx
Creat_PHP_Tools
Add_LNMPA_Startup
Check_LNMPA_Install
}
LAMP_Stack()
{
Apache_Selection
Init_Install
if [ "${ApacheSelect}" = "1" ]; then
Install_Apache_22
else
Install_Apache_24
fi
if [ "${PHPSelect}" = "1" ]; then
Install_PHP_52
elif [ "${PHPSelect}" = "2" ]; then
Install_PHP_53
elif [ "${PHPSelect}" = "3" ]; then
Install_PHP_54
elif [ "${PHPSelect}" = "4" ]; then
Install_PHP_55
elif [ "${PHPSelect}" = "5" ]; then
Install_PHP_56
elif [ "${PHPSelect}" = "6" ]; then
Install_PHP_7
fi
Creat_PHP_Tools
Add_LAMP_Startup
Check_LAMP_Install
}
LAP_Stack()
{
Stack="lamp"
Apache_Selection
#-----Init_Install------
Press_Install
Print_APP_Ver
Print_Sys_Info
Check_Hosts
if [ "${DISTRO}" = "RHEL" ]; then
RHEL_Modify_Source
fi
Get_Dist_Version
if [ "${DISTRO}" = "Ubuntu" ]; then
Ubuntu_Modify_Source
fi
Set_Timezone
if [ "$PM" = "yum" ]; then
CentOS_InstallNTP
CentOS_RemoveAMP
CentOS_Dependent
elif [ "$PM" = "apt" ]; then
Deb_InstallNTP
Xen_Hwcap_Setting
Deb_RemoveAMP
Deb_Dependent
fi
Disable_Selinux
Check_Download
Install_Autoconf
Install_Libiconv
Install_Libmcrypt
Install_Mhash
Install_Mcrypt
Install_Freetype
Install_Curl
Install_Pcre
Install_Icu4c
if [ "${SelectMalloc}" = "2" ]; then
Install_Jemalloc
elif [ "${SelectMalloc}" = "3" ]; then
Install_TCMalloc
fi
if [ "$PM" = "yum" ]; then
CentOS_Lib_Opt
elif [ "$PM" = "apt" ]; then
Deb_Lib_Opt
Deb_Check_MySQL
fi
#-----Init_Install------
if [ "${ApacheSelect}" = "1" ]; then
Install_Apache_22
else
Install_Apache_24
fi
if [ "${PHPSelect}" = "1" ]; then
Install_PHP_52
elif [ "${PHPSelect}" = "2" ]; then
Install_PHP_53
elif [ "${PHPSelect}" = "3" ]; then
Install_PHP_54
elif [ "${PHPSelect}" = "4" ]; then
Install_PHP_55
elif [ "${PHPSelect}" = "5" ]; then
Install_PHP_56
elif [ "${PHPSelect}" = "6" ]; then
Install_PHP_7
fi
Creat_PHP_Tools
Add_LAP_Startup
Check_LAP_Install
}
LNP_Stack()
{
Stack="lnmp"
#-----Init_Install------
Press_Install
Print_APP_Ver
Print_Sys_Info
Check_Hosts
if [ "${DISTRO}" = "RHEL" ]; then
RHEL_Modify_Source
fi
Get_Dist_Version
if [ "${DISTRO}" = "Ubuntu" ]; then
Ubuntu_Modify_Source
fi
Set_Timezone
if [ "$PM" = "yum" ]; then
CentOS_InstallNTP
CentOS_RemoveAMP
CentOS_Dependent
elif [ "$PM" = "apt" ]; then
Deb_InstallNTP
Xen_Hwcap_Setting
Deb_RemoveAMP
Deb_Dependent
fi
Disable_Selinux
Check_Download
Install_Autoconf
Install_Libiconv
Install_Libmcrypt
Install_Mhash
Install_Mcrypt
Install_Freetype
Install_Curl
Install_Pcre
Install_Icu4c
if [ "${SelectMalloc}" = "2" ]; then
Install_Jemalloc
elif [ "${SelectMalloc}" = "3" ]; then
Install_TCMalloc
fi
if [ "$PM" = "yum" ]; then
CentOS_Lib_Opt
elif [ "$PM" = "apt" ]; then
Deb_Lib_Opt
Deb_Check_MySQL
fi
#-----Init_Install------
if [ "${PHPSelect}" = "1" ]; then
Install_PHP_52
elif [ "${PHPSelect}" = "2" ]; then
Install_PHP_53
elif [ "${PHPSelect}" = "3" ]; then
Install_PHP_54
elif [ "${PHPSelect}" = "4" ]; then
Install_PHP_55
elif [ "${PHPSelect}" = "5" ]; then
Install_PHP_56
elif [ "${PHPSelect}" = "6" ]; then
Install_PHP_7
fi
LNMP_PHP_Opt
Install_Nginx
Creat_PHP_Tools
Add_LNP_Startup
Check_LNP_Install
}
LN_Stack()
{
#-----Init_Install------
Press_Install
Print_APP_Ver
Print_Sys_Info
Check_Hosts
if [ "${DISTRO}" = "RHEL" ]; then
RHEL_Modify_Source
fi
Get_Dist_Version
if [ "${DISTRO}" = "Ubuntu" ]; then
Ubuntu_Modify_Source
fi
Set_Timezone
if [ "$PM" = "yum" ]; then
CentOS_InstallNTP
CentOS_RemoveAMP
CentOS_Dependent
elif [ "$PM" = "apt" ]; then
Deb_InstallNTP
Xen_Hwcap_Setting
Deb_RemoveAMP
Deb_Dependent
fi
Disable_Selinux
Check_Download
Install_Autoconf
Install_Libiconv
Install_Libmcrypt
Install_Mhash
Install_Mcrypt
Install_Freetype
Install_Curl
Install_Pcre
Install_Icu4c
if [ "${SelectMalloc}" = "2" ]; then
Install_Jemalloc
elif [ "${SelectMalloc}" = "3" ]; then
Install_TCMalloc
fi
if [ "$PM" = "yum" ]; then
CentOS_Lib_Opt
elif [ "$PM" = "apt" ]; then
Deb_Lib_Opt
Deb_Check_MySQL
fi
#-----Init_Install------
Install_Nginx_Only
Add_LN_Startup
Check_LN_Install
}
LM_Stack()
{
Init_Install
Add_LM_Startup
Check_LM_Install
}
LCP_Stack()
{
ver="1"
echo "Which memcached php extension do you choose:"
echo "Install php-memcache,(Discuz x) please enter: 1"
echo "Install php-memcached, please enter: 2"
read -p "Enter 1 or 2 (Default 1): " ver
if [ "${ver}" = "1" ]; then
echo "You choose php-memcache"
PHP_ZTS="memcache.so"
elif [ "${ver}" = "2" ]; then
echo "You choose php-memcached"
PHP_ZTS="memcached.so"
else
ver="1"
echo "You choose php-memcache"
PHP_ZTS="memcache.so"
fi
echo "====== Installing memcached ======"
Press_Install
sed -i '/memcache.so/d' /usr/local/php/etc/php.ini
sed -i '/memcached.so/d' /usr/local/php/etc/php.ini
Get_PHP_Ext_Dir
zend_ext=${zend_ext_dir}${PHP_ZTS}
if [ -s "${zend_ext}" ]; then
rm -f "${zend_ext}"
fi
if echo "${Cur_PHP_Version}" | grep -Eqi '^5.2.';then
sed -i "/extension_dir =/a\
extension = \"${PHP_ZTS}\"" /usr/local/php/etc/php.ini
elif echo "${Cur_PHP_Version}" | grep -Eqi '^5.[3456].' || echo "${Cur_PHP_Version}" | grep -Eqi '^7.';then
sed -i "/the dl()/i\
extension = \"${PHP_ZTS}\"" /usr/local/php/etc/php.ini
else
echo "Error: can't get php version!"
echo "Maybe php was didn't install or php configuration file has errors.Please check."
sleep 3
exit 1
fi
if [ "${ver}" = "1" ]; then
Install_PHPMemcache
elif [ "${ver}" = "2" ]; then
Install_PHPMemcached
fi
echo "Copy Memcached PHP Test file..."
\cp ${cur_dir}/conf/memcached${ver}.php ${Default_Website_Dir}/memcached.php
Restart_PHP
if [ -s "${zend_ext}" ]; then
echo "====== Memcached install completed ======"
echo "PHP Memcached installed successfully, enjoy it!"
else
sed -i "/${PHP_ZTS}/d" /usr/local/php/etc/php.ini
echo "PHP Memcached install failed!"
fi
}
LCS_Stack()
{
ver="1"
echo "Which memcached php extension do you choose:"
echo "Install php-memcache,(Discuz x) please enter: 1"
echo "Install php-memcached, please enter: 2"
read -p "Enter 1 or 2 (Default 1): " ver
if [ "${ver}" = "1" ]; then
echo "You choose php-memcache"
PHP_ZTS="memcache.so"
elif [ "${ver}" = "2" ]; then
echo "You choose php-memcached"
PHP_ZTS="memcached.so"
else
ver="1"
echo "You choose php-memcache"
PHP_ZTS="memcache.so"
fi
echo "====== Installing memcached ======"
Press_Install
echo "Install memcached..."
cd ${cur_dir}/src
Download_Files ${Download_Mirror}/web/memcached/${Memcached_Ver}.tar.gz ${Memcached_Ver}.tar.gz
Tar_Cd ${Memcached_Ver}.tar.gz ${Memcached_Ver}
./configure --prefix=/usr/local/memcached
make &&make install
cd ../
rm -rf ${cur_dir}/src/${Memcached_Ver}
ln -sf /usr/local/memcached/bin/memcached /usr/bin/memcached
\cp ${cur_dir}/init.d/init.d.memcached /etc/init.d/memcached
chmod +x /etc/init.d/memcached
useradd -s /sbin/nologin nobody
if [ ! -d /var/lock/subsys ]; then
mkdir -p /var/lock/subsys
fi
StartUp memcached
if [ -s /sbin/iptables ]; then
/sbin/iptables -A INPUT -p tcp --dport 11211 -j DROP
/sbin/iptables -A INPUT -p udp --dport 11211 -j DROP
if [ "$PM" = "yum" ]; then
service iptables save
elif [ "$PM" = "apt" ]; then
iptables-save > /etc/iptables.rules
fi
fi
echo "Starting Memcached..."
/etc/init.d/memcached start
if [ -s /usr/local/memcached/bin/memcached ]; then
echo "====== Memcached install completed ======"
echo "Memcached installed successfully, enjoy it!"
else
echo "Memcached install failed!"
fi
}
#------------------------- end customer methods end-------------------------------------------------
case "${Stack}" in
#nginx+php+mysql
lnmp)
Dispaly_Selection
LNMP_Stack 2>&1 | tee /root/lnmp-install.log
;;
#nginx+apache+php+mysql
lnmpa)
Dispaly_Selection
LNMPA_Stack 2>&1 | tee /root/lnmp-install.log
;;
#apache+php+mysql
lamp)
Dispaly_Selection
LAMP_Stack 2>&1 | tee /root/lnmp-install.log
;;
#apache+php
lap)
Dispaly_Selection
LAP_Stack 2>&1 | tee /root/lnmp-install.log
;;
#nginx+php
lnp)
Dispaly_Selection
LNP_Stack 2>&1 | tee /root/lnmp-install.log
;;
#nginx
ln)
Dispaly_Selection
LN_Stack 2>&1 | tee /root/lnmp-install.log
;;
#mysql
lm)
Dispaly_Selection
LM_Stack 2>&1 | tee /root/lnmp-install.log
;;
#php+memcache
lcp)
LCP_Stack 2>&1 | tee /root/lnmp-install.log
;;
#memcache server
lcs)
LCS_Stack 2>&1 | tee /root/lnmp-install.log
;;
*)
Echo_Red "Usage: $0 {lnmp|lnmpa|lamp}"
;;
esac
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )