{"id":74,"date":"2017-03-26T18:29:04","date_gmt":"2017-03-26T10:29:04","guid":{"rendered":"http:\/\/www.nby.me\/?p=74"},"modified":"2017-03-26T18:42:28","modified_gmt":"2017-03-26T10:42:28","slug":"centos7-%e5%ae%89%e8%a3%85mysql5-6-php5-6-nginx1-10-%e9%82%ae%e4%bb%b6%e6%9c%8d%e5%8a%a1-%e4%bb%a5%e5%8f%8avhost%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/nby.me\/?p=74","title":{"rendered":"Centos7 \u5b89\u88c5MySQL5.6 php5.6 nginx1.10 \u90ae\u4ef6\u670d\u52a1 \u4ee5\u53cavhost\u811a\u672c"},"content":{"rendered":"<p>\u8fd9\u4e2a\u811a\u672c\u4e3b\u8981\u662f\u6211\u7528\u6765\u4e00\u952e\u914d\u7f6e\u670d\u52a1\u5668\u7528\u7684\u3002<\/p>\n<p>\u4e3b\u8981\u5305\u62ecnginx1.10 php5.6 mysql5.6\u00a0postfix\u00a0opendkim\u3002<\/p>\n<p>\u4ee5\u53cadropbox\u5907\u4efd\uff0c\u865a\u62df\u4e3b\u673a\u6dfb\u52a0\u811a\u672c\u3002<\/p>\n<p>\u53ef\u4ee5\u81ea\u52a8\u914d\u7f6e\u6ee1\u5206\u7684\u90ae\u4ef6\u670d\u52a1\u5668\uff0cDNS\u90a3\u5757\u8bf7\u53c2\u8003\u522b\u7684\u6559\u7a0b\u914d\u7f6e\u4e00\u4e0b\uff0cdkim\u7684TXT\u8bb0\u5f55\u5728\/root\/&#8217;yourhostname&#8217;-dkim-signature_default.txt\uff0c\u7528\u4e4b\u524d\u4fee\u6539hostname\uff0crDNS\u4e5f\u8981\u4fee\u6539\u3002<\/p>\n<p>linode vultr \u5e94\u8be5\u90fd\u662f\u7c98\u8d34\u4e0a\u5c31\u80fd\u76f4\u63a5\u7528\u7684\u3002<\/p>\n<p>nginx\u914d\u7f6e\u5728\/etc\/nginx<\/p>\n<p>php.ini\u5728\/etc\u4e0b<\/p>\n<p>php-fpm\u4e5f\u5728\/etc\u4e0b<\/p>\n<p>\u6709\u95ee\u9898\u53ef\u7559\u8a00\u54a8\u8be2\u3002<\/p>\n<p><!--more--><\/p>\n<p>#!\/bin\/bash<br \/>\necho -e &#8220;\\033[46m input mysql keys \\033[0m&#8221;<br \/>\nread mysql<br \/>\nyum install -y wget<br \/>\nwget -P \/usr\/sbin https:\/\/raw.github.com\/andreafabrizi\/Dropbox-Uploader\/master\/dropbox_uploader.sh<br \/>\nchmod +x \/usr\/sbin\/dropbox_uploader.sh<br \/>\necho -e &#8220;\\033[46m [Notice] Close selinux \\033[0m&#8221;<br \/>\n[ -s \/etc\/selinux\/config ] &amp;&amp; sed -i &#8216;s\/SELINUX=enforcing\/SELINUX=disabled\/g&#8217; \/etc\/selinux\/config;<br \/>\nsetenforce 0 &gt;\/dev\/null 2&gt;&amp;1;<br \/>\necho -e &#8220;\\033[46m [Notice] set datetime \\033[0m&#8221;<br \/>\nyum install -y epel-release ntp crontabs;<br \/>\nyum -y groupinstall &#8216;Development Tools&#8217;;<br \/>\nntpdate -u pool.ntp.org;<br \/>\nrm -rf \/etc\/localtime;<br \/>\nln -sf \/usr\/share\/zoneinfo\/Asia\/Shanghai \/etc\/localtime;<br \/>\necho -e &#8220;\\033[46m [Notice] install epel remi nginx repo \\033[0m&#8221;<br \/>\nrpm -Uvh http:\/\/rpms.famillecollet.com\/enterprise\/remi-release-7.rpm<br \/>\nrpm -Uvh http:\/\/nginx.org\/packages\/centos\/7\/noarch\/RPMS\/nginx-release-centos-7-0.el7.ngx.noarch.rpm<br \/>\nrpm -Uvh http:\/\/repo.mysql.com\/mysql-community-release-el7-5.noarch.rpm<br \/>\nrm \/etc\/yum.repos.d\/remi.repo -f<br \/>\ncat &gt; \/etc\/yum.repos.d\/remi.repo &lt;&lt;&#8220;EOF&#8221;<br \/>\n# Repository: http:\/\/rpms.remirepo.net\/<br \/>\n# Blog: http:\/\/blog.remirepo.net\/<br \/>\n# Forum: http:\/\/forum.remirepo.net\/<\/p>\n<p>[remi]<br \/>\nname=Remi&#8217;s RPM repository for Enterprise Linux 7 &#8211; $basearch<br \/>\n#baseurl=http:\/\/rpms.remirepo.net\/enterprise\/7\/remi\/$basearch\/<br \/>\n#mirrorlist=https:\/\/rpms.remirepo.net\/enterprise\/7\/remi\/httpsmirror<br \/>\nmirrorlist=http:\/\/rpms.remirepo.net\/enterprise\/7\/remi\/mirror<br \/>\nenabled=1<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-remi<\/p>\n<p>[remi-php55]<br \/>\nname=Remi&#8217;s PHP 5.5 RPM repository for Enterprise Linux 7 &#8211; $basearch<br \/>\n#baseurl=http:\/\/rpms.remirepo.net\/enterprise\/7\/php55\/$basearch\/<br \/>\n#mirrorlist=https:\/\/rpms.remirepo.net\/enterprise\/7\/php55\/httpsmirror<br \/>\nmirrorlist=http:\/\/rpms.remirepo.net\/enterprise\/7\/php55\/mirror<br \/>\n# NOTICE: common dependencies are in &#8220;remi-safe&#8221;<br \/>\nenabled=0<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-remi<\/p>\n<p>[remi-php56]<br \/>\nname=Remi&#8217;s PHP 5.6 RPM repository for Enterprise Linux 7 &#8211; $basearch<br \/>\n#baseurl=http:\/\/rpms.remirepo.net\/enterprise\/7\/php56\/$basearch\/<br \/>\n#mirrorlist=https:\/\/rpms.remirepo.net\/enterprise\/7\/php56\/httpsmirror<br \/>\nmirrorlist=http:\/\/rpms.remirepo.net\/enterprise\/7\/php56\/mirror<br \/>\n# NOTICE: common dependencies are in &#8220;remi-safe&#8221;<br \/>\nenabled=1<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-remi<\/p>\n<p>[remi-test]<br \/>\nname=Remi&#8217;s test RPM repository for Enterprise Linux 7 &#8211; $basearch<br \/>\n#baseurl=http:\/\/rpms.remirepo.net\/enterprise\/7\/test\/$basearch\/<br \/>\nname=Remi&#8217;s test RPM repository for Enterprise Linux 7 &#8211; $basearch<br \/>\n#baseurl=http:\/\/rpms.remirepo.net\/enterprise\/7\/test\/$basearch\/<br \/>\n#mirrorlist=https:\/\/rpms.remirepo.net\/enterprise\/7\/test\/mirror<br \/>\nmirrorlist=http:\/\/rpms.remirepo.net\/enterprise\/7\/test\/mirror<br \/>\n# WARNING: If you enable this repository, you must also enable &#8220;remi&#8221;<br \/>\nenabled=0<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-remi<\/p>\n<p>[remi-debuginfo]<br \/>\nname=Remi&#8217;s RPM repository for Enterprise Linux 7 &#8211; $basearch &#8211; debuginfo<br \/>\nbaseurl=http:\/\/rpms.remirepo.net\/enterprise\/7\/debug-remi\/$basearch\/<br \/>\nenabled=0<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-remi<\/p>\n<p>[remi-php55-debuginfo]<br \/>\nname=Remi&#8217;s PHP 5.5 RPM repository for Enterprise Linux 7 &#8211; $basearch &#8211; debuginfo<br \/>\nbaseurl=http:\/\/rpms.remirepo.net\/enterprise\/7\/debug-php55\/$basearch\/<br \/>\nenabled=0<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-remi<\/p>\n<p>[remi-php56-debuginfo]<br \/>\nname=Remi&#8217;s PHP 5.6 RPM repository for Enterprise Linux 7 &#8211; $basearch &#8211; debuginfo<br \/>\nbaseurl=http:\/\/rpms.remirepo.net\/enterprise\/7\/debug-php56\/$basearch\/<br \/>\nenabled=0<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-remi<\/p>\n<p>[remi-test-debuginfo]<br \/>\nname=Remi&#8217;s test RPM repository for Enterprise Linux 7 &#8211; $basearch &#8211; debuginfo<br \/>\nbaseurl=http:\/\/rpms.remirepo.net\/enterprise\/7\/debug-test\/$basearch\/<br \/>\nenabled=0<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-remi<br \/>\ngpgcheck=1<br \/>\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-remi<br \/>\nEOF<br \/>\nyum clean all<br \/>\nyum makecache<br \/>\necho -e &#8220;\\033[46m [Notice] install service \\033[0m&#8221;<br \/>\nyum install -y nginx mysql-community-server php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-json php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pdo_dblib php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common php-pecl-zip php-recode php-snmp php-soap memcached libmemcached libmemcached-devel php-pecl-memcached redis php-pecl-redis ImageMagick ImageMagick-devel php-pecl-imagick<br \/>\nsed -i &#8216;4a return 500;&#8217; \/etc\/nginx\/conf.d\/default.conf<br \/>\nsed -i &#8220;\/^return\/ s\/^\/ \/ &#8221; \/etc\/nginx\/conf.d\/default.conf<br \/>\nsed -i &#8217;23a server_tokens off;&#8217; \/etc\/nginx\/nginx.conf<br \/>\nsed -i &#8220;\/^server_tokens\/ s\/^\/ \/ &#8221; \/etc\/nginx\/nginx.conf<br \/>\nsed -i &#8216;s:#gzip on;:gzip on;:g&#8217; \/etc\/nginx\/nginx.conf<br \/>\nsed -i &#8216;s:short_open_tag = Off:short_open_tag = On:g&#8217; \/etc\/php.ini<br \/>\nsed -i &#8216;s:expose_php = On:expose_php = Off:g&#8217; \/etc\/php.ini<br \/>\nsed -i &#8216;s:;cgi.fix_pathinfo=1:cgi.fix_pathinfo=0:g&#8217; \/etc\/php.ini<br \/>\nsed -i &#8216;s:;date.timezone =:date.timezone = &#8220;Asia\/Hong_Kong&#8221;:g&#8217; \/etc\/php.ini<br \/>\nsed -i &#8216;s:; max_input_vars = 1000:max_input_vars = 10000:g&#8217; \/etc\/php.ini<br \/>\nsed -i &#8216;s@;open_basedir =@open_basedir = \/data\/wwwroot\/:\/tmp\/:\/proc\/@g&#8217; \/etc\/php.ini<br \/>\nsed -i &#8216;s@listen = 127.0.0.1:9000@listen = \/var\/run\/php-fpm\/php-fpm.sock@g&#8217; \/etc\/php-fpm.d\/www.conf<br \/>\nsed -i &#8216;s:user = apache:user = nginx:g&#8217; \/etc\/php-fpm.d\/www.conf<br \/>\nsed -i &#8216;s:group = apache:group = nginx:g&#8217; \/etc\/php-fpm.d\/www.conf<br \/>\nsed -i &#8216;s:;listen.owner = nobody:listen.owner = nobody:g&#8217; \/etc\/php-fpm.d\/www.conf<br \/>\nsed -i &#8216;s:;listen.group = nobody:listen.group = nobody:g&#8217; \/etc\/php-fpm.d\/www.conf<br \/>\necho -e &#8220;\\033[46m [Notice] Start service \\033[0m&#8221;<br \/>\nsystemctl disable httpd<br \/>\nsystemctl stop httpd<br \/>\nsystemctl enable mysqld.service;<br \/>\nsystemctl enable php-fpm.service;<br \/>\nsystemctl enable nginx.service;<br \/>\nsystemctl enable firewalld.service;<br \/>\nsystemctl start firewalld.service<br \/>\nfirewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-service=http;<br \/>\nfirewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-service=https;<br \/>\nfirewall-cmd &#8211;reload;<br \/>\nsystemctl start mysqld.service;<br \/>\nsystemctl start php-fpm.service;<br \/>\nsystemctl start nginx.service;<br \/>\nmkdir -p \/var\/lib\/php\/session<br \/>\nchown -R nginx:nginx \/var\/lib\/php\/session\/<br \/>\nchown -R nginx:nginx \/var\/run\/php-fpm\/<br \/>\necho -e &#8220;\\033[46m [Notice] lnmp successful \\033[0m&#8221;<br \/>\necho -e &#8220;\\033[46m [Notice] install postfix opendkim \\033[0m&#8221;<br \/>\nyum install -y postfix opendkim mailx<br \/>\nsed -i &#8220;s\/#myhostname = virtual.domain.tld\/myhostname = `hostname -f`\/g&#8221; \/etc\/postfix\/main.cf<br \/>\nsed -i &#8220;s\/#mydomain = domain.tld\/mydomain = `hostname -f`\/g&#8221; \/etc\/postfix\/main.cf<br \/>\nsed -i &#8216;s:inet_interfaces = localhost:inet_interfaces = all:g&#8217; \/etc\/postfix\/main.cf<br \/>\nsed -i &#8216;s:inet_protocols = all:inet_protocols = ipv4:g&#8217; \/etc\/postfix\/main.cf<br \/>\nsed -i &#8216;s:mydestination =:#mydestination =:g&#8217; \/etc\/postfix\/main.cf<br \/>\nsed -i &#8216;s:#relay_domains = $mydestination:relay_domains = $mydomain:g&#8217; \/etc\/postfix\/main.cf<br \/>\nsed -i &#8216;s:#myorigin = $mydomain:myorigin = $mydomain:g&#8217; \/etc\/postfix\/main.cf<br \/>\ncat &gt; \/etc\/opendkim.conf&lt;&lt;&#8220;EOF&#8221;<br \/>\nUserID opendkim:opendkim<br \/>\nUMask 022<br \/>\nMode sv<br \/>\nPidFile \/var\/run\/opendkim\/opendkim.pid<br \/>\nCanonicalization relaxed\/relaxed<br \/>\nTemporaryDirectory \/var\/tmp<br \/>\nExternalIgnoreList refile:\/etc\/opendkim\/TrustedHosts<br \/>\nInternalHosts refile:\/etc\/opendkim\/TrustedHosts<br \/>\nKeyTable refile:\/etc\/opendkim\/KeyTable<br \/>\nSigningTable refile:\/etc\/opendkim\/SigningTable<br \/>\nMinimumKeyBits 1024<br \/>\nSocket inet:8891@127.0.0.1<br \/>\nLogWhy Yes<br \/>\nSyslog Yes<br \/>\nSyslogSuccess Yes<br \/>\nEOF<br \/>\nmkdir -p \/etc\/opendkim\/keys\/`hostname -f`<br \/>\nopendkim-genkey -D \/etc\/opendkim\/keys\/`hostname -f`\/ -d `hostname -f` -s default<br \/>\nchown opendkim:opendkim -R \/etc\/opendkim\/<br \/>\nchmod -R 700 \/etc\/opendkim<br \/>\necho &#8220;default._domainkey.`hostname -f` `hostname -f`:default:\/etc\/opendkim\/keys\/`hostname -f`\/default.private&#8221; &gt;&gt; \/etc\/opendkim\/KeyTable<br \/>\necho &#8220;*@`hostname -f` default._domainkey.`hostname -f`&#8221; &gt;&gt; \/etc\/opendkim\/SigningTable<br \/>\necho &#8220;localhost&#8221; &gt;&gt; \/etc\/opendkim\/TrustedHosts<br \/>\necho &#8220;`hostname -f`&#8221; &gt;&gt; \/etc\/opendkim\/TrustedHosts<br \/>\ncat &gt;&gt; \/etc\/postfix\/main.cf&lt;&lt;EOF<br \/>\nmynetworks = 127.0.0.0\/8<br \/>\nhome_mailbox = Maildir\/<br \/>\nmydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain<br \/>\n#DKIM<br \/>\nmilter_default_action = accept<br \/>\nmilter_protocol = 2<br \/>\nsmtpd_milters = inet:8891<br \/>\nnon_smtpd_milters = inet:8891<br \/>\nEOF<br \/>\nhash -r<br \/>\nsystemctl enable postfix<br \/>\nsystemctl start postfix<br \/>\nsystemctl enable opendkim<br \/>\nsystemctl start opendkim<br \/>\ncp \/etc\/opendkim\/keys\/`hostname -f`\/default.txt \/root\/`hostname -f`-dkim-signature_default.txt<br \/>\necho -e &#8220;\\033[46m open &#8216;\/root\/`hostname -f`-dkim-signature_default.txt&#8217;, then add the TXT record to you DNS resolution system. \\033[0m&#8221;<br \/>\necho -e &#8220;\\033[46m [Notice] install postfix opendkim successful \\033[0m&#8221;<br \/>\ncat &gt; \/usr\/sbin\/panel&lt;&lt;&#8220;EOF&#8221;<br \/>\n#!\/bin\/bash<br \/>\n# Sanity check<br \/>\n[ $(id -g) != &#8220;0&#8221; ] &amp;&amp; die &#8220;Script must be run as root.&#8221;;<br \/>\necho -e &#8220;\\033[46m Nginx PHP Mail Manage \\033[0m&#8221;<br \/>\necho -e &#8220;\\033[46m1.restart nginx&amp;php-fpm\\n2.check nginx&amp;php-fpm status\\n3.restart postfix&amp;opendkim\\n4.check postfix&amp;opendkim \\033[0m&#8221;<br \/>\nselect selected in &#8216;rnp&#8217; &#8216;cnp&#8217; &#8216;rpo&#8217; &#8216;cpo&#8217;; do<br \/>\nbreak;<br \/>\ndone;<br \/>\nif [ &#8220;$selected&#8221; == &#8216;rnp&#8217; ]; then<br \/>\nsystemctl restart nginx<br \/>\nsystemctl restart php-fpm<br \/>\nsystemctl status nginx<br \/>\nsystemctl status php-fpm<br \/>\nchown -R nginx:nginx \/var\/run\/php-fpm\/<br \/>\nchown -R nginx:nginx \/var\/lib\/php\/session\/<br \/>\nexit;<br \/>\nelif [ &#8220;$selected&#8221; == &#8216;cnp&#8217; ]; then<br \/>\nsystemctl status nginx<br \/>\nsystemctl status php-fpm<br \/>\nexit;<br \/>\nelif [ &#8220;$selected&#8221; == &#8216;rpo&#8217; ]; then<br \/>\nsystemctl restart postfix<br \/>\nsystemctl restart opendkim<br \/>\nsystemctl status postfix<br \/>\nsystemctl status opendkim<br \/>\nexit;<br \/>\nelif [ &#8220;$selected&#8221; == &#8216;cpo&#8217; ]; then<br \/>\nsystemctl status postfix<br \/>\nsystemctl status opendkim<br \/>\nexit;<br \/>\nfi;<\/p>\n<p>EOF<br \/>\nchmod +x \/usr\/sbin\/panel<br \/>\nmkdir \/root\/backup<br \/>\nmkdir \/root\/tools<br \/>\nmkdir \/root\/tmp<br \/>\ncat &gt; \/root\/tools\/backup.sh&lt;&lt;EOF<br \/>\n#!\/bin\/bash<br \/>\nSCRIPT_DIR=&#8221;\/usr\/sbin&#8221; #\u8fd9\u4e2a\u6539\u6210\u4f60\u5b58\u653e\u521a\u521a\u4e0b\u8f7d\u4e0b\u6765\u7684dropbox_uploader.sh\u7684\u6587\u4ef6\u5939\u4f4d\u7f6e<br \/>\nDROPBOX_DIR=&#8221;\/root\/backup&#8221; #\u8fd9\u4e2a\u6539\u6210\u4f60\u7684\u5907\u4efd\u6587\u4ef6\u60f3\u8981\u653e\u5728Dropbox\u4e0b\u9762\u7684\u6587\u4ef6\u5939\u540d\u79f0\uff0c\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u811a\u672c\u4f1a\u81ea\u52a8\u521b\u5efa<br \/>\nBACKUP_SRC=&#8221;\/home \/etc\/nginx\/conf.d&#8221; #\u8fd9\u4e2a\u662f\u4f60\u60f3\u8981\u5907\u4efd\u7684\u672c\u5730VPS\u4e0a\u7684\u6587\u4ef6\uff0c\u4e0d\u540c\u7684\u76ee\u5f55\u7528\u7a7a\u683c\u5206\u5f00<br \/>\nBACKUP_DST=&#8221;\/root\/tmp&#8221; #\u8fd9\u4e2a\u662f\u4f60\u6682\u65f6\u5b58\u653e\u5907\u4efd\u538b\u7f29\u6587\u4ef6\u7684\u5730\u65b9\uff0c\u4e00\u822c\u7528\/tmp\u5373\u53ef<br \/>\nMYSQL_SERVER=&#8221;localhost&#8221; #\u8fd9\u4e2a\u662f\u4f60mysql\u670d\u52a1\u5668\u7684\u5730\u5740\uff0c\u4e00\u822c\u586b\u8fd9\u4e2a\u672c\u5730\u5730\u5740\u5373\u53ef<br \/>\nMYSQL_USER=&#8221;root&#8221; #\u8fd9\u4e2a\u662f\u4f60mysql\u7684\u7528\u6237\u540d\u540d\u79f0\uff0c\u6bd4\u5982root\u6216admin\u4e4b\u7c7b\u7684<br \/>\nMYSQL_PASS=&#8221;$mysql&#8221; #\u8fd9\u4e2a\u662f\u4f60mysql\u7528\u6237\u7684\u5bc6\u7801<br \/>\n# \u4e0b\u9762\u7684\u4e00\u822c\u4e0d\u7528\u6539\u4e86<br \/>\nNOW=\\$(date +&#8221;%Y.%m.%d&#8221;)<br \/>\nDESTFILE=&#8221;\\$BACKUP_DST\/\\$NOW.tar.gz&#8221;<br \/>\n# \u5907\u4efdmysql\u6570\u636e\u5e93\u5e76\u548c\u5176\u5b83\u5907\u4efd\u6587\u4ef6\u4e00\u8d77\u538b\u7f29\u6210\u4e00\u4e2a\u6587\u4ef6<br \/>\nmysqldump -u \\$MYSQL_USER -h \\$MYSQL_SERVER -p\\$MYSQL_PASS &#8211;all-databases &gt; &#8220;\\$NOW-Databases.sql&#8221;<br \/>\necho &#8220;Databases Package Done,Package Website&#8230;&#8221;<br \/>\ntar cfzP &#8220;\\$DESTFILE&#8221; \\$BACKUP_SRC &#8220;\\$NOW-Databases.sql&#8221;<br \/>\necho &#8220;Package Done,Uploading&#8230;&#8221;<br \/>\n# \u7528\u811a\u672c\u4e0a\u4f20\u5230dropbox<br \/>\n\\$SCRIPT_DIR\/dropbox_uploader.sh upload &#8220;\\$DESTFILE&#8221; &#8220;\\$DROPBOX_DIR\/\\$NOW.tar.gz&#8221;<br \/>\nif [ \\$? -eq 0 ];then<br \/>\necho &#8220;Upload Successful&#8221;<br \/>\nelse<br \/>\necho &#8220;Upload Fail&#8221;<br \/>\nfi<br \/>\n# \u5220\u9664\u672c\u5730\u7684\u4e34\u65f6\u6587\u4ef6<br \/>\nrm -f &#8220;\\$NOW-Databases.sql&#8221; &#8220;\\$DESTFILE&#8221;<br \/>\nEOF<br \/>\nchmod +x \/root\/tools\/backup.sh<br \/>\nsystemctl enable crond<br \/>\nsystemctl start crond<br \/>\necho &#8216;#!\/bin\/bash<br \/>\n# Sanity check<br \/>\n[ $(id -g) != &#8220;0&#8221; ] &amp;&amp; die &#8220;Script must be run as root.&#8221;;<br \/>\necho -e &#8220;\\033[46m Vhost Manage \\033[0m&#8221;<br \/>\necho -e &#8220;\\033[46m1.add www domain\\n2.add second domain\\n3.delete website\\n4.exit \\033[0m&#8221;<br \/>\nselect selected in &#8216;addwww&#8217; &#8216;addxxx&#8217; &#8216;del&#8217; &#8216;exit&#8217;; do<br \/>\nbreak;<br \/>\ndone;<br \/>\nif [ &#8220;$selected&#8221; == &#8216;addwww&#8217; ]; then<br \/>\nunset domain<br \/>\necho &#8220;input domain&#8221;;<br \/>\nread domain<br \/>\nuseradd -m -s \/sbin\/nologin $domain;<br \/>\nusermod -G nginx $domain<br \/>\nmkdir -p \/home\/$domain\/www;<br \/>\nmkdir -p \/home\/$domain\/log;<br \/>\nmkdir -p \/home\/$domain\/tmp\/session;<br \/>\nchown -R nginx:nginx \/home\/$domain<br \/>\ncat &gt; \/etc\/nginx\/conf.d\/$domain.conf &lt;&lt;EOF<br \/>\nserver {<br \/>\nlisten 80;<br \/>\nserver_name www.$domain;<br \/>\naccess_log \/home\/$domain\/log\/access.log;<br \/>\nerror_log \/home\/$domain\/log\/error.log;<br \/>\nroot \/home\/$domain\/www;<br \/>\nindex index.php index.html index.htm;<br \/>\nlocation = \/favicon.ico {<br \/>\nlog_not_found off;<br \/>\naccess_log off;<br \/>\n}<br \/>\n#include \/home\/$domain\/rewrite.conf;<br \/>\nlocation = \/robots.txt {<br \/>\nallow all;<br \/>\nlog_not_found off;<br \/>\naccess_log off;<br \/>\n}<\/p>\n<p>#error_page 404 \/404.html;<\/p>\n<p># redirect server error pages to the static page \/50x.html<br \/>\n#<br \/>\nerror_page 500 502 503 504 \/50x.html;<br \/>\nlocation = \/50x.html {<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\n}<\/p>\n<p># pass the PHP scripts to FastCGI server listening on sock<br \/>\n#<br \/>\nlocation ~ \\.php\\$ {<br \/>\ntry_files \\$uri =404;<br \/>\nfastcgi_pass unix:\/var\/run\/php-fpm\/$domain.sock;<br \/>\nfastcgi_index index.php;<br \/>\nfastcgi_param SCRIPT_FILENAME \\$document_root\\$fastcgi_script_name;<br \/>\ninclude fastcgi_params;<br \/>\n}<\/p>\n<p># Deny all attempts to access hidden files such as .htaccess<br \/>\n# Deny access to any files with a .php extension in the uploads directory<br \/>\n#<br \/>\nlocation ~ \/\\. {<br \/>\ndeny all;<br \/>\n}<br \/>\nlocation ~* \/(?:uploads|files|data|upload)\/.*\\.php\\$ {<br \/>\ndeny all;<br \/>\n}<\/p>\n<p>location ~* \\.(gif|jpg|jpeg|png|bmp|txt|zip|jar|swf)\\$ {<br \/>\nexpires 30d;<br \/>\naccess_log off;<br \/>\nvalid_referers none blocked *.$domain server_names ~\\.google\\. ~\\.baidu\\. ~\\.bing\\. ~\\.yahoo\\. ~\\.soso\\. ~\\.sogou\\. ~\\.alexa\\. ~\\.haosou\\. ~\\.youdao\\.;<br \/>\nif (\\$invalid_referer) {<br \/>\n#return 403;<br \/>\nrewrite ^\/ http:\/\/www.$domain\/403.png;<br \/>\n}<br \/>\n}<br \/>\nrewrite ^\/sitemap.xml\\$ \/sitemap.php last;<br \/>\n}<\/p>\n<p>server {<br \/>\nserver_name $domain;<br \/>\nrewrite ^\/(.*)\\$ http:\/\/www.\\$host\/$1 permanent;<br \/>\n}<br \/>\nEOF<br \/>\ncat &gt; \/etc\/php-fpm.d\/$domain.conf &lt;&lt;EOF<br \/>\n[$domain]<br \/>\nlisten = \/var\/run\/php-fpm\/$domain.sock<br \/>\nlisten.allowed_clients = 127.0.0.1<br \/>\nlisten.owner = nginx<br \/>\nlisten.group = nginx<br \/>\nlisten.mode = 0660<\/p>\n<p>user = nginx<br \/>\ngroup = nginx<\/p>\n<p>pm = dynamic<br \/>\npm.max_children = 50<br \/>\npm.start_servers = 5<br \/>\npm.min_spare_servers = 5<br \/>\npm.max_spare_servers = 35<\/p>\n<p>chdir = \/<br \/>\nslowlog = \/var\/log\/php-fpm\/www-slow.log<br \/>\nphp_value[session.save_handler] = files<br \/>\nphp_value[session.save_path] = \/home\/$domain\/tmp\/session<br \/>\nphp_admin_value[open_basedir] = \/home\/$domain\/www:\/home\/$domain\/tmp:\/usr\/share\/php:\/tmp<br \/>\nphp_admin_value[upload_tmp_dir] = \/home\/$domain\/tmp<br \/>\nEOF<br \/>\n# cat &gt; \/etc\/logrotate.d\/$domain &lt;&lt;EOF<br \/>\n#\/data\/$domain\/log\/*.log {<br \/>\n#daily<br \/>\n#missingok<br \/>\n#rotate 7<br \/>\n#compress<br \/>\n#delaycompress<br \/>\n#notifempty<br \/>\n#create 640 nginx adm<br \/>\n#sharedscripts<br \/>\n#postrotate<br \/>\n# [ -f \/var\/run\/nginx.pid ] &amp;&amp; kill -USR1 `cat \/var\/run\/nginx.pid`<br \/>\n#endscript<br \/>\n#}<br \/>\n#EOF<br \/>\nnginx -t<br \/>\nsystemctl restart nginx<br \/>\nsystemctl restart php-fpm<br \/>\nsystemctl status nginx<br \/>\nsystemctl status php-fpm<br \/>\necho &#8220;successful!&#8221;;<br \/>\nexit;<br \/>\nelif [ &#8220;$selected&#8221; == &#8216;addxxx&#8217; ]; then<br \/>\nunset domain<br \/>\necho &#8220;input domain&#8221;;<br \/>\nread domain<br \/>\nunset sdomain<br \/>\necho &#8220;input second domain [need add . at end]&#8221;;<br \/>\nread sdomain<br \/>\nuseradd -m -s \/sbin\/nologin $sdomain$domain;<br \/>\nusermod -G nginx $sdomain$domain<br \/>\nmkdir -p \/home\/$sdomain$domain\/www;<br \/>\nmkdir -p \/home\/$sdomain$domain\/log;<br \/>\nmkdir -p \/home\/$sdomain$domain\/tmp\/session;<br \/>\nchown -R nginx:nginx \/home\/$sdomain$domain<br \/>\ncat &gt; \/etc\/nginx\/conf.d\/$sdomain$domain.conf &lt;&lt;EOF<br \/>\nserver {<br \/>\nlisten 80;<br \/>\nserver_name $sdomain$domain;<br \/>\naccess_log \/home\/$sdomain$domain\/log\/access.log;<br \/>\nerror_log \/home\/$sdomain$domain\/log\/error.log;<br \/>\nroot \/home\/$sdomain$domain\/www;<br \/>\nindex index.php index.html index.htm;<br \/>\nlocation = \/favicon.ico {<br \/>\nlog_not_found off;<br \/>\naccess_log off;<br \/>\n}<br \/>\n#include \/home\/$sdomain$domain\/rewrite.conf;<br \/>\nlocation = \/robots.txt {<br \/>\nallow all;<br \/>\nlog_not_found off;<br \/>\naccess_log off;<br \/>\n}<\/p>\n<p>#error_page 404 \/404.html;<\/p>\n<p># redirect server error pages to the static page \/50x.html<br \/>\n#<br \/>\nerror_page 500 502 503 504 \/50x.html;<br \/>\nlocation = \/50x.html {<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\n}<\/p>\n<p># pass the PHP scripts to FastCGI server listening on sock<br \/>\n#<br \/>\nlocation ~ \\.php\\$ {<br \/>\ntry_files \\$uri =404;<br \/>\nfastcgi_pass unix:\/var\/run\/php-fpm\/$sdomain$domain.sock;<br \/>\nfastcgi_index index.php;<br \/>\nfastcgi_param SCRIPT_FILENAME \\$document_root\\$fastcgi_script_name;<br \/>\ninclude fastcgi_params;<br \/>\n}<\/p>\n<p># Deny all attempts to access hidden files such as .htaccess<br \/>\n# Deny access to any files with a .php extension in the uploads directory<br \/>\n#<br \/>\nlocation ~ \/\\. {<br \/>\ndeny all;<br \/>\n}<br \/>\nlocation ~* \/(?:uploads|files|data|upload)\/.*\\.php\\$ {<br \/>\ndeny all;<br \/>\n}<\/p>\n<p>location ~* \\.(gif|jpg|jpeg|png|bmp|txt|zip|jar|swf)\\$ {<br \/>\nexpires 30d;<br \/>\naccess_log off;<br \/>\nvalid_referers none blocked *.$sdomain$domain server_names ~\\.google\\. ~\\.baidu\\. ~\\.bing\\. ~\\.yahoo\\. ~\\.soso\\. ~\\.sogou\\. ~\\.alexa\\. ~\\.haosou\\. ~\\.youdao\\.;<br \/>\nif (\\$invalid_referer) {<br \/>\n#return 403;<br \/>\nrewrite ^\/ http:\/\/www.$domain\/403.png;<br \/>\n}<br \/>\n}<br \/>\nrewrite ^\/sitemap.xml\\$ \/sitemap.php last;<br \/>\n}<br \/>\nEOF<br \/>\ncat &gt; \/etc\/php-fpm.d\/$sdomain$domain.conf &lt;&lt;EOF<br \/>\n[$sdomain$domain]<br \/>\nlisten = \/var\/run\/php-fpm\/$sdomain$domain.sock<br \/>\nlisten.allowed_clients = 127.0.0.1<br \/>\nlisten.owner = nginx<br \/>\nlisten.group = nginx<br \/>\nlisten.mode = 0660<\/p>\n<p>user = nginx<br \/>\ngroup = nginx<\/p>\n<p>pm = dynamic<br \/>\npm.max_children = 50<br \/>\npm.start_servers = 5<br \/>\npm.min_spare_servers = 5<br \/>\npm.max_spare_servers = 35<\/p>\n<p>chdir = \/<br \/>\nslowlog = \/var\/log\/php-fpm\/www-slow.log<br \/>\nphp_value[session.save_handler] = files<br \/>\nphp_value[session.save_path] = \/home\/$sdomain$domain\/tmp\/session<br \/>\nphp_admin_value[open_basedir] = \/home\/$sdomain$domain\/www:\/home\/$sdomain$domain\/tmp:\/usr\/share\/php:\/tmp<br \/>\nphp_admin_value[upload_tmp_dir] = \/home\/$sdomain$domain\/tmp<br \/>\nEOF<br \/>\n# cat &gt; \/etc\/logrotate.d\/$sdomain$domain &lt;&lt;EOF<br \/>\n#\/data\/$sdomain$domain\/log\/*.log {<br \/>\n#daily<br \/>\n#missingok<br \/>\n#rotate 7<br \/>\n#compress<br \/>\n#delaycompress<br \/>\n#notifempty<br \/>\n#create 640 nginx adm<br \/>\n#sharedscripts<br \/>\n#postrotate<br \/>\n# [ -f \/var\/run\/nginx.pid ] &amp;&amp; kill -USR1 `cat \/var\/run\/nginx.pid`<br \/>\n#endscript<br \/>\n#}<br \/>\n#EOF<br \/>\nsystemctl restart nginx<br \/>\nsystemctl restart php-fpm<br \/>\nsystemctl status nginx<br \/>\nsystemctl status php-fpm<br \/>\necho &#8220;successful!&#8221;;<br \/>\nexit;<br \/>\nelif [ &#8220;$selected&#8221; == &#8216;del&#8217; ]; then<br \/>\necho &#8220;input domain&#8221;;<br \/>\nread domain<br \/>\necho &#8220;input second domain [need add . at end]&#8221;;<br \/>\nread sdomain<br \/>\nrm \/etc\/nginx\/conf.d\/$sdomain$domain.conf<br \/>\ntar zcvf \/home\/bakdel$sdomain$domain.tar.gz \/home\/www\/$sdomain$domain<br \/>\nrm \/home\/www\/$sdomain$domain -rf<br \/>\nexit;<br \/>\nelif [ &#8220;$selected&#8221; == &#8216;exit&#8217; ]; then<br \/>\nexit;<br \/>\nfi;<\/p>\n<p>&#8216;&gt;&gt;\/usr\/sbin\/vhost<\/p>\n<p>chmod +x \/usr\/sbin\/vhost<br \/>\necho -e &#8220;\\033[46mneed set mysql mysql_secure_installation\\nset dropbox key! go \/root\/dropbox_uploader.sh info\\ncrontab -e [0 5 * * * \/bin\/bash \/root\/tools\/backup.sh]\\npanel and vhost command can help you \\033[0m&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e2a\u811a\u672c\u4e3b\u8981\u662f\u6211\u7528\u6765\u4e00\u952e\u914d\u7f6e\u670d\u52a1\u5668\u7528\u7684\u3002 \u4e3b\u8981\u5305\u62ecnginx1.10 php5.6 mysql5.6\u00a0post &hellip; <a href=\"https:\/\/nby.me\/?p=74\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">Centos7 \u5b89\u88c5MySQL5.6 php5.6 nginx1.10 \u90ae\u4ef6\u670d\u52a1 \u4ee5\u53cavhost\u811a\u672c<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/posts\/74"}],"collection":[{"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nby.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74"}],"version-history":[{"count":2,"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":76,"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions\/76"}],"wp:attachment":[{"href":"https:\/\/nby.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nby.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nby.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}