半只蚂蚁 发表于 2019-2-19 09:58:27

Ubuntu14.04搭建LNMP平台

  更新源:
  apt-get install update
  关闭apache2:
  /etc/init.d/apache2 stop
  安装nginx:
  apt-get install nginx
  安装MYSQL:
  apt-get install mysql-server #连续输入两次相同密码,密码为mysql管理账户所使用
  安装PHP:
  apt-get install php5-fpm php5-mysql
  配置PHP,修改php.ini文件:
  cp /etc/php5/fpm/php.ini /etc/php5/fpm/php.ini.back #备份php.ini文件
  vim /etc/php5/fpm/php.ini
  cgi.fix_pathinfo=0#取消有安全隐患的pathinfo模式
  启动php-fpm
  service php5-fpm restart
  配置nginx,让其使用php5-fpm进程
  cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.back
  vim /etc/nginx/sites-available/default
  server {
  listen 80 default_server;
  listen [::]:80 default_server ipv6only=on;
  root /usr/share/nginx/html;
  index index.html index.htm;
  server_name localhost;
  location / {
  # First attempt to serve request as file, then
  # as directory, then fall back to displaying a 404.
  try_files $uri $uri/ =404;
  # Uncomment to enable naxsi on this location
  # include /etc/nginx/naxsi.rules
  }
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
  root /usr/share/nginx/html;
  }
  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;
  #       fatcgi_param SCRITP_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
  }
  }
  重启nginx服务:
  service nginx restart
  建立info.php测试文件:
  vim /usr/share/nginx/html/info.php
  
  浏览器测试:
  http://IP/info.php
  将制作的php网页页面原文件上传至/usr/share/nginx/html/目录下即可



页: [1]
查看完整版本: Ubuntu14.04搭建LNMP平台