vnsc威尼斯城官方网站LNMP+法斯特CGI平台搭建脚本

LNMP+法斯特CGI平台搭建脚本

本脚本首要介绍LNMP+法斯特CGI平台的搭建脚本,必要预备的安装包如下:

cmake-2.8.10.2.tar.gz
libevent-2.0.21-stable.tar.gz
libmcrypt-2.5.8.tar.gz
mhash-0.9.9.9.tar.gz
nginx-1.2.0.tar.gz
php-5.4.9.tar.gz
libiconv-1.13.tar.gz
mysql-5.5.13.tar.gz

是因为剧本供给,将上述安装包统后生可畏打包为lnmp+memcached.zip,使用时将该脚本放在该安装包相符的目录。

先安装信任包,供给将yum源配好,在此边不再赘言,接下去是本子内容:

#!/bin/bash
echo “++++++++++++++++++++++++++++++++++++++++++”
echo “+                  检查yum酒店配置                    +”
echo “++++++++++++++++++++++++++++++++++++++++++”
yum clean all > /dev/null
yum list > /dev/null
if [ $? -eq 0 ];then
    echo  “yum仓库配置寻常”
    sleep 1
else
    echo “yum旅馆配置不行,请检查yum配置”
fi
echo “++++++++++++++++++++++++++++++++++++++++++”
echo “+          安装依赖软件包                +”
echo “++++++++++++++++++++++++++++++++++++++++++”
yum -y install gcc gcc-c++ autoconf automake bison flex freetype
freetype-devel fontconfig-devel gettext-devel libjpeg libjpeg-devel
libpng libpng-devel libxml2 libxml2-devel libtool libtool-ltdl
libtool-ltdl-devel libtiff-devel libXpm-devel libicu libicu-devel libidn
libidn-devel libxslt libxslt-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 openssl
openssl-devel openldap openldap-devel nss_ldap openldap-clients
openldap-servers pcre pcre-devel pam-devel vim-enhanced mysql-devel

unzip lnmp+memcached.zip

