Nginx自动化部署分流实战

Author:zfs

过程查看我上一篇httpd自动化的文章,大体一致。

下面是shell脚本代码:

#!/usr/bin/env bash

cat <<-EOF >  /etc/yum.repos.d/nginx.repo

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/7/\$basearch

gpgcheck=0

enabled=1

EOF

yum clean all

yum makecache

yum -y install nginx

systemctl start nginx

rm -rf /etc/nginx/conf.d/default.conf

cat <<-EOF > /etc/nginx/conf.d/wordpress.conf

server {

listen 80;

server_name  www.wordpress.com;

location / {

root /var/www/wordpress;

index index.php index.html index.htm;

}

location ~ \.php$ {

root /var/www/wordpress;

fastcgi_pass  127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME  \$document_root\$fastcgi_script_name;

include fastcgi_params;

}

}

EOF

cat <<-EOF > /etc/nginx/conf.d/edosoho.conf

server {

listen 80;

server_name  www.edusoho.com;

location / {

root /var/www/edusoho/web;

index index.php index.html index.htm;

}

location ~ \.php$ {

root /var/www/edusoho/web;

fastcgi_pass  127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME  \$document_root\$fastcgi_script_name;

include fastcgi_params;

}

}

EOF

cd /root/

rm -rf /etc/nginx/conf.d/defalut.conf

mkdir -p /var/www/wordpress

mkdir -p /var/www/edusoho

systemctl restart nginx

yum -y install mariadb mariadb-server expect

systemctl start mariadb

cat <<-EOF > /root/zfsexpect

#!/usr/bin/expect

spawn mysqladmin -uroot -p password "zfs"

expect "Enter password:"

send "\r"

interact

EOF

chmod a+x /root/zfsexpect

expect /root/zfsexpect

mysql -uroot -p"zfs" -e "create database wordpress;"

mysql -uroot -p"zfs" -e "create database edusoho;"

systemctl restart mariadb

yum -y install php php-cli php-curl php-fpm php-intl php-mcrypt php-mysql php-gd php-mbstring php-xml php-dom

systemctl start php-fpm

sed -ri s/"post_max_size =8M"/"post_max_size =1024M"/g      /etc/php.ini

sed -ri s/"memory_limit =128M"/"memory_limit =1024M"/g      /etc/php.ini

sed -ri s/"post_max_size =2M"/"upload_max_filesize =1024M"/g      /etc/php.ini

sed -ri s/";date.timezone ="/"date.timezone =Asia\/ShangHai"/g      /etc/php.ini

systemctl restart php-fpm

wget http://download.edusoho.com/edusoho-7.5.12.tar.gz

wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz

tar xf edusoho-7.5.12.tar.gz

tar xf wordpress-4.9.4-zh_CN.tar.gz

mv /root/wordpress/wp-config-sample.php /root/wordpress/wp-config.php

sed -ri s/"database_name_here"/"wordpress"/g  /root/wordpress/wp-config.php

sed -ri s/"username_here"/"root"/g  /root/wordpress/wp-config.php

sed -ri s/"password_here"/"zfs"/g  /root/wordpress/wp-config.php

cp -rf /root/wordpress/* /var/www/wordpress/

cp -rf /root/edusoho/* /var/www/edusoho/

chown -R apache:apache /var/www/wordpress/*

chown -R apache:apache /var/www/edusoho/*

systemctl restart nginx mariadb php-fpm

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容