下载一键包: wget http://10.0.0.188/lnmp-full.tar.gz 安装: tar xzf lnmp-full.tar.gz 进入lnmp: cd lnmp 执行安装: ./install.sh 安装流程: Please input SSH port(Default: 22): (默认22回车) Do you want to enable iptables? [y/n]: y 是否开启iptebles,如果安全组开启,可关闭 (选择Y) Do you want to install Web server? [y/n]: y 是否安装Nginx、Apache、Tomcat (选择Y) Please select Nginx server: 1. Install Nginx 2. Install Tengine 3. Install OpenResty 4. Do not install Please input a number:(Default 1 press Enter) 1 (选择1) 可自由组合有4种 LNMP:安装Nginx,不安装Apache、Tomeat(系统运行php-fpm进程) 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) (直接回车) LAMP:不安装Nginx,安装Apache、Tomeat(无php-fpm进程,php以模块形式加载在Apache中)() 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) LNMPA:安装Nginx、Apache,不安装Tomcat(该模式下,静态资源由Nginx处理,php由Apache处理,无php-fpm进程,php以模块形式加载在Apache中) PHP用户推荐使用lnmp,java用户推荐lnmt Do you want to install Database? [y/n]: y 是否安装数据库(选择y) Please select a version of the Database: 1. Install MySQL-8.0 2. Install MySQL-5.7 3. Install MySQL-5.6 4. Install MySQL-5.5 5. Install MariaDB-10.3 6. Install MariaDB-10.2 7. Install MariaDB-10.1 8. Install MariaDB-10.0 9. Install MariaDB-5.5 10. Install Percona-5.7 11. Install Percona-5.6 12. Install Percona-5.5 13. Install AliSQL-5.6 14. Install PostgreSQL 15. Install MongoDB Please input a number:(Default 2 press Enter) 2 选择2 (数据库版本Install MySQL-5.7) Please input the root password of MySQL(default: 0jwo46Fd): 设置数据库密码: Please choose installation of the database: 1. Install database from binary package. 2. Install database from source package. Please input a number:(Default 1 press Enter) 1 数据库安装方式:建议(二进制),源码编译 Do you want to install PHP? [y/n]: y 是否安装php(选择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.0 6. Install php-7.1 7. Install php-7.2 Please input a number:(Default 5 press Enter) 1 选择1 Please select a opcode cache of the PHP: 1. Install Zend OPcache 2. Install XCache 3. Install APCU 4. Install eAccelerator-0.9 Please input a number:(Default 1 press Enter) 1 建议选择1 Do you want to install opcode cache of the PHP? [y/n]: y 选择OP缓存类型 Do you want to install ionCube? [y/n]: n 选择图片处理 Do you want to install ImageMagick or GraphicsMagick? [y/n]: y 安装IMAGE或GraphicsMagick Please select ImageMagick or GraphicsMagick: 1. Install ImageMagick 2. Install GraphicsMagick Please input a number:(Default 1 press Enter) 为空 空格键安装 Do you want to install Pure-FTPd? [y/n]:y 安装ftp Do you want to install phpMyAdmin? [y/n]: y 是否安装phpMyadmin Do you want to install redis? [y/n]:y 安装redis Do you want to install memcached? [y/n]:y 安装memcached Do you want to install HHVM? [y/n]:n 是否安装HHVM(建议不安装) 等待安装............................................最后输入y重启即可。 ####################Congratulations######################## Total OneinStack Install Time: 16 minutes Nginx install dir: /usr/local/nginx Database install dir: /usr/local/mysql Database data dir: /data/mysql Database user: root Database password: aasd11235316 PHP install dir: /usr/local/php Opcache Control Panel URL: http://10.0.0.200/ocp.php Pure-FTPd install dir: /usr/local/pureftpd Create FTP virtual script: ./pureftpd_vhost.sh phpMyAdmin dir: /data/wwwroot/default/phpMyAdmin phpMyAdmin Control Panel URL: http://10.0.0.200/phpMyAdmin redis install dir: /usr/local/redis memcached install dir: /usr/local/memcached Index URL: http://10.0.0.200/ Please restart the server and see if the services start up fine. 安装好的路径 ###################################################################################### 接下来添加虚拟主机 添加虚拟主机 ./vhost.sh What Are You Doing? 1. Use HTTP Only 2. Use your own SSL Certificate and Key 3. Use Let's Encrypt to Create SSL Certificate and Key q. Exit Please input the correct option: 1 选择1 Please input domain(example: www.example.com): www.hanlee.top 添加主机域名. Please input the directory for the domain:www.hanlee.top : (Default directory: /data/wwwroot/www.hanlee.top): 修改网站根目录,默认为以上路径,我们将它更改为/var/www/ Do you want to add more domain name? [y/n]:y 提示你再添加一个域名。我们选择y Type domainname or IP(example: example.com other.example.com):hanlee.top 再次输入一次不带www的。 Do you want to redirect from hanlee.top to www.hanlee.top? [y/n]:y 选择y Do you want to add hotlink protection? [y/n]: y 选择y 热链接保护 Please input the rewrite of programme : wordpress,opencart,magento2,drupal,joomla,laravel,thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud rewrite was exist. (Default rewrite: other): wordpress You choose rewrite=wordpress 重写规则 选择wordpress Allow Nginx/Tengine/OpenResty access_log? [y/n]: y 日志,选择y nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful Reload Nginx...... ####################################################################### # OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+ # # For more information please visit https://oneinstack.com # ####################################################################### Your domain: www.hanlee.top Virtualhost conf: /usr/local/nginx/conf/vhost/www.hanlee.top.conf Directory of: /var/www/ Rewrite rule: /usr/local/nginx/conf/rewrite/wordpress.conf 已添加完成。。www根目录也修改完成 ##################################################################################################### cd lnmp 删除虚拟主机 ./vhost.sh del 删除ftp帐号 ./pureftpd_vhost.sh 更新版本? ./upgrade.sh 卸载? ./uninstall.sh LNMP中开启nginx的文件目录列表功能 vi /usr/local/nginx/conf/nginx.conf #编辑配置文件,在http {下面添加以下内容: autoindex on; #开启nginx目录浏览功能 autoindex_exact_size off; #文件大小从KB开始显示 autoindex_localtime on; #显示文件修改时间为服务器本地时间 :wq! #保存,退出 service nginx reload #重启nginx配置 即可 对中文目录的支持 在server{下面即可 location / { #root html; root /var/ftp/; autoindex on; # //开启目录浏览功能; autoindex_exact_size off; #//关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b>; autoindex_localtime on; #//开启以服务器本地时区显示文件修改日期! #index index.php index.html index.htm; } 要想创建多个www根目录,就再添加一次虚拟主机 ./vhost.sh 然后再多给一个文件夹设置成根目录。比如/var/www/ss5 给123这个文件夹设置成根目录 然后,再给123这个目录绑定一个域名,比如:ss5.hanlee.top 这样用二级域名就可以直接访问二级目录。一级域名访问不了二级目录,二级域名访问一级同意如此 最后,要设置最后一步,才能显示二级目录下的文件列表 如:我创建了ss5这个目录,我想看ss5目录下的文件。 ####################################################################### # OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+ # # For more information please visit https://oneinstack.com # ####################################################################### Your domain: ss5.hanlee.top Virtualhost conf: /usr/local/nginx/conf/vhost/ss5.hanlee.top.conf Directory of: /var/www/ss5 Rewrite rule: /usr/local/nginx/conf/rewrite/wordpress.conf 创建好之后,找到这个路径的文件/usr/local/nginx/conf/vhost/ss5.hanlee.top.conf 打开,在server下 server { autoindex on; #开启nginx目录浏览功能 autoindex_exact_size off; #文件大小从KB开始显示 autoindex_localtime on; #显示文件修改时间为服务器本地时间 添加目录显示代码。保存 #然后重启nginx配置 service nginx reload 然后我用ss5.hanlee.top加端口访问,即可访问到ss5这个二级目录下的文件列表,二级和一级目录就可以互相不冲突。 如果还需要创建第三级目录和域名,那就再./vhost.sh一遍,如果只是用于http,可以不用开启目录浏览功能,默认即可 关闭防火墙 systemctl stop firewalld.service