linux 下 shell自动部署php7.2环境的脚本

目的:懒

1.安装环境

创建文件:php7.sh

也可以直接执行

#!/bin/bash
sudo yum install vim -y
sudo yum install epel-release -y
sudo yum install https://centos7.iuscommunity.org/ius-release.rpm -y
sudo yum install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

sudo yum install php72u-fpm -y
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
sudo yum install php72u-gd  php72u-mysqlnd php72u-pdo php72u-mcrypt php72u-mbstring php72u-json php72u-opcache php72u-xml php72u-cli php72u-xml -y

sudo systemctl reload php-fpm

sudo yum remove mariadb-libs -y
sudo yum install mariadb101u-server -y
sudo systemctl start mariadb
sudo systemctl enable mariadb

到上面ok
下面设置数据库几步好像有问题 有空调下
自己运行下就好啦
mysql_secure_installation
一般也就
回车 密码 密码 yyyyyy一路y到底^_^

nginx 配置

server {
  listen 80;
  listen 443;
  ssl on;
  server_name   httproot.com;
  root         /projectdir/public;
  index         index.php index.html;
  ssl_certificate /keydir/2.pem;
  ssl_certificate_key /keydir/1.key;
  ssl_session_cache shared:SSL:1m;
  ssl_session_timeout 5m;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_prefer_server_ciphers on;
client_max_body_size 1000m;
  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }

  location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
  }
}

2.设置登录key

mkdir /root/.ssh

vim /root/.ssh/authorized_keys

修改sshd 的主配置文件,关闭密码认证登陆,使用key登陆。

vim /etc/ssh/sshd_config

找到 PasswordAuthentication yes 

改成 PasswordAuthentication no

service sshd restart

开端口

有的服务器要用的iptable没加端口的话加下

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

查看端口配置列表

iptables -L -n

第二种方式

修改/etc/sysconfig/iptables文件,添加

-A INPUT -p tcp -m tcp --dport 12530 -j ACCEPT

安装composer

//下载composer
curl -sS https://getcomposer.org/installer | php

//将composer.phar文件移动到bin目录以便全局使用composer命令
mv composer.phar /usr/local/bin/composer

//切换国内源
composer config -g repo.packagist composer https://packagist.phpcomposer.com

HTTPROOT | 自学PHP | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 石头哥 |微信小程序 |木讯
Copyright © 1998 - 2016 HTTPROOT.COM. All Rights Reserved httproot.com 版权所有