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

[经验分享] Ubuntu14.04搭建LNMP

[复制链接]

尚未签到

发表于 2018-4-29 13:25:22 | 显示全部楼层 |阅读模式
  一、操作步骤   (具体文档请联系本博主,首页有博主邮箱)
  1.更新

  

  2.安装Nginx
  

  3.安装MySQL  

  # 连续输入两次相同的密码

  4.安装PHP

  

  5.配置PHP,修改php.ini文件

  

  将cgi.fix_pathinfo=1 设置为 cgi.fix_pathinfo=0
  启动php-fpmsudo
  

  6.配置Nginx让其使用php-fpm进程

  备份/etc/nginx/sites-available/default文件

  

  7.修改default配置文件支持PHP

  

  下边是配置文件详细信息
[...]

  server {
  listen 80;
  listen [::]:80 default_server ipv6only=on;
  

  root /usr/share/nginx/html;
  index index.php index.html index.htm;
  

  # Make site accessible from http://localhost/
  server_name _;
  

  location / {
  # First attempt to serve request as file, then
  # as directory, then fall back to displaying a 404.
  try_files $uri $uri/ /index.html;
  # Uncomment to enable naxsi on this location
  # include /etc/nginx/naxsi.rules
  }
  

  location /doc/ {
  alias /usr/share/doc/;
  autoindex on;
  allow 127.0.0.1;
  allow ::1;
  deny all;
  }
  

  # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
  #location /RequestDenied {
  #       proxy_pass http://127.0.0.1:8080;
  #}
  

  #error_page 404 /404.html;
  

  # redirect server error pages to the static page /50x.html
  #
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
  root /usr/share/nginx/html;
  }
  

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ .php$ {
  try_files $uri =404;
  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;
  }
  

  # deny access to .htaccess files, if Apache's document root
  # concurs with nginx's one
  #
  location ~ /.ht {
  deny all;
  }
  }
[...]

  取消同时侦听 IPv4 和 IPv6 的80端口。
  server_name _; 默认主机名 (当然你可以修改,例如修改为: www.example.com).
  index主页这一行我们加入 index.php。
  PHP 重要配置配置 location ~ .php$ {} 这几行我们需要启动,反注释掉。另外再添加一行:try_files $uri =404。
  8.重新加载nginx

  

  9.修改PHP配置文件

  

  修改 #cgi.fix_pathinfo=1: 为 cgi.fix_pathinfo=0:
[...]

  ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
  ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
  ; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
  ; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting
  ; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
  ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
  ; http://php.net/cgi.fix-pathinfo
  cgi.fix_pathinfo=0
[...]

  10.重新加载 PHP-FPM:

  

  11.现在创建一个探针文件保存在 /usr/share/nginx/html目录下

  vi /usr/share/nginx/html/index.php
  


  

  搭建成功PHP版本为

  PHP logo
  PHP Version 5.5.9-1ubuntu4.21
  

运维网声明 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-453589-1-1.html 上篇帖子: Ubuntu14.04搭建LAMP 下篇帖子: Ubuntu16.04搭建LAMP
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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