环境搭建教程
Centos7+Mysql/MariaDB+sendMail+Nginx+PHP 环境搭建一条龙
脚本 示例
#########################
# WeiCot LNMPS 环境配置脚本
# WeiCot.Com
# Email 1050653098@qq.com
# V 2016 05 06
#####################
#!/bin/bash
export PATH=$PATH:/usr/local/mysql/bin
dbPass=pass #数据库密码
webdir=m4 #网站目录
app=ml2t1 #应用名 注意这是 位于 /home/file/ 的zip 包
domain=$webdir.sunacg.com #网站域名
rewrite=mage; #rewrite 文件
winPath=xmpp/htdocs/UP/ #cmd 中使用 wintar 压缩文件多余的目录
vhostdir=/home/wwwroot/$webdir #网站目录
al=/home/wwwlogs/$domain.log #网站日志文件
domainPath="http://${domain}/" #网站地址
filePath=/home/file/ #应用存放路径
#判断网站根目录是否存在
if [ -d $vhostdir ]
then
echo "web dir exist "
else
echo "add web dir"
mkdir $vhostdir
fi
#解压并移动文件到根目录
unzip -q $filePath$app.zip
mv $filePath$winPath$app/* $vhostdir
#创建数据库并导入 文件 顺带更改配置文件
mysql -uroot -p$dbPass -e "create database ${webdir}"
mysql -uroot -proot $webdir<$app.sql
mysql -uroot -p$dbPass -e "use ${webdir}; UPDATE core_config_data SET value = '${domainPath}' WHERE core_config_data.path ='web/secure/base_url'"
mysql -uroot -p$dbPass -e "use ${webdir}; UPDATE core_config_data SET value = '${domainPath}' WHERE core_config_data.path ='web/unsecure/base_url'"
#矫正权限
cd $vhostdir;
find . -type f -exec chmod 644 '{}' \;
find . -type d -exec chmod 755 '{}' \;
chmod o+w var var/.htaccess app/etc
chmod 550 lib/PEAR
chmod -R o+w media
rm -rf ./var/cache
chmod -R 777 js var media skin mai
cd $filePath;
cat >/etc/nginx/vhost/${domain}.conf<<EOF
server
{
listen 80;
#listen [::]:80;
server_name ${domain}${moredomainame};
index index.html index.htm index.php default.html default.htm default.php;
root ${vhostdir};
include ${rewrite}.conf;
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log ${al};
}
EOF
#重启 Nginx
systemctl restart nginx.service
systemctl status nginx.service
转载请注明:(●--●) Hello.My Weicot » 使用 WeiCot LNMPS 环境配置Shell 脚本 配置多站 以magento 为例子