Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to automatically install Shell scripts for LNMP server environment

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how to automatically install the Shell script of the LNMP server environment". In the daily operation, I believe that many people have doubts about how to automatically install the Shell script of the LNMP server environment. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to automatically install the Shell script of the LNMP server environment". Next, please follow the editor to study!

This script has been used on the production server for more than a year, and the script advocates simplicity and beauty, and it only takes a script to automatically configure LNMP on any server with a network.

This script will create a packages directory under the script execution directory to store the software needed by LNMP. You can delete the directory after installation.

How to use it:

1. Save the contents of the shell script as nginx_php

2. Run under root permission:

The code is as follows:

Chmod uplix nginx_php;. / nginx_php init;. / nginx_php ins_mysql-server;. / nginx_php ins_mysql-client;. / nginx_php ins_php52;. / nginx_php ins_php52-ext;. / nginx_php ins_mysql

You need to enter a y confirmation while the script is running.

The Shell script contains the following:

The code is as follows:

# / bash

# author:coralzd powered by www.freebsdsystem.org

# written by coralzd 2011.05.05

# version 0.1.3 build 20110505

Nginx_dir= "/ usr/local/nginx"

Php52_dir= "/ usr/local/php52"

Mysql_dir= "/ usr/local/mysql"

Function init ()

{

LANG=C

Yum-y install wget 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

Read-p "Now,will download nginxphp software...Y | y:" nginxphp

Case "$nginxphp" in

Y | y)

Echo-n "starting download nginx_php..."

Cat > list / etc/ld.so.conf.d/usr_local_lib.conf

Cp nginx.conf / usr/local/nginx/conf/

Cp fcgi.conf / usr/local/nginx/conf/

Echo "nginx installed sucussfully!"

}

Function ins_mysql-server ()

{

Cd packages/

Tar zxf mysql-5.1.52.tar.gz

Cd mysql-5.1.52

CHOST= "x86_64-pc-linux-gnu"

CFLAGS= "- march=nocona-O2-pipe"

CXXFLAGS= "${CFLAGS}"

. / configure "--prefix=$ {mysql_dir}"-- with-server-suffix=-DZWWW "--with-mysqld-user=mysql"-- without-debug ""-- with-charset=utf8 ""-- with-extra-charsets=all ""-- with-pthread ""-- with-big-tables "--enable-thread-safe-client"-- enable-assembler "--with-readline"-- with-ssl "--enable -local-infile "--with-plugins=partition Myisammrg "--without-ndb-debug"

Make & & make install

Cp support-*/mysql.server / etc/init.d/mysqld

Cd / usr/local/mysql

Chown-R mysql:mysql.

Rm-rf sql-bench mysql-test

Echo "mysql server 5.1.52 installed successfully!"

}

Function ins_mysql-client ()

{

Cd packages/

Tar zxf mysql-5.1.52.tar.gz

Cd mysql-5.1.52

CHOST= "x86_64-pc-linux-gnu"

CFLAGS= "- march=nocona-O2-pipe"

CXXFLAGS= "${CFLAGS}"

. / configure "--prefix=$ {mysql_dir}"-- with-mysqld-user=mysql "--without-debug"-- with-charset=utf8 ""-- with-extra-charsets=all ""-- with-pthread ""-- with-big-tables ""-- enable-thread-safe-client "--enable-assembler"-- with-readline "--with-ssl"-- enable-local-infile "--without-server"

Make & & make install

Cd / usr/local/mysql

Chown-R mysql:mysql.

Rm-rf sql-bench mysql-test

Echo "mysql client 5.1.52 installed successfully!"

}

Function ins_php52 ()

{

Cd packages/

Tar zxf libiconv-1.13.1.tar.gz

Cd libiconv-1.13.1/

. / configure-- prefix=/usr/local

Make

Make install

Cd.. /

Tar zxf 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.. /.. /

Tar zxf 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

Ln-s / usr/local/bin/libmcrypt-config / usr/bin/libmcrypt-config

Tar zxf mcrypt-2.6.8.tar.gz

Cd mcrypt-2.6.8/

/ sbin/ldconfig

. / configure

Make

Make install

Cd.. /

Tar zxf php-5.2.17.tar.gz

Gzip-cd php-5.2.17-fpm-0.5.14.diff.gz | patch-d php-5.2.17- p1

Cd php-5.2.17/

. / configure-- prefix=$ {php52_dir}-- with-config-file-path=$ {php52_dir} / etc-- with-mysql=$ {mysql_dir}-- with-mysqli=$ {mysql_dir} / 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-ldap--with-ldap-sasl-with-xmlrpc-enable-zip-enable-soap

Make ZEND_EXTRA_LIBS='-liconv'

Make install

Cd..

Cp php.ini / usr/local/php52/etc/

Cp php-fpm.conf / usr/local/php52/etc/

Echo "/ usr/local/mysql/lib/mysql" > > / etc/ld.so.conf.d/mysql_lib.conf

/ sbin/ldconfig

Echo "php52 installed successfully!"

}

Function ins_php52-ext ()

{

Cd packages/

Tar zxf memcache-2.2.5.tgz

Cd memcache-2.2.5/

${php52_dir} / bin/phpize

. / configure-- with-php-config=$ {php52_dir} / bin/php-config

Make

Make install

Cd.. /

Tar jxf eaccelerator-0.9.6.1.tar.bz2

Cd eaccelerator-0.9.6.1/

${php52_dir} / bin/phpize

. / configure-- enable-eaccelerator=shared-- with-php-config=$ {php52_dir} / bin/php-config

Make

Make install

Cd.. /

Tar zxf PDO_MYSQL-1.0.2.tgz

Cd PDO_MYSQL-1.0.2/

${php52_dir} / bin/phpize

. / configure-- with-php-config=$ {php52_dir} / bin/php-config-- with-pdo-mysql=$ {mysql_dir}

Make

Make install

Cd.. /

Tar zxf ImageMagick.tar.gz

Cd ImageMagick-6.5.1-2 /

. / configure

Make

Make install

Cd.. /

Tar zxf imagick-2.3.0.tgz

Cd imagick-2.3.0/

${php52_dir} / bin/phpize

. / configure-- with-php-config=$ {php52_dir} / bin/php-config

Make

Make install

Cd.. /

Echo "php52 extension installed successfully!"

}

Case $1 in

Init)

Init

Ins_mysql-server)

Ins_mysql-server

Ins_mysql-client)

Ins_mysql-client

Ins_nginx)

Ins_nginx

Ins_php52)

Ins_php52

Ins_php52-ext)

Ins_php52-ext

*)

Echo "Usage: `basename $0` {init | ins_mysql-server | ins_mysql-client | ins_php52 | ins_php52-ext | ins_mysql}"

Esac

At this point, the study on "how to automatically install the Shell script for the LNMP server environment" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report