installnginx() {
read -p “即将早先安装nginx,是还是不是起头设置?(Y/N)”
command_nginx_install
if [ $command_nginx_install == N ] || [ $command_nginx_install ==
n ];then
    echo “安装已撤销!”
    exit
elif [ $command_nginx_install == Y ] || [ $command_nginx_install
== Y ];then
    echo “安装正在初始……”
    sleep 2
fi
cd lnmp+memcached
useradd -s /sbin/nologin -M nginx
tar -zxf nginx-1.2.0.tar.gz -C /usr/src/
cd /usr/src/nginx-1.2.0/
 ./configure –prefix=/usr/local/nginx
–pid-path=/usr/local/nginx/nginx.pid –user=nginx –group=nginx
–with-http_ssl_module –with-http_flv_module
–with-http_stub_status_module –with-http_gzip_static_module
–http-client-body-temp-path=/usr/local/nginx/client
–http-proxy-temp-path=/usr/local/nginx/proxy
–http-fastcgi-temp-path=/usr/local/nginx/fcgi
–http-uwsgi-temp-path=/usr/local/nginx/uwsgi
–http-scgi-temp-path=/usr/local/nginx/scgi –with-pcre
if [ $? -eq 0 ];then
    echo “配置达成,希图编写翻译安装”
else
    echo “配置战败,请检查”
    exit
fi
make && make install
if [ $? -eq 0 ];then
    echo “nginx安装到位”
else
    echo “nginx安装失利,请检查”
    exit
fi
}
installmysql() {
echo “##############################”
echo “#    开首安装mysql数据库……  #”
echo “##############################”
read -p “将在上马设置mysql数据库,是或不是继续?(Y/N)”
command_mysql_install
if [ $command_mysql_install == N ] || [ $command_mysql_install ==
n ];then
    echo “安装已吊销!”
    exit
elif [ $command_mysql_install == Y ] || [ $command_mysql_install
== Y ];then
    echo “安装正在开头……”
    sleep 2
fi
cd /root/lnmp+memcached
useradd -s /sbin/nologin -M mysql
echo “~~~~~~~”
echo “~          安装cmake工具            ~”
echo “~~~~~~~”
tar -zxf cmake-2.8.10.2.tar.gz -C /usr/src/
cd /usr/src/cmake-2.8.10.2/
./bootstrap –prefix=/usr/local/cmake
make && make install
echo “~~~~~~~”
echo “~          安装mysql数据库          ~”
echo “~~~~~~~”
cd /root/lnmp+memcached
tar -zxf mysql-5.5.13.tar.gz -C /usr/src/
cd /usr/src/mysql-5.5.13/
/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DSYSCONFDIR=/etc -DMYSQL_DATADIR=/usr/local/mysql/data
-DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
-DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DWITH_READLINE=1
-DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
if [ $? -eq 0 ];then
    echo “配置达成,将要上马编写翻译安装”
else
    echo “配置退步,请检查!”
    exit
fi
make && make install
if [ $? -eq 0 ];then
    echo “mysql安装到位,思虑早先化”
else
    echo “mysql安装败北,请检查!”
    exit
fi
cd /usr/local/mysql/
chown -R mysql.mysql .
./scripts/mysql_install_db –user=mysql
cd /usr/src/mysql-5.5.13/support-files/
cp my-medium.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig –add mysqld
service mysqld start > /dev/null
cd /usr/local/mysql/
./scripts/mysql_install_db –user=mysql
export PATH=/usr/local/mysql/bin/:$PATH
echo “export  PATH=/usr/local/mysql/bin:$PATH” >> /etc/bashrc
echo “/usr/local/mysql/lib/” >> /etc/ld.so.conf
ldconfig
if [ $? -eq 0 ];then
    echo “mysql初叶化完成”
else
    echo “mysql早先化退步,请检查!”
    exit
fi
}
installphp() {
echo “##############################”
echo “#      开端设置PHP服务        #”
echo “##############################”
read -p “将要安装PHP服务,是还是不是继续?(Y/N)” command_php_install
if [ $command_php_install == n ] || [ $command_php_install == N
];then
    echo “安装撤废”
    exit
elif [ $command_php_install == y ] || [ $command_php_install == Y
];then
    cd /root/lnmp+memcached
    echo “初阶设置PHP”
fi
echo “##############################”
echo “#        安装PHP的依附包        #”
echo “##############################”
tar -zxf mhash-0.9.9.9.tar.gz -C /usr/src
cd /usr/src/mhash-0.9.9.9
./configure
make && make install
if [ $? -eq 0 ];then
    echo “mhash安装完结”
else
    echo “mhash安装战败”
    exit
fi
sleep 2
cd /root/lnmp+memcached
tar -zxf libmcrypt-2.5.8.tar.gz -C /usr/src
cd /usr/src/libmcrypt-2.5.8
./configure
make && make install
cd libltdl/
./configure –with-gmetad –enable-gexec –enable-ltdl-install
make && make install
if [ $? -eq 0 ];then
        echo “libmcrypt安装到位”
else
        echo “libmcrypt安装退步”
        exit
fi
sleep 2
cd /root/lnmp+memcached
tar -zxf libiconv-1.13.tar.gz -C /usr/src
cd /usr/src/libiconv-1.13
./configure
make && make install
if [ $? -eq 0 ];then
        echo “libconv安装完结”
else
        echo “libconv安装退步”
        exit
fi
sleep 2
cd /root/
ln -sv /usr/local/lib/libmcrypt* /usr/lib/
ln -sv /usr/local/lib/libmhash.* /usr/lib/
ldconfig -v
echo
“##############################################”
echo “#                伊始设置PHP主程序                #”
echo
“##############################################”
cd /root/lnmp+memcached
tar -zxf php-5.4.9.tar.gz -C /usr/src/
cd /usr/src/php-5.4.9
./configure –prefix=/usr/local/php5nginx
–with-config-file-path=/usr/local/php5nginx/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-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-zip
–enable-soap
if [ $? -eq 0 ];then
    echo “php配置实现”
else
    echo “php配置退步,请检查!”
    exit
fi
make ZEND_EXTRA_LIBS=’-liconv’
make install
if [ $? -eq 0 ];then
    echo “php安装到位,筹划带头化”
else
    echo “php安装失利,请检查!”
    exit
fi
cp php.ini-production /usr/local/php5nginx/etc/php.ini
cp /usr/local/php5nginx/etc/php-fpm.conf.default
/usr/local/php5nginx/etc/php-fpm.conf
cd /usr/src/php-5.4.9/sapi/fpm/
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig –add php-fpm
service php-fpm start
if [ $? -eq 0 ];then
    echo “php初叶化完结”
else
    echo “php起头化失利,请检查!”
    exit
fi
}

case $1 in
nginx)
    installnginx ;;
mysql)
    installmysql ;;
php)
    installphp ;;
lnmp)
    installnginx
    installmysql
    installphp ;;
*)
    echo
“本脚本可安装nginx、mysql、php以至完整搭建lnmp平台,请输入要安装的服务。举个例子:sh
nginx.sh lnmp”;;
esac

该脚本使用时得以给脚本加多试行权限:

chmod +x lnmp.sh

那会儿平素使用./lnmp.sh 安装部分
就能够进行安装,注意,此脚本须要内定要设置的有些,比如要设置mysql,则在实施时候输入./lnmp.sh
mysql。

若留意气风发台裸机上安装lnmp平台,则能够使用./lnmp.sh lnmp来任何搭建lnmp平台。

