花蜻宽 发表于 2015-11-16 11:09:04

Ubuntu14.04简单部署LNMP环境

  1.安装mysql
  sudo apt-get install mysql-server mysql-client
  过程输入用户名和密码


  
  1.安装nginx
  sudo apt-get install nginx
  
  2.使用php5-fpm来作为我们的php解析
  sudo apt-get install php5-fpm
  
  3.修改一下nginx配置,使之支持php
  $vim /etc/nginx/sites-available/default
  server {
  listen 80 default_server;
  listen [::]:80 default_server ipv6only=on;
  
  root /usr/share/nginx/html;
  index index.php index.html index.htm;
  
  server_name localhost;
  
  location ~ \.php$ {
  fastcgi_pass unix:/var/run/php5-fpm.sock;
  fastcgi_index index.php;
  include fastcgi_params;
  }
  }
  
  即因为ubuntu的对php监听端口修改了
  修改 location ~ \.php$ {
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param APPLICATION_ENV production;
  include fastcgi_params;
  }
  
  为
  location ~ \.php$ {
  fastcgi_pass unix:/var/run/php5-fpm.sock;
  fastcgi_index index.php;
  include fastcgi_params;
  }
  
  要修改php文件存放目录,把所有的root 后的路径改为自己要的路径
  
  测试配置修改是否成功 sudo nginx -t
  
  5.重启服务
  sudo service php5-fpm restart
  sudo service nginx restart
  
  6.测试
  在/usr/share/nginx/html/目录下
  rm index.html
  vim index.php
  <?php
  phpinfo();
  ?>
  
  在浏览器里输入127.0.0.1,出现如下界面则成功

         版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: Ubuntu14.04简单部署LNMP环境