设为首页 收藏本站
查看: 974|回复: 0

使用LNMP常见问题解答

[复制链接]
累计签到:5 天
连续签到:1 天
发表于 2015-8-21 10:16:01 | 显示全部楼层 |阅读模式
使用LNMP常见问题解答
  一、LNMP的安装过程详解,注:绿色文字为注释,实际使用过程中没有。



##先要下载,并根据不同系统进行安装:
wget -c http://soft.vpser.net/lnmp/lnmp1.0.tar.gz
tar zxvf lnmp1.0.tar.gz
cd lnmp1.0
./centos.sh #如果您是其它系统,则命令改为:./ubuntu.sh 或 debian.sh  以上为下载及进入安装过程,以下为安装前简易设置,切记输入个其它域名及牢记mysql密码:



=========================================================================
LNMP V1.0 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 the root password of mysql:
(Default password: root):vpsmm.com #请输入mysql密码
===========================
MySQL root password:vpsmm.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):
INPUT error,The InnoDB Storage Engine will NOT install! #是否安装InnoDB
===========================
Install PHP 5.3.17,Please input y
Install PHP 5.2.17,Please input n or press Enter
(Please input y or n):y #选择php版本
You will install PHP 5.3.17
===========================
Install MySQL 5.5.27,Please input y
Install MySQL 5.1.60,Please input n or press Enter
(Please input y or n):y #选择mysql版本
You will install MySQL 5.5.27
Press any key to start...or Press Ctrl+c to cancel
CentOS release 6.3 (Final)#按任意键,设置完成,正式进入安装,预计20-40分钟完成二,域名绑定详解
  其实所谓的域名绑定,就是通过命令的形式,简易创建一个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):legcloud.com #输入你要绑定的域名,legcould和www.legcloud要分别绑定
===========================
domain=legcloud.com
===========================
Do you want to add more domain name? (y/n)
y #是否添加子域名,可以输入y或n,这里输入y
Type domainname,example(bbs.vpser.net forums.vpser.net luntan.vpser.net):
www.legcloud.com #输入你要绑定的其它域名,支持泛解析,例如:*.legcloud.com
===========================
domain list=www.legcloud.com
===========================
Please input the directory for the domain:legcloud.com :
(Default directory: /home/wwwroot/legcloud.com):/home/legcloud.com #网站存放目录,可默认或自行输入
===========================
Virtual Host Directory=/home/legcloud.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 #输入wordpress就可以
===========================
You choose rewrite=wordpress
===========================
===========================
Allow access_log? (y/n)
===========================
n #是否创建日志文件,如果不需要可不用
Press any key to start create virtul host...
#按任意建继续,以下为一些相关信息,包括创建目录,测试nginx等,如果有错误提示,请一定要认真分析
Create Virtul Host directory......
set permissions of Virtual Host directory......
You select the exist rewrite rule:/usr/local/nginx/conf/wordpress.conf
Test Nginx configure file......
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
Restart Nginx......
=========================================================================
Add Virtual Host for LNMP V0.9  ,  Written by Licess
=========================================================================
For more information please visit http://www.lnmp.org/
Your domain:legcloud.com
Directory of legcloud.com:/home/legcloud.com
=========================================================================三、自定义伪静态规则
  如果lnmp默认的伪静态规则不能满足你的需要,或者,你要自行定义伪静态规则,可以新建一个conf文件,放置于 /usr/local/nginx/conf 下,在域名配置文件,即:/usr/local/nginx/conf/vhost/legcloud.com.conf 里引用。



server
{
listen       80;
server_name legcloud.com www.legcloud.com; #绑定的域名
index index.html index.htm index.php default.html default.htm default.php; #首页文件
root  /home/legcloud.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;
}  修改设置以后,一定要重新载入lnmp或者,重新载入nginx,以下任决命令都一样:



/root/lnmp reload #使用lnmp重新载入配置
/etc/init.d/nginx reload #只重新载入nginx配置,我一般用这个四、自定义404、503等常见错误
  不管是404还是503等常见错误,还是设置/usr/local/nginx/conf/vhost/legcloud.com.conf文件来完成:



listen       80;
server_name legcloud.com www.legcloud.com;
index index.html index.htm index.php default.html default.htm default.php;
root  /home/legcloud.com;
error_page 404 /404.php; #放在这里,可自定义文件名,再重载nginx就可以了
include wordpress.conf;五、判断当前域名并自动301到主域名



if ($host != 'vpsmm.com' ) {rewrite ^/(.*)$ http://www.vpsmm.com/$1 permanent;}
#判断当前域名,如果不是则自动301到主域名,放置于error_page ...;上下均可。六、关闭或开启FSO等php函数
  lnmp最新版,默认禁用了一些函数,例如fso等,可修改/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
  七、升级PHP和NGINX版本



cd lnm0.9 #进入lnmp安装目录
./upgrade_nginx.sh #升级nginx,只要输入你要升级的版本即可(可见nginx.org)
./upgrade_php.sh #升级php,只要输入你要升级的版本即可(可见php.net)

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-102051-1-1.html 上篇帖子: [转]专访企业QQ SaaS团队,谈企业级LNMP架构设计 下篇帖子: LNMP集成环境安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表