是因为我们在安装时或然数次实行脚本,所以大家得以将脚本中使用yum安装部分单独保存为八个剧本,可能封装为一个函数,在本子后增加二个case来调用。

CentOS 6.4 下的LNMP 临蓐环���搭建及安装脚本

生儿育女条件实用之LNMP构造的编写翻译安装+SSL加密完毕

LNMP 全职能编写翻译安装 for CentOS 6.3笔记

CentOS 6.3 安装LNMP (PHP 5.4,MyySQL5.6)

在陈设LNMP的时候遭逢Nginx运维退步的2个难题

Ubuntu安装Nginx php5-fpm MySQL(LNMP意况搭建卡塔尔

本文永远更新链接地址:

本脚本首要介绍LNMP+FastCGI平台的搭建脚本,须求预备的安装包如下:
cmake-2.8.10.2.tar.gz libevent-2.0.21-stable.tar.gz libmcr…

LNMP:Linux+Nginx+Mysql+Perl/PHP/Python风流倜傥组常用来搭建动态网址依旧服务器的开源软件,本人都以各自独立的主次,可是因为常被放在一块儿行使,具有了越来越高的包容度,协同构成了二个无敌的Web应用程序平台。

更新源:

1.1、专门的职业原理教学表达

1、        用户请求的静态文件,由nginx服务器处理,根据静态的location配置进行处理    用户请求的动态文件,由php服务进行处理,根据动态的location配置进行处理2、    nginx服务接收到动态请求,会将请求抛给FastCGI,在由FastCGI将动态请求交给PHP3、    PHP如果可以处理,就直接通过FastCGI返回给nginx,如果不可以处理,便会请求后端数据库,在返回给nginx

附图

vnsc威尼斯城官方网站 1

Nginx:**nginx**是三个高质量的HTTP和反向代理服务器,对于拍卖静态页面有那超高的工夫,在高连接出现的场合下,Nginx是Apache服务器不错的代替品,並且其体量较apache比较要小相当多,但效果与利益上并不远逊色于apache,因它的安居、足够的成效集、示例配置文件和低系统财富的消耗而名闻遐迩。

apt-get install update

1.2、LNMP 安装

1.3、基本管理数据库

show databases;#查询默认的数据库信息use mysql;#表示选择使用一个数据库,相当于cd进入一个数据库select database();#表示查看当前所在数据库,类似于pwd命令的功能select user();#查看当前登录数据库的用户,类似于whoami命令select user,host from mysql.user;#查看可以登录mysql数据库的目录,以及都可以从哪里进行管理create database wordpress;#创建数据库drop database wordpress;#删除数据库grant all on wordpress.* to 'wordpress'@'localhost' indentified by 'oldboy123';#添加用户信息grant all on wordpress.* to 'wordpress'@'172.16.1.%' indentified by 'oldboy123'#添加用户信息dropuserwordpress@'172.16.1.8'#删除用户信息

PHP:PHP
是一门简单而卓有效用的编制程序语言,它疑似粘连剂,能够将 LAMP 系统全部任何的零件黏合在合作。您能够运用 PHP 编写能访问 MySQL 数据库中的数据和 Linux 提供的意气风发部分表征的动态内容。

关闭apache2:

    Mysql**:**MySQL是一个Mini关系型数据库管理体系,由于其体量小、速度快、总体具备开销低,特别是开放源码那风华正茂个性,多数中型Mini型网址为了收缩网址全体具备资金财产而选拔了MySQL作为网站数据库。

/etc/init.d/apache2 stop

注:此番尝试搭建LNMP的服务器IP地址为:172.16.4.1

安装nginx:

风华正茂、源码编写翻译安装Nginx

1、由于要求这里我们使用的是源码编写翻译安装Nginx,所以大家须求塑造开采条件,即需求设置Development libraries和Development tools那多个开采包组,可是由于Development libraries包组信任于Development tools包组,所以当安装Development libraries包组时Development tools里的大多包实在早就安装过了,所以那边大家只设置Development libraries这么些包组,命令如下:

#yum
groupinstall “Development libraries” –y

2、化解信任关系:

Nginx的安装必要凭仗于gcc、openssl-devel、pcre-devel、zlib-devel那几个包,所以在动用源码安装早先请确定保证那多个包已经设置,命令如下:

#rpm –ivh gcc
openssl-devel pcre-devel zlib-devel

注:日常情状下,那么些包已经安装过。

3、为nginx建构安全运会转账户:

# groupadd -r
nginx

# useradd -r -g
nginx -s /sbin/nologin -M nginx

4、编写翻译安装nginx-1.0.14

下载nginx-1.0.14.tar.gz到本地,下载地址:

实行以下命令:

# tar xf nginx-1.0.14.tar.gz # cd nginx-1.0.14 #./configure \ --prefix=/usr \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx/nginx.pid  \ --lock-path=/var/lock/nginx.lock \ --user=nginx \ --group=nginx \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/tmp/nginx/client/ \ --http-proxy-temp-path=/var/tmp/nginx/proxy/ \ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ --http-scgi-temp-path=/var/tmp/nginx/scgi \ --with-pcre # make && make install 

4、提供SysV服务脚本/etc/rc.d/init.d/nginx,内容如下:

#!/bin/sh # # nginx - this script starts and stops the nginx daemon # chkconfig:   - 85 15 # description:  Nginx is an HTTP(S) server, HTTP(S) reverse \ #               proxy and IMAP/POP3 proxy server # processname: nginx # config:      /etc/nginx/nginx.conf # config:      /etc/sysconfig/nginx # pidfile:     /var/run/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() {    # make required directories    user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`    options=`$nginx -V 2>&1 | grep 'configure arguments:'`    for opt in $options; do        if [ `echo $opt | grep '.*-temp-path'` ]; then            value=`echo $opt | cut -d "=" -f 2`            if [ ! -d "$value" ]; then                # echo "creating" $value                mkdir -p $value && chown -R $user $value            fi        fi    done } start() {     [ -x $nginx ] || exit 5     [ -f $NGINX_CONF_FILE ] || exit 6     make_dirs     echo -n $"Starting $prog: "     daemon $nginx -c $NGINX_CONF_FILE     retval=$?     echo     [ $retval -eq 0 ] && touch $lockfile     return $retval } stop() {     echo -n $"Stopping $prog: "     killproc $prog -QUIT     retval=$?     echo     [ $retval -eq 0 ] && rm -f $lockfile     return $retval } restart() {     configtest || return $?     stop     sleep 1     start } reload() {     configtest || return $?     echo -n $"Reloading $prog: "     killproc $nginx -HUP     RETVAL=$?     echo } force_reload() {     restart } configtest() {   $nginx -t -c $NGINX_CONF_FILE } rh_status() {     status $prog } rh_status_q() {     rh_status >/dev/null 2>&1 } case "$1" in     start)         rh_status_q && exit 0         $1         ;;     stop)         rh_status_q || exit 0         $1         ;;     restart|configtest)         $1         ;;     reload)         rh_status_q || exit 7         $1         ;;     force-reload)         force_reload         ;;     status)         rh_status         ;;     condrestart|try-restart)         rh_status_q || exit 0             ;;     *)         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"         exit 2 esac 

vnsc威尼斯城官方网站 2

apt-get install nginx

安装MYSQL:

apt-get install mysql-server 
#连天输入四遍相符密码,密码为mysql管理账户所使用

安装PHP:

apt-get install php5-fpm php5-mysql

配置PHP,修改php.ini文件:

cp /etc/php5/fpm/php.ini /etc/php5/fpm/php.ini.back  #备份php.ini文件

vim /etc/php5/fpm/php.ini

cgi.fix_pathinfo=0 #废除有安全隐患的pathinfo情势

启动php-fpm

service php5-fpm restart

计划nginx,让其利用php5-fpm进度

cp /etc/nginx/sites-available/default
/etc/nginx/sites-available/default.back

vim /etc/nginx/sites-available/default

server {

            listen 80 default_server;

            listen [::]:80 default_server ipv6only=on;

            root /usr/share/nginx/html;

            index index.html index.htm;

            server_name localhost;

        location / {

            # First attempt to serve request as file, then

            # as directory, then fall back to displaying a 404.

            try_files $uri $uri/ =404;

            # Uncomment to enable naxsi on this location

            # include /etc/nginx/naxsi.rules

        }

            error_page 500 502 503 504 /50x.html;

        location = /50x.html {

            root /usr/share/nginx/html;

        }

        location ~ \.php$ {

            #       try_files $uri =404;

            fastcgi_split_path_info ^(.+\.php)(/.+)$;

            #       # NOTE: You should have “cgi.fix_pathinfo = 0;”
in php.ini

            #

            #       # With php5-cgi alone:

            #       fastcgi_pass 127.0.0.1:9000;

            #       # With php5-fpm:

                fastcgi_pass unix:/var/run/php5-fpm.sock;

                fastcgi_index index.php;

            #       fatcgi_param SCRITP_FILENAME
$document_root$fastcgi_script_name;

                include fastcgi_params;

        }

}

重启nginx服务:

service nginx restart

创造info.php测量检验文件:

vim /usr/share/nginx/html/info.php

<?php

phpinfo();

?>

浏览器测验:

http://IP/info.php

将成立的php网页页面原来的著作件上传至/usr/share/nginx/html/目录下就可以

相关文章