在Debian系统下配置LNMP的教程
linux  /  管理员 发布于 4年前   526
LNMP环境的配置是需要让我们的主机支持Nginx、MySQL、PHP、phpMyAdmin,这样配置好之后就可以直接使用此环境,并在上面运行网站了,下面我来配置方法。 我们先来看官方说明 LNMP一键安装包是一个用Linux Shell编写的可以为CentOS/RadHat、Debian/Ubuntu VPS(VDS)或独立主机安装LNMP(Nginx、MySQL、PHP、phpMyAdmin)生产环境的Shell程序 即可安装MySQL,安装过程中会询问 root密码 ,键入你需要的密码之后回车即可。 安装完成后,执行如下命令进行一步安全设置: 按照提示进行,过程中会询问是否更改 root密码,是否移除匿名用户,是否禁止root远程登录等。 上面的命令安装了php5-memcache的扩展,于是继续安装 Memcached 。 安装完毕之后,使用 php5-fpm -v 查看一下PHP的版本: PHP 5.4.16-1~dotdeb.1 (fpm-fcgi) (built: Jun 8 2013 22:20:42) 3,安装Nginx 这里我直接安装了Nginx的全部扩展功能(nginx-full),以应对以后可能出现的功能性增强。 然后启动Nginx: 访问结果如上图,接下来配置Nginx。 …… 修改保存之后重启Nginx: 接下来我们新建一个phpinfo,查看php的详细信息: 保存之后访问 http://ip/phpinfo.php , 如果出现 phpinfo 页面,则大功告成。 如何新建站点 进入配置文件目录,新建一个站点配置文件,比如 保存之后重启Nginx,添加及绑定网站即完成。 最后,附两个最常用的程序Nginx伪静态: WordPress: Discuz X:
1,安装MySQL
执行命令:apt-get install -y mysql-server mysql-client
mysql_secure_installation
2,安装PHP
执行命令:apt-get install php5-fpm php5-gd php5-mysql php5-memcache php5-curl
apt-get install memcached
root@ztbox:~# php5-fpm -v
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologiesapt-get install -y nginx-full
service nginx start
vim /etc/nginx/sites-available/default
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
……service nginx restart
vim /usr/share/nginx/html/phpinfo.php
和军哥的一键包不同,此方法所安装的 LNMP 需要手动添加站点配置文件。cd /etc/nginx/conf.d
vi dearroy.com.confserver { listen 80; #ipv6 #listen [::]:80 default_server; root /usr/share/nginx/html/dearroy.com; #默认首页文件名 index index.php index.html index.htm; #绑定域名 server_name localhost; #伪静态规则 include wordpress.conf; location / { try_files $uri $uri/ /index.html; } #定义错误页面 #error_page 404 /404.html; location ~ .php$ { fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } #PHP}
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
rewrite ^([^.]*)/article-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^.]*)/forum-(w+)-([0-9]+).html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^.]*)/group-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^.]*)/space-(username|uid)-(.+).html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^.]*)/([a-z]+)-(.+).html$ $1/$2.php?rewrite=$3 last;
if (!-e $request_filename) {
return 404;
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号