Ubuntu14.04搭建LNMP平台

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

<?php

phpinfo();

?>

浏览器测试:

http://IP/info.php


将制作的php网页页面原文件上传至/usr/share/nginx/html/目录下即可


以上是关于Ubuntu14.04搭建LNMP平台的主要内容,如果未能解决你的问题,请参考以下文章

记一次使用Ubuntu 14.04 LTS搭建FBctf平台

ubuntu14.04 安装LNMP

Ubuntu14.04下搭建Bochs仿真平台,同时用该平台安装Linux0.11内核

Ubuntu14.04server + LNMP + Zabbix3.4安装教程

Ubuntu系统搭建Zabbix监控

Ubuntu14.04安装lnmp(nginx+php-fpm+mysql), nginx reload总是fail,附操作步骤,请指点,谢谢。