elnmp安装脚本

LAMP与LNMP

apache(https)里面装上php模块,apache是一个整体的服务,有php解释php语言的功能,php不以一个服务一个进程这样启动。

LNMP需要启动php服务,php跟mysql交互。

nginx处理静态文件,php处理交互的请求,nginx可以支持用户并发可达好几万,apache做不到。

mysql5.6.43自动安装脚本

不同版本是不通用的,5.7的安装方式就已经不一样,需要看官方说明;
mysql的安装跟mariadb的安装基本上是一模一样。
是在全新的centos7系统上测试安装,所以不会缺少包,测试多次成功。

#! /bin/bash
cd /usr/local/src
yum install -y wget
   wget -c  http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
     tar -zxvf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.6.43-linux-glibc2.12-x86_64 ../mysql
    cd ../mysql
     useradd mysql
     mkdir -p /data/mysql
    chown mysql:mysql /data/mysql
     yum install -y perl-5.16.3-294.el7_6.x86_64
   yum install -y perl-Data-Dumper
    yum install -y libaio-devel
    ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
sleep 10
    cp support-files/mysql.server /etc/init.d/mysqld
     chkconfig --add mysqld
        sed -r '45,48s/(basedir=)(.*)/\1\/usr\/local\/mysql/' -i /etc/init.d/mysqld
        sed -r '45,48s/(datadir=)(.*)/\1\/data\/mysql/' -i /etc/init.d/mysqld
        sed -r '2,3s/(datadir=)(.*)/\1\/data\/mysql/' -i /etc/my.cnf
        sed -r '2,3s/(socket=)(.*)/\1\/tmp\/mysql.sock/' -i /etc/my.cnf
        sed -r '12,13s/(log-error=)(.*)/\1\/var\/log\/mysql.log/' -i /etc/my.cnf
        sed -r '12,13s/(pid-file=)(.*)/\1\/var\/run\/mysql.pid/' -i /etc/my.cnf
        service mysqld start
        if [ $? -eq 0 ]; then
        echo "mysqld start successfully"
        else
        echo "fault"
        fi

安装mariadb10.2.27的脚本

需要先把二进制文件下载好,下载时间较长,不适合在脚本里下载;

#! /bin/bash
cd /usr/local/src
#yum install -y wget
  # wget -c  http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
     tar -zxvf mariadb-10.2.27-linux-glibc_214-x86_64.tar.gz		#change to the packet name;
mv mariadb-10.2.27-linux-glibc_214-x86_64.tar ../mysql			#change to the packet name;
    cd ../mysql
     useradd mysql
     mkdir -p /data/mysql
    chown mysql:mysql /data/mysql
     yum install -y perl-5.16.3-294.el7_6.x86_64
   yum install -y perl-Data-Dumper
    yum install -y libaio-devel
    ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
sleep 10
    cp support-files/mysql.server /etc/init.d/mysqld
     chkconfig --add mysqld
        sed -r '45,48s/(basedir=)(.*)/\1\/usr\/local\/mysql/' -i /etc/init.d/mysqld
        sed -r '45,48s/(datadir=)(.*)/\1\/data\/mysql/' -i /etc/init.d/mysqld
        #if use the system default file use below sed, or move the file support-files/my-*.cnf to /etc/my.cnf;
        sed -r '2,3s/(datadir=)(.*)/\1\/data\/mysql/' -i /etc/my.cnf
        sed -r '2,3s/(socket=)(.*)/\1\/tmp\/mysql.sock/' -i /etc/my.cnf
        sed -r '12,13s/(log-error=)(.*)/\1\/var\/log\/mysql.log/' -i /etc/my.cnf
        sed -r '12,13s/(pid-file=)(.*)/\1\/var\/run\/mysql.pid/' -i /etc/my.cnf
        service mysqld start
        if [ $? -eq 0 ]; then
        echo "mysqld start successfully"
        else
        echo "fault"
        fi

安装mysql5.6.43后安装php5.6.39脚本

安装php7也只是把文件更换一下,相应的语句修改一下,都是可以安装的。

#!/bin/bash
# need to download the php file and change the tar phase
#download php in shell used to be failed
# prepare the php-fpm.conf file in /tmp
   cd /usr/local/src
     yum install -y bzip2
        sleep 5
    tar -jxvf php-5.6.39.tar.bz2
     sleep 5
        mv php-5.6.39 php5.6
     cd php5.6/
     yum install -y gcc-plugin-devel.x86_64
     yum install -y libxml2-devel
     yum install -y openssl-devel.x86_64
     yum install -y libcurl-devel
     yum install -y libjpeg-turbo-devel
     yum install -y libpng-devel
     yum install -y freetype-devel
     yum install -y epel-release
     yum install -y libmcrypt-devel
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl  --with-openssl
     make
   make install
        sleep 10
     cp /usr/local/src/php5.6/php.ini-production /usr/local/php-fpm/etc/php.ini
     cp  /usr/local/src/php5.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chkconfig --add php-fpm
   chmod 755 /etc/init.d/php-fpm
     useradd -s /sbin/nologin php-fpm
        mv /tmp/php-fpm.conf /usr/local/php-fpm/etc/php-fpm.conf
