Ubuntu14.04搭建LNMP
admin
2023-03-19 11:41:23
0

一、操作步骤   (具体文档请联系本博主,首页有博主邮箱)

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


相关内容

热门资讯

90分钟16条,特朗普的社媒账... 周六下午,特朗普将他的Truth Social账号变成了“AI垃圾工厂”,在短短90分钟内发布了16...
我,22岁,确诊为“妈” 又是一年母亲节。每年今天,大家都试图再次看见母亲,讨论她们的付出与局限,以“成为母亲”为界限,划分她...
重达11000克拉!缅甸发现“... 【环球网报道】美国哥伦比亚广播公司、英国天空新闻网等媒体援引缅甸官方媒体8日消息报道称,缅甸发现一块...
玻璃缝隙漏水怎么处理 1、检查窗户玻璃附近墙体的防水层,重新做防水层。2、查找原先的密封物,检查门窗与墙体的密封度,如果密...
热水器侧面的缝隙漏水可以修好吗 问题:热水器侧面的缝隙漏水可以修好吗回答:如果热水器侧面出现缝隙漏水的情况基本上都是可以修好的。首先...
洗面盆和台面缝隙漏水怎么办 洗菜盆漏水的修补方法1、如果是洗菜盆和台面衔接松动:如果是因为洗菜盆安装时没安装好,与台面缝隙过大,...
空调缝隙漏水怎么办 空调在一定的年限服务后,会出现一些问题,例如漏水。空调漏水是比较常见的问题,但有许多原因可能导致空调...
不用电的情况下空气开关跳闸是怎... 家用空气断路器跳闸的原因很好判断,如果漏电断路器脱扣后复位按钮突出,则可以断定电路有漏电,需要注意的...
宏福苑母亲节晚宴,女儿希望火中... 凤凰卫视记者在香港报道:有慈善机构为大埔宏福苑居民举办母亲节晚宴,参加的居民表示,经历大火后更深刻体...
顺风车乘客拒付高速费,00后车... 近日,江苏苏州一00后车主接了一单顺风车,车主称下单时乘客已经点击确定承担全部高速费,可下高速时乘客...