歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

LNMP最新源碼安裝腳本(定期更新)

LNMP最新源碼安裝腳本(定期更新)   Linux+Nginx+MySQL+PHP+Pureftpd+User manager for PureFTPd,腳本中用到的軟件包大多最新版本,修復了User manager for PureFTPd一些安全性問題,不建議使用phpMyAdmin,如需使用可以將解壓包放到/data/admin目錄下。   又見LNMP有木有?如有錯誤請各位大蝦們及時告之   LNMP已經放到github(定期更新)上,地址:https://github.com/lj2007331/lnmp   腳本中軟件版本如下: 01 cmake-2.8.10.2.tar.gz 02 mysql-5.5.32.tar.gz 03 libiconv-1.14.tar.gz 04 libmcrypt-2.5.8.tar.gz 05 mhash-0.9.9.9.tar.gz 06 mcrypt-2.6.8.tar.gz 07 php-5.3.26.tar.gz 08 memcache-2.2.5.tgz 09 eaccelerator-0.9.6.1.tar.bz2 10 PDO_MYSQL-1.0.2.tgz 11 ImageMagick-6.8.3-10.tar.gz 12 imagick-3.0.1.tgz 13 pecl_http-1.7.5.tgz 14 pcre-8.32.tar.gz 15 nginx-1.4.1.tar.gz 16 pure-ftpd-1.0.36.tar.gz 17 ftp_v2.1.tar.gz 使用方法:   1 wget http://blog.linuxeye.com/wp-content/uploads/lnmp/lnmp_install.sh 2 chmod +x lnmp_install.sh 3 lnmp_install.sh 說明:  本人在 CentOS 6.x 32/64bit( Linode)上測試通過,並且在線上使用這個腳本。  腳本內容     001 #!/bin/bash 002 # Check if user is root 003 [ $(id -u) != "0" ] && echo "Error: You must be root to run this script, please use root to install lnmp" && exit 1 004   005 echo "#######################################################################" 006 echo "#                    LNMP for CentOS/RadHat Linux                     #" 007 echo "# For more information please visit https://github.com/lj2007331/lnmp #" 008 echo "#######################################################################" 009 echo '' 010   011 # get IP 012 IP=`ifconfig | grep 'inet addr:' | cut -d: -f2 | grep -v ^10. | grep -v ^192.168 | grep -v ^172. | grep -v ^127. | awk '{print  $1}' | awk '{print;exit}'` 013   014 # Set password 015 while : 016 do 017     read -p "Please input the root password of MySQL:" mysqlrootpwd 018     read -p "Please input the manager password of Pureftpd:" ftpmanagerpwd 019     if (( ${#mysqlrootpwd} >= 5 && ${#ftpmanagerpwd} >=5 ));then 020         break 021     else 022        echo "least 5 characters" 023     fi 024 done 025   026 # Download packages 027 mkdir -p /root/lnmp/{source,conf} 028 function Download() 029 { 030 cd /root/lnmp 031 [ -s init.sh ] && echo 'init.sh found' || wget https://raw.github.com/lj2007331/lnmp/master/init.sh 032 cd /root/lnmp/source 033 [ -s cmake-2.8.10.2.tar.gz ] && echo 'cmake-2.8.10.2.tar.gz found' || wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz 034 [ -s mysql-5.5.32.tar.gz ] && echo 'mysql-5.5.32.tar.gz found' || wget http://fossies.org/linux/misc/mysql-5.5.32.tar.gz 035 [ -s libiconv-1.14.tar.gz ] && echo 'libiconv-1.14.tar.gz found' || wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz 036 [ -s libmcrypt-2.5.8.tar.gz ] && echo 'bmcrypt-2.5.8.tar.gz found' || wget http://iweb.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz 037 [ -s mhash-0.9.9.9.tar.gz ] && echo 'mhash-0.9.9.9.tar.gz found' || wget http://iweb.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz 038 [ -s mcrypt-2.6.8.tar.gz ] && echo 'mcrypt-2.6.8.tar.gz found' || wget http://vps.googlecode.com/files/mcrypt-2.6.8.tar.gz 039 [ -s php-5.3.26.tar.gz ] && echo 'php-5.3.26.tar.gz found' || wget http://kr1.php.net/distributions/php-5.3.26.tar.gz 040 [ -s memcache-2.2.5.tgz ] && echo 'memcache-2.2.5.tgz found' || wget http://pecl.php.net/get/memcache-2.2.5.tgz 041 [ -s eaccelerator-0.9.6.1.tar.bz2 ] && echo 'eaccelerator-0.9.6.1.tar.bz2 found' || wget http://superb-dca2.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.tar.bz2 042 [ -s PDO_MYSQL-1.0.2.tgz ] && echo 'PDO_MYSQL-1.0.2.tgz found' || wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz 043 [ -s ImageMagick-6.8.3-10.tar.gz ] && echo 'ImageMagick-6.8.3-10.tar.gz found' || wget http://www.imagemagick.org/download/legacy/ImageMagick-6.8.3-10.tar.gz 044 [ -s imagick-3.0.1.tgz ] && echo 'imagick-3.0.1.tgz found' || wget http://pecl.php.net/get/imagick-3.0.1.tgz 045 [ -s pecl_http-1.7.5.tgz ] && echo 'pecl_http-1.7.5.tgz found' || wget http://pecl.php.net/get/pecl_http-1.7.5.tgz 046 [ -s pcre-8.32.tar.gz ] && echo 'pcre-8.32.tar.gz found' || wget http://iweb.dl.sourceforge.net/project/pcre/pcre/8.32/pcre-8.32.tar.gz 047 [ -s nginx-1.4.1.tar.gz ] && echo 'nginx-1.4.1.tar.gz found' || wget http://nginx.org/download/nginx-1.4.1.tar.gz 048 [ -s pure-ftpd-1.0.36.tar.gz ] && echo 'pure-ftpd-1.0.36.tar.gz found' || wget ftp://ftp.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.36.tar.gz 049 [ -s ftp_v2.1.tar.gz ] && echo 'ftp_v2.1.tar.gz found' || wget http://acelnmp.googlecode.com/files/ftp_v2.1.tar.gz 050 cd ../conf 051 [ -s init.d.nginx ] && echo 'init.d.nginx found' || wget https://raw.github.com/lj2007331/lnmp/master/conf/init.d.nginx 052 [ -s nginx.conf ] && echo 'nginx.conf found' || wget https://raw.github.com/lj2007331/lnmp/master/conf/nginx.conf 053 [ -s pure-ftpd.conf ] && echo 'pure-ftpd.conf found' || wget https://raw.github.com/lj2007331/lnmp/master/conf/pure-ftpd.conf 054 [ -s pureftpd-mysql.conf ] && echo 'pureftpd-mysql.conf found' || wget https://raw.github.com/lj2007331/lnmp/master/conf/pureftpd-mysql.conf 055 [ -s script.mysql ] && echo 'script.mysql found' || wget https://raw.github.com/lj2007331/lnmp/master/conf/script.mysql 056 } 057   058   059 function MySQL() 060 # install MySQL 061 { 062 cd /root/lnmp/source 063 useradd -M -s /sbin/nologin mysql 064 mkdir -p /data/mysql;chown mysql.mysql -R /data/mysql 065 tar xzf cmake-2.8.10.2.tar.gz 066 cd cmake-2.8.10.2 067 ./configure 068 make &&  make install 069 cd .. 070 tar zxf mysql-5.5.32.tar.gz 071 cd mysql-5.5.32 072 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \ 073 -DMYSQL_DATADIR=/data/mysql  \ 074 -DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock \ 075 -DWITH_INNOBASE_STORAGE_ENGINE=1 \ 076 -DENABLED_LOCAL_INFILE=1 \ 077 -DMYSQL_TCP_PORT=3306 \ 078 -DEXTRA_CHARSETS=all \ 079 -DDEFAULT_CHARSET=utf8 \ 080 -DDEFAULT_COLLATION=utf8_general_ci \ 081 -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \ 082 -DWITH_DEBUG=0 083 make && make install 084   085 /bin/cp support-files/my-medium.cnf /etc/my.cnf 086 cp support-files/mysql.server /etc/init.d/mysqld 087 chmod 755 /etc/init.d/mysqld 088 chkconfig --add mysqld 089 chkconfig mysqld on 090 cd .. 091   092 # my.cf 093 sed -i '38a ##############' /etc/my.cnf 094 sed -i '39a skip-name-resolve' /etc/my.cnf 095 sed -i '40a basedir=/usr/local/mysql' /etc/my.cnf 096 sed -i '41a datadir=/data/mysql' /etc/my.cnf 097 sed -i '42a user=mysql' /etc/my.cnf 098 sed -i '43a #lower_case_table_names = 1' /etc/my.cnf 099 sed -i '44a max_connections=1000' /etc/my.cnf 100 sed -i '45a ft_min_word_len=1' /etc/my.cnf 101 sed -i '46a expire_logs_days = 7' /etc/my.cnf 102 sed -i '47a query_cache_size=64M' /etc/my.cnf 103 sed -i '48a query_cache_type=1' /etc/my.cnf 104 sed -i '49a ##############' /etc/my.cnf 105   106 /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql 107   108 chown mysql.mysql -R /data/mysql 109 /sbin/service mysqld start 110 export PATH=$PATH:/usr/local/mysql/bin 111 echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile 112 source /etc/profile 113   114 /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$mysqlrootpwd\" with grant option;" 115 /usr/local/mysql/bin/mysql -uroot -p$mysqlrootpwd -e "delete from mysql.user where Password='';" 116 /sbin/service mysqld restart 117 } 118   119 function PHP() 120 # install PHP 121 { 122 cd /root/lnmp/source 123 tar xzf libiconv-1.14.tar.gz 124 cd libiconv-1.14 125 ./configure --prefix=/usr/local 126 make && make install 127 cd ../ 128   129 tar xzf libmcrypt-2.5.8.tar.gz 130 cd libmcrypt-2.5.8 131 ./configure 132 make && make install 133 /sbin/ldconfig 134 cd libltdl/ 135 ./configure --enable-ltdl-install 136 make && make install 137 cd ../../ 138   139 tar xzf mhash-0.9.9.9.tar.gz 140 cd mhash-0.9.9.9 141 ./configure 142 make && make install 143 cd ../ 144   145 if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then 146     ln -s /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la 147     ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so 148     ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4 149     ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8 150     ln -s /usr/local/lib/libmhash.a /usr/lib64/libmhash.a 151     ln -s /usr/local/lib/libmhash.la /usr/lib64/libmhash.la 152     ln -s /usr/local/lib/libmhash.so /usr/lib64/libmhash.so 153     ln -s /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2 154     ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1 155     ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config 156     ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /lib64/libmysqlclient.so.18 157         ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 158         ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagick 159         cp -frp /usr/lib64/libldap* /usr/lib 160 else 161     ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la 162     ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so 163     ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4 164     ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8 165     ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a 166     ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la 167     ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so 168     ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2 169     ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 170     ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config 171     ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /lib/libmysqlclient.so.18 172         ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagick 173         ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 174 fi 175   176 tar xzf mcrypt-2.6.8.tar.gz 177 cd mcrypt-2.6.8 178 /sbin/ldconfig 179 ./configure 180 make && make install 181 cd ../ 182   183 tar xzf php-5.3.26.tar.gz 184 useradd -M -s /sbin/nologin www 185 cd php-5.3.26 186 ./configure  --prefix=/usr/local/php --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-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-ftp --with-gettext --enable-zip --enable-soap --disable-debug 187 make ZEND_EXTRA_LIBS='-liconv' 188 make install 189 cp php.ini-production /usr/local/php/lib/php.ini 190   191 #php-fpm Init Script 192 cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 193 chmod +x /etc/init.d/php-fpm 194 chkconfig --add php-fpm 195 chkconfig php-fpm on 196 cd ../ 197   198 tar xzf memcache-2.2.5.tgz 199 cd memcache-2.2.5 200 /usr/local/php/bin/phpize 201 ./configure --with-php-config=/usr/local/php/bin/php-config 202 make && make install 203 cd ../ 204   205 tar xjf eaccelerator-0.9.6.1.tar.bz2 206 cd eaccelerator-0.9.6.1 207 /usr/local/php/bin/phpize 208 ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config 209 make && make install 210 cd ../ 211   212 tar xzf PDO_MYSQL-1.0.2.tgz 213 cd PDO_MYSQL-1.0.2 214 /usr/local/php/bin/phpize 215 ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql 216 make && make install 217 cd ../ 218   219 tar xzf ImageMagick-6.8.3-10.tar.gz 220 cd ImageMagick-6.8.3-10 221 ./configure 222 make && make install 223 cd ../ 224   225 tar xzf imagick-3.0.1.tgz 226 cd imagick-3.0.1 227 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 228 /usr/local/php/bin/phpize 229 ./configure --with-php-config=/usr/local/php/bin/php-config 230 make && make install 231 cd ../ 232   233 # Support HTTP request curls 234 tar xzf pecl_http-1.7.5.tgz 235 cd pecl_http-1.7.5 236 /usr/local/php/bin/phpize 237 ./configure --with-php-config=/usr/local/php/bin/php-config 238 make && make install 239 cd ../ 240   241 # Modify php.ini 242 mkdir /tmp/eaccelerator 243 /bin/chown -R www.www /tmp/eaccelerator/ 244 sed -i '808a extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"' /usr/local/php/lib/php.ini 245 sed -i '809a extension = "memcache.so"' /usr/local/php/lib/php.ini 246 sed -i '810a extension = "pdo_mysql.so"' /usr/local/php/lib/php.ini 247 sed -i '811a extension = "imagick.so"' /usr/local/php/lib/php.ini 248 sed -i '812a extension = "http.so"' /usr/local/php/lib/php.ini 249 sed -i '135a output_buffering = On' /usr/local/php/lib/php.ini 250 sed -i '848a cgi.fix_pathinfo=0' /usr/local/php/lib/php.ini 251 sed -i 's@short_open_tag = Off@short_open_tag = On@g' /usr/local/php/lib/php.ini 252 sed -i 's@expose_php = On@expose_php = Off@g' /usr/local/php/lib/php.ini 253 sed -i 's@;date.timezone [email protected] = Asia/Shanghai@g' /usr/local/php/lib/php.ini 254 sed -i 's@#sendmail_path.*@#sendmail_path = /usr/sbin/sendmail -t@g' /usr/local/php/lib/php.ini 255 echo '[eaccelerator] 256 zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so" 257 eaccelerator.shm_size="64" 258 eaccelerator.cache_dir="/tmp/eaccelerator" 259 eaccelerator.enable="1" 260 eaccelerator.optimizer="1" 261 eaccelerator.check_mtime="1" 262 eaccelerator.debug="0" 263 eaccelerator.filter="" 264 eaccelerator.shm_max="0" 265 eaccelerator.shm_ttl="0" 266 eaccelerator.shm_prune_period="0" 267 eaccelerator.shm_only="0" 268 eaccelerator.compress="0" 269 eaccelerator.compress_level="9" 270 eaccelerator.keys = "disk_only" 271 eaccelerator.sessions = "disk_only" 272 eaccelerator.content = "disk_only"' >> /usr/local/php/lib/php.ini 273   274 cat > /usr/local/php/etc/php-fpm.conf <<EOF 275 ;;;;;;;;;;;;;;;;;;;;; 276 ; FPM Configuration ; 277 ;;;;;;;;;;;;;;;;;;;;; 278   279 ;;;;;;;;;;;;;;;;;; 280 ; Global Options ; 281 ;;;;;;;;;;;;;;;;;; 282   283 [global] 284 pid = run/php-fpm.pid 285 error_log = log/php-fpm.log 286 log_level = notice 287   288 emergency_restart_threshold = 30 289 emergency_restart_interval = 1m 290 process_control_timeout = 5s 291 daemonize = yes 292   293 ;;;;;;;;;;;;;;;;;;;; 294 ; Pool Definitions ; 295 ;;;;;;;;;;;;;;;;;;;; 296   297 [www] 298   299 listen = 127.0.0.1:9000 300 listen.backlog = -1 301 listen.allowed_clients = 127.0.0.1 302 listen.owner = www 303 listen.group = www 304 listen.mode = 0666 305 user = www 306 group = www 307   308 pm = dynamic 309 pm.max_children = 32 310 pm.start_servers = 4 311 pm.min_spare_servers = 4 312 pm.max_spare_servers = 16 313 pm.max_requests = 512 314   315 request_terminate_timeout = 0 316 request_slowlog_timeout = 0 317   318 slowlog = log/$pool.log.slow 319 rlimit_files = 51200 320 rlimit_core = 0 321   322 catch_workers_output = yes 323 env[HOSTNAME] = $HOSTNAME 324 env[PATH] = /usr/local/bin:/usr/bin:/bin 325 env[TMP] = /tmp 326 env[TMPDIR] = /tmp 327 env[TEMP] = /tmp 328 EOF 329   330 # php start 331 service php-fpm start 332 } 333   334 function Nginx() 335 # install Nginx 336 { 337 cd /root/lnmp/source 338 tar xzf pcre-8.32.tar.gz 339 cd pcre-8.32 340 ./configure 341 make && make install 342 cd ../ 343   344 #tar xzf ngx_cache_purge-2.1.tar.gz 345 tar xzf nginx-1.4.1.tar.gz 346 cd nginx-1.4.1 347   348 # Modify Nginx version 349 sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION      "2.2.14"@g' src/core/nginx.h 350 sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER          "Apache/" NGINX_VERSION@g' src/core/nginx.h 351 #./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --add-module=../ngx_cache_purge-2.1 352 ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module 353 make && make install 354 cd /root/lnmp/conf 355 cp init.d.nginx /etc/init.d/nginx 356 chmod 755 /etc/init.d/nginx 357 chkconfig --add nginx 358 chkconfig nginx on 359 mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf_bk 360 cp nginx.conf /usr/local/nginx/conf/nginx.conf 361   362 #logrotate nginx log 363 echo '/usr/local/nginx/logs/*.log { 364 daily 365 rotate 5 366 missingok 367 dateext 368 compress 369 notifempty 370 sharedscripts 371 postrotate 372     [ -f /usr/local/nginx/logs/nginx.pid ] && kill -USR1 `cat /usr/local/nginx/logs/nginx.pid` 373 endscript 374 }' > /etc/logrotate.d/nginx 375   376 service nginx restart 377 } 378   379 function Pureftp() 380 # install Pureftpd and pureftpd_php_manager 381 { 382 cd /root/lnmp/source 383 tar xzf pure-ftpd-1.0.36.tar.gz 384 cd pure-ftpd-1.0.36 385 ./configure --prefix=/usr/local/pureftpd CFLAGS=-O2 --with-mysql=/usr/local/mysql --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg  --with-throttling --with-uploadscript --with-language=simplified-chinese 386 make && make install 387 cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin 388 chmod +x /usr/local/pureftpd/sbin/pure-config.pl 389 cp contrib/redhat.init /etc/init.d/pureftpd 390 sed -i 's@fullpath=.*@fullpath=/usr/local/pureftpd/sbin/$prog@' /etc/init.d/pureftpd 391 sed -i 's@pureftpwho=.*@pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho@' /etc/init.d/pureftpd 392 sed -i 's@/etc/pure-ftpd.conf@/usr/local/pureftpd/pure-ftpd.conf@' /etc/init.d/pureftpd 393 chmod +x /etc/init.d/pureftpd 394 chkconfig --add pureftpd 395 chkconfig pureftpd on 396   397 cd /root/lnmp/conf 398 /bin/cp pure-ftpd.conf /usr/local/pureftpd/ 399 /bin/cp pureftpd-mysql.conf /usr/local/pureftpd/ 400 mysqlftppwd=`cat /dev/urandom | head -1 | md5sum | head -c 8` 401 sed -i 's/tmppasswd/'$mysqlftppwd'/g' /usr/local/pureftpd/pureftpd-mysql.conf 402 sed -i 's/mysqlftppwd/'$mysqlftppwd'/g' script.mysql 403 sed -i 's/ftpmanagerpwd/'$ftpmanagerpwd'/g' script.mysql 404 /usr/local/mysql/bin/mysql -uroot -p$mysqlrootpwd< script.mysql 405 service pureftpd start 406   407 mkdir -p /data/admin 408 cd ../source 409 tar xzf ftp_v2.1.tar.gz 410 mv ftp /data/admin;chown -R www.www /data/admin 411 sed -i 's/tmppasswd/'$mysqlftppwd'/g' /data/admin/ftp/config.php 412 sed -i "s/myipaddress.com/`echo $IP`/g" /data/admin/ftp/config.php 413 sed -i 's/127.0.0.1/localhost/g' /data/admin/ftp/config.php 414 sed -i 's@iso-8859-1@UTF-8@' /data/admin/ftp/language/english.php 415 rm -rf  /data/admin/ftp/install.php 416 echo '<?php 417 phpinfo() 418 ?>' > /data/admin/index.php 419 cd ../ 420 } 421   422 function Iptables() 423 { 424 cat > /etc/sysconfig/iptables << EOF 425 # Firewall configuration written by system-config-securitylevel 426 # Manual customization of this file is not recommended. 427 *filter 428 :INPUT DROP [0:0] 429 :FORWARD ACCEPT [0:0] 430 :OUTPUT ACCEPT [0:0] 431 -A INPUT -i lo -j ACCEPT 432 -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 433 -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 434 -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 435 -A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT 436 -A INPUT -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT 437 -A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT 438 -A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT 439 COMMIT 440 EOF 441 service iptables restart 442 } 443   444 Download 2>&1 | tee -a /root/lnmp/lnmp_install.log 445 Download 446 chmod +x /root/lnmp/init.sh 447 /root/lnmp/init.sh 2>&1 | tee -a /root/lnmp/lnmp_install.log 448 echo -e "\033[32minitialized successfully\033[0m" 449 MySQL 2>&1 | tee -a /root/lnmp/lnmp_install.log 450 [ -d "/usr/local/mysql" ] && echo -e "\033[32mMySQL install successfully\033[0m" || echo "MySQL install failed" 451 PHP 2>&1 | tee -a /root/lnmp/lnmp_install.log 452 [ -d "/usr/local/php" ] && echo -e "\033[32mPHP install successfully\033[0m" || echo "PHP install failed" 453 Nginx 2>&1 | tee -a /root/lnmp/lnmp_install.log 454 [ -d "/usr/local/nginx" ] && echo -e "\033[32mNginx install successfully\033[0m" || echo "Nginx install failed" 455 Pureftp 2>&1 | tee -a /root/lnmp/lnmp_install.log 456 [ -d "/usr/local/pureftpd" ] && echo -e "\033[32mPureftpd install successfully\033[0m" || echo "Pureftpd install failed" 457 Iptables 2>&1 | tee -a /root/lnmp/lnmp_install.log 458   459 echo "################Congratulations####################" 460 echo "The path of some dirs:" 461 echo -e "Nginx dir:                     \033[32m/usr/local/nginx\033[0m" 462 echo -e "MySQL dir:                     \033[32m/usr/local/mysql\033[0m" 463 echo -e "PHP dir:                       \033[32m/usr/local/php\033[0m" 464 echo -e "Pureftpd dir:                  \033[32m/usr/local/pureftpd\033[0m" 465 echo -e "Pureftp_php_manager dir:       \033[32m/data/admin\033[0m" 466 echo -e "MySQL Password:                \033[32m${mysqlrootpwd}\033[0m" 467 echo -e "Pureftp_manager url:           \033[32mhttp://$IP/ftp\033[0m" 468 echo -e "Pureftp_manager Password:      \033[32m${ftpmanagerpwd}\033[0m" 469 echo "###################################################"  
Copyright © Linux教程網 All Rights Reserved