service php-fpm start
if  [ $? -eq 0 ]; then
        echo "php-fpm installed successfully"
else
        echo "fault"
fi

/usr/local/php-fpm/sbin/php-fpm
-m
-i
-t

安装mariadb10.2.27后安装php5.6.39脚本

./configure要关联到mysql5.6的解压缩文件(tar后就可以),而关联到mariadb安装后的目录下,会缺少很多文件,这些文件可以从官网下载手动生成,但是很麻烦,依赖太多。用如下方法,更有效,简单。
php-fpm.conf内容如下:(可根据自己要求修改)

[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
listen.mode = 666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
#!/bin/bash
# need to download the php file and change the tar phase
# prepare the php-fpm.conf file in /tmp
# need a mysql5.6 file in /usr/local/
   cd /usr/local/src
 #    wget -c http://cn2.php.net/distributions/php-5.6.39.tar.bz2
     yum install -y bzip2
        sleep 10

     tar -jxvf php-5.6.39.tar.bz2
     sleep 5
        mv php-5.6.39 php5.6
     cd php5.6/
     yum install -y gcc-plugin-devel.x86_64
     yum install -y libxml2-devel
     yum install -y openssl-devel.x86_64
     yum install -y libcurl-devel
     yum install -y libjpeg-turbo-devel
     yum install -y libpng-devel
     yum install -y freetype-devel
     yum install -y epel-release
     yum install -y libmcrypt-devel
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql5.6 --with-mysqli=/usr/local/mysql5.6/bin/mysql_config --with-pdo-mysql=/usr/local/mysql5.6 --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl   
  make
   make install
        sleep 10
     cp /usr/local/src/php5.6/php.ini-production /usr/local/php-fpm/etc/php.ini
     cp  /usr/local/src/php5.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chkconfig --add php-fpm
   chmod 755 /etc/init.d/php-fpm
     useradd -s /sbin/nologin php-fpm
        mv /tmp/php-fpm.conf /usr/local/php-fpm/etc/php-fpm.conf
service php-fpm start
if  [ $? -eq 0 ]; then
        echo "php-fpm installed successfully"
else
        echo "fault"
fi

安装mariadb10.2.27后安装php7.3.0脚本

#!/bin/bash
# need to download the php file and change the tar phase
# need a mysql5.6 file in /usr/local/
   cd /usr/local/src
 #    wget -c http://cn2.php.net/distributions/php-5.6.39.tar.bz2
     yum install -y bzip2
        sleep 10
tar -jxvf php-7.3.0.tar.bz2
     sleep 5
        mv php-7.3.0 php7.3
     cd php7.3/
     yum install -y gcc-plugin-devel.x86_64
     yum install -y libxml2-devel
     yum install -y openssl-devel.x86_64
     yum install -y libcurl-devel
     yum install -y libjpeg-turbo-devel
     yum install -y libpng-devel
     yum install -y freetype-devel
     yum install -y epel-release
     yum install -y libmcrypt-devel
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql5.6 --with-mysqli=/usr/local/mysql5.6/bin/mysql_config --with-pdo-mysql=/usr/local/mysql5.6 --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl   
  make
   make install
        sleep 10
     cp /usr/local/src/php7.3/php.ini-production /usr/local/php-fpm/etc/php.ini
     cp  /usr/local/src/php7.3/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chkconfig --add php-fpm
   chmod 755 /etc/init.d/php-fpm
     useradd -s /sbin/nologin php-fpm
	mv /usr/local/php-fpm/etc/php-fpm.conf.default /usr/local/php-fpm/etc/php-fpm.conf
	mv /usr/local/php-fpm/etc/php-fpm.d/www.conf.default /usr/local/php-fpm/etc/php-fpm.d/www.conf
service php-fpm start
if  [ $? -eq 0 ]; then
        echo "php-fpm installed successfully"
else
        echo "fault"
fi

nginx安装命令列表:

wget http://nginx.org/download/nginx-1.14.2.tar.gz
tar zxvf nginx-1.14.2.tar.gz
cd nginx-1.14.2
./configure --prefix=/usr/local/nginx --with-http_ssl_module
make && make install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值