本帖最后由 我本戏子 于 2015-8-13 22:00 编辑 OneinStack是非常优秀的一键PHP/JAVA安装脚本,提供以下环境: lnmp(Linux + Nginx+ MySQL+ PHP) lamp(Linux + Apache+ MySQL+ PHP) lnmpa(Linux + Nginx+ MySQL+ PHP+ Apache):Nginx处理静态,Apache(mod_php)处理动态PHP lnmt(Linux + Nginx+ MySQL+ Tomcat):Nginx处理静态,Tomcat(JDK)处理JAVA lnmh(Linux + Nginx+ MySQL+ HHVM) 对于不熟悉Linux的新手来说,非常方便配置网站环境。建议大部分站长使用LAMP/LNMP/LANMP环境即可。 系统:腾讯云Centos6.6 64位 环境配置: 1 yum -y install wget screen #for CentOS/Redhat #apt-get -y install wget screen #for Debian/Ubuntu 2 wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz #包含源码,国内外均可下载 wget http://mirrors.linuxeye.com/oneinstack.tar.gz #不包含源码,建议仅国外主机下载 3 tar xzf oneinstack-full.tar.gz # tar xzf oneinstack.tar.gz cd oneinstack #如果需要修改目录(安装、数据存储、Nginx日志),请修改options.conf文件 4 screen -S oneinstack #如果网路出现中断,可以执行命令`screen -r oneinstack`重新连接安装窗口 5 ./install.sh #请勿sh install.sh或者bash install.sh这样执行 <ignore_js_op> 比如我选择LAMP架构,是这样输入的: Do you want to upgrade operating system? [y/n]: y Your system is already upgraded! Please input SSH port(Default: 22): Do you want to install Web server? [y/n]: y Please select Nginx server: 1. Install Nginx 2. Install Tengine 3. Do not install Please input a number:(Default 1 press Enter) 3 Please select Apache server: 1. Install Apache-2.4 2. Install Apache-2.2 3. Do not install Please input a number:(Default 3 press Enter) 2 Please select tomcat server: 1. Install Tomcat-8 2. Install Tomcat-7 3. Do not install Please input a number:(Default 3 press Enter) 3 Do you want to install Database? [y/n]: y Please select a version of the Database: 1. Install MySQL-5.6 2. Install MySQL-5.5 3. Install MariaDB-10.0 4. Install MariaDB-5.5 5. Install Percona-5.6 6. Install Percona-5.5 Please input a number:(Default 1 press Enter) 1 Please input the root password of database: root3306 Do you want to install PHP? [y/n]: y Please select a version of the PHP: 1. Install php-5.3 2. Install php-5.4 3. Install php-5.5 4. Install php-5.6 5. Install php-7/phpng(beta) Please input a number:(Default 1 press Enter) 3 Do you want to install opcode cache of the PHP? [y/n]: y Please select a opcode cache of the PHP: 1. Install Zend OPcache 2. Install XCache 3. Install APCU Please input a number:(Default 1 press Enter) 1 Do you want to install ionCube? [y/n]: n Do you want to install ImageMagick or GraphicsMagick? [y/n]: n Do you want to install Pure-FTPd? [y/n]: y Do you want to install phpMyAdmin? [y/n]: y Do you want to install redis? [y/n]: n Do you want to install memcached? [y/n]: n Do you want to use jemalloc or tcmalloc optimize Database and Web server? [y/n]: n Do you want to install HHVM? [y/n]: n 然后系统自动编译。大概需要半个小时。 安装完成后会给出APACHE MYSQL PHP PHPMYADMIN等的安装目录等 并询问是否重启主机,输入y,确定重启。 我在上面选择的环境是apache2.2+mysql5.6+php5.5+phpmyadmin(建议)+Zend OPcache 其他组件我用不上,如果你用得上 那么就输入y。 Zend OPcache 通过 opcode 缓存和优化提供更快的 PHP 执行过程。它将预编译的脚本文件存储在共享内存中供以后使用,从而避免了从磁盘读取代码并进行编译的时间消耗。同时,它还应用了一些代码优化模式,使得代码执行更快。 重启后,SSH连接云服务器并 cd oneinstack 添加网站(虚拟主机) ./vhost.sh Please input domain(example: www.linuxeye.com): qq.com domain=qq.com Do you want to add more domain name? [y/n]: y Type domainname,example(linuxeye.com www.example.com): www.qq.com domain list=www.qq.com Please input the directory for the domain:baidu.com : (Default directory: /home/wwwroot/qq.com): Virtual Host Directory=/home/wwwroot/qq.com Create Virtul Host directory...... set permissions of Virtual Host directory...... Allow Apache access_log? [y/n]: y You access log file=/home/wwwlogs/baidu.com_apache.log Syntax OK Restart Apache...... 上面我的选择是绑定qq.com和www.qq.com,允许生成访问日志,网站主目录设置为/home/wwwroot/qq.com 现在我们即可SFTP连接到云服务器进入/home/wwwroot/qq.com目录,上传网站程序。 如何添加数据库? 本地浏览器打开phpmyadmin地址(上面我选择了按照phpmyadmin),用户名root密码是刚才你设置的密码。 新建数据库,新建数据库用户并授权。 现在即可安装网站。 如果我添加虚拟主机的时候输入错了信息,怎么办呢? 删除虚拟主机 ./vhost.sh del 可选择 是否删除该虚拟主机目录下数据。 如何备份? ./backup_**p.sh //设置备份选项 ./backup.sh //立即备份 crontab -e //把备份加入任务计划 0 1 * * * cd ~/oneinstack;./backup.sh > /dev/null 2>&1 & 如何管理服务? Nginx/Tengine: service nginx {start|stop|status|restart|reload|configtest} MySQL/MariaDB/Percona: service mysqld {start|stop|restart|reload|status} PHP: service php-fpm {start|stop|restart|reload|status} HHVM: service supervisord {start|stop|status|restart|reload} 注:hhvm进程交给supervisord管理 Apache: service httpd {start|restart|stop} Tomcat: service tomcat {start|stop|status|restart} Pure-Ftpd: service pureftpd {start|stop|restart|status} Redis: service redis-server {start|stop|status|restart|reload} Memcached: service memcached {start|stop|status|restart|reload} 如何更新apache/nginx的版本? ./upgrade.sh 可以选择更新各种环境组件 What Are You Doing? 1. Upgrade Nginx/Tengine 2. Upgrade MySQL/MariaDB/Percona 3. Upgrade PHP 4. Upgrade Redis 5. Upgrade phpMyAdmin q. Exit 如何卸载oneinstack? ./uninstall.sh |