今天在群里发现一些用户不会安装centos 服务器的 WEB SERVER。
 
就随手写了一个脚本,一步搞定,由于时间关系没有做webserver性能上的优化,后面如果有其它的需求,我们在更新这个脚本。
 
安装上的webserver: nginx  php-fpm   mysql
 
使用:   
sh aliyun_ecs_install_webserver.sh www.youdomain.com  
注:(www.youdomain.com是需要访问的域名)
 
安装后,如果你的域名指向安装服务器的IP,  就直接可以访问你的安装域名了,会输出phpinfo;
 
注: 一定要用root账号运行,不然不保证安装成功。
 
sh 文件下载:   
 
广告一下啊,我的项目
邮大爷  (
https://www.youdaye.com)
 
这是源代码:
 
#如果要修改web的目录,请修改:WEBHTML="/usr/share/nginx/html"
 
#!/bin/bash
#For aliyun ECS (centos system)
#web server : nginx   php-fpm   mysql
#author xiaohui<xh.8326@gmail.com>
#version 1.0.0
if [ $# -lt 1 ]
    then
        echo "used: sh $0 site domain(as:youdomain.com)";
    exit 0;
fi
# you site domain
SITENAME=$1
# modify you domain path 
# nginx default: /usr/share/nginx/html
WEBHTML="/usr/share/nginx/html"
# web server
# nginx   php-fpm   mysql
# 1 yum install mysql
yes | yum install mysql*
# 2 yum install php*
yes | yum install php*
# 3 yum install nginx
NGXYUM="
[nginx]\nname=nginx repo\nbaseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/\ngpgcheck=0\nenabled=1\n
"
echo -e $NGXYUM > /etc/yum.repos.d/nginx.repo
yes | yum install nginx
# start web server
chkconfig nginx on
chkconfig mysqld on
chkconfig php-fpm on
# add site conf
NGXSERVER="
server\n
{\n
    listen      80;\n
    server_name ${SITENAME};\n
    root        ${WEBHTML}/${SITENAME};\n
    index       index.php index.html;\n
    access_log  /var/log/${SITENAME}.access.log  main;\n
    error_page  404              /404.html;\n
    error_page  500 502 503 504  /50x.html;\n
    location = /50x.html {\n
        root   /usr/share/nginx/html;\n
    }\n
    location / {\n
        if (!-e \$request_filename) {\n
            rewrite ^/.*\$ /index.php last;\n
        }\n
    }\n
    location ~*\.(gif|jpg|png|js|css|ico|html|ico)$ {\n
        expires 120d;\n
    }\n
    location ~ \.php\$ {\n
        fastcgi_pass    127.0.0.1:9000;\n
        fastcgi_index   index.php;\n
        fastcgi_param   SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n
        include         fastcgi_params;\n
    }\n
}\n
"
echo -e $NGXSERVER > /etc/nginx/conf.d/${SITENAME}".conf"
PHPTEST="
<?php \n
phpinfo();
"
mkdir ${WEBHTML}/${SITENAME}
echo -e ${PHPTEST} > ${WEBHTML}/${SITENAME}/index.php
/etc/init.d/mysqld start
/etc/init.d/php-fpm start
/etc/init.d/nginx start
 
 
 
 
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
二十五史资源多多,曹雪芹立书的王熙凤的下场一样凄凉封建颠覆体系的结果!我曾用尽全力,所以不会遗憾。塑造区块链溯源二十五史工程项目资源研究:https://mp.weixin.qq.com/s/7x1MwwpLWUgR6t3V59qeAw
-------------------------