Linux云主机搭建LNMP

  前几天帮朋友给他新购的阿里云主机配置环境,这兄弟自己为了研究下是如何安装的,重新更换了下系统就自己开始尝试动手安装LNMP,也失败了,手动配置环境很多地方都需要修改,并且还有很多问题,对于我们这些新手来说还是直接跟我一样使用LNMP一键安装包来配置环境最方便了。

  一、LNMP的安装过程
  通过Putty连接到云主机后根据系统版本执行下面的命令。
  CentOS执行:wget -c http://soft.vpser.net/lnmp/lnmp0.9-full.tar.gz && tar zxvf lnmp0.9-full.tar.gz && cd lnmp0.9-full && ./centos.sh
  Debian执行:wget -c http://soft.vpser.net/lnmp/lnmp0.9-full.tar.gz && tar zxvf lnmp0.9-full.tar.gz && cd lnmp1.0-full && ./debian.sh
  Ubuntu执行:wget -c http://soft.vpser.net/lnmp/lnmp0.9-full.tar.gz && tar zxvf lnmp0.9-full.tar.gz && cd lnmp0.9-full && ./ubuntu.sh
  在下载执行编译过程中需要简单的设置下主机域名MySQL密码是否安装InnoDB

=========================================================================
LNMP V0.9 for CentOS/RadHat Linux VPS  Written by Licess
=========================================================================
A tool to auto-compile & install Nginx+MySQL+PHP on Linux

For more information please visit http://www.lnmp.org/
=========================================================================
Please input domain:
(Default domain: www.lnmp.org):www.zhangweilong.com  //输入主机域名地址
===========================
domain=www.zhangweilong.com
===========================
===========================
Please input the root password of mysql:
(Default password: root):www.zhangweilong.com        //输入MySQL密码
===========================
mysqlrootpwd=www.zhangweilong.com
===========================
===========================
Do you want to install the InnoDB Storage Engine?
(Default no,if you want please input: y ,if not please press the enter button):y
                                                    //是否需要安装InnoDB
You will install the InnoDB Storage Engine

  经过十几分钟到半个多小时的等待终于安装完毕喽。

  二、域名绑定设置
  其实所谓的域名绑定,就是通过命令的形式,简易创建一个conf文件到/usr/local/nginx/conf/vhost下面,这个过程完全可以手工创建conf,或者,平时修改目录、域名等,直接修改conf文件,效果完全一样:

/root/vhost.sh //lnmp域名绑定命令
=========================================================================
Add Virtual Host for LNMP V0.9  ,  Written by Licess
=========================================================================
LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux
This script is a tool to add virtual host for nginx
For more information please visit http://www.lnmp.org/

=========================================================================
Please input domain:
(Default domain: www.lnmp.org):www.zhangweilong.com     //属于需要绑定的域名,zhangweilong.com和www.zhangweilong.com要分别来绑定
===========================
domain=www.zhangweilong.com
===========================
Do you want to add more domain name? (y/n)  //是否需要绑定其他域名
zhangweilong.com                            //输入你要绑定的其它域名,支持泛解析,例如:*.zhangweilong.com
Please input the directory for the domain:www.zhangweilong.com :
(Default directory: /home/wwwroot/www.zhangweilong.com):/home/wwwroot/zhangweilong      //网站存放目录,可默认或自行输入
===========================
Virtual Host Directory=/home/wwwroot/zhangweilong
===========================
===========================
Allow Rewrite rule? (y/n)                   //是否添加伪静态规则
===========================
y
Please input the rewrite of programme :
wordpress,discuz,typecho,sablog,dabr rewrite was exist.
(Default rewrite: other):wordpress          //根据程序选择伪静态规则,我是用wordpress就直接输入wordpress就可以了
===========================
You choose rewrite=wordpress
===========================
===========================
Allow access_log? (y/n)                     //是否需要创建日志文件
===========================
n
Press any key to start create virtul host...
=========================================================================

三、开启/关闭FSO等PHP函数
  LNMP最新版默认禁止了一些函数,例如FSO等,这样会导致WordPress等程序有些功能无法正常运行,可以修改/usr/local/php/etc/php.ini来解决。

disable_functions = passthru,exec,system,chroot,scandir....
//这是禁用函数,把不想禁用的删除即可----如果自用主机,最简单的修改方案:
disable_functions =
; passthru,exec,system,chroot,scandir....
//设置为全部开启

  修改好后使用/etc/init.d/php-fpm restart,重启PHP服务。

最后修改:7年前

共有 1 条评论