欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

lnmp使用实例

程序员文章站 2024-04-05 21:39:01
...

更新系统 #yum check-update#yum update 安装Screen #yum install screen 开始安装lnmp: #screen -S lnmp#wget -c http://soft.vpser.net/lnmp/lnmp0.8.tar.gz //最新版请查阅lnmp官网#tar zxvf lnmp0.8.tar.gz#./lnmp0.8/centos.sh | tee lnmp.log //输出lo

更新系统

#yum check-update
#yum update

安装Screen

#yum install screen

开始安装lnmp:

#screen -S lnmp
#wget -c http://soft.vpser.net/lnmp/lnmp0.8.tar.gz //最新版请查阅lnmp官网
#tar zxvf lnmp0.8.tar.gz
#./lnmp0.8/centos.sh | tee lnmp.log //输出log文件,以备出错时查阅

接下来按照提示设定域名和mysql密码,程序会自动下载相关程序,而后编译安装之

安装PureFTP:

#./lnmp0.8/pureftp.sh

按提示输入mysql和ftp管理员密码,安装完成后可以通过http://vpsip/ftp/来登录管理ftp帐号

使用LNMP

添加虚拟主机:

#/root/vhost.sh

按照提示填入域名、目录、rewrite规则文件,如下所示:

root@buyvm256:~#/root/vhost.sh
=========================================================================
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):xxx.com
===========================
domain=xxx.com
===========================
Do you want to add more domain name? (y/n)  //添加更多域名
y
Type domainname,example(bbs.vpser.net forums.vpser.net luntan.vpser.net):
www.xxx.com
===========================
domain list=www.xxx.com
===========================
Please input the directory for the domain:xxx.com :  //网站目录
(Default directory: /home/wwwroot/xxx.com):
===========================
Virtual Host Directory=/home/wwwroot/xxx.com
===========================
===========================
Allow Rewrite rule? (y/n)  //重写规则
===========================
y
Please input the rewrite of programme :
wordpress,discuz,typecho,sablog,dabr rewrite was exist.
(Default rewrite: other):wordpress  //选择重写规则
===========================
You choose rewrite=wordpress
===========================
===========================
Allow access_log? (y/n)  //是否记录log
===========================
n
Press any key to start create virtul host...

然后,登录 http://vpsip/ftp添加ftp帐号,http://vpsip/phpmyadmin/增加数据库

注意:开通ftp时,记着添加到www用户组

修改虚拟主机配置

创建好的虚拟主机,配置文件目录为/wp-content/local/nginx/conf/vhost/,文件名为domain.conf,如下所示:

aquan@buyvm256:~$ cat /usr/local/nginx/conf/vhost/xxx.com.conf 
server
        {
                listen       80;   //端口
                server_name xxx.com www.xxx.com;   //域名
                index index.html index.htm index.php default.html default.htm default.php;  //索引文件
                root  /home/wwwroot/xxx.com;   //目录
                include wordpress.conf;
                location ~ .*\.(php|php5)?$
                        {
                                try_files $uri =404;
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }
                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }
                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }
                access_log off;
        }

主机配置文件修改后,使用如下命令重新加载配置使之生效

#/etc/init.d/nginx reload

删除虚拟主机

删除/wp-content/local/nginx/conf/vhost/下对应配置文件(.conf),再删除/home/wwwroot/下的本地目录

一些其他问题

设置虚拟主机目录权限

#chown -R www /home/wwwroot/vps.aotee.com
#chmod -R 777 /home/wwwroot/vps.aotee.com