Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 14|回复: 0
打印 上一主题 下一主题

ubuntu 14.04下配置LNMP

[复制链接]

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
跳转到指定楼层
楼主
发表于 2016-8-5 10:26:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 zangcf 于 2016-8-5 10:58 编辑

ubuntu 14.04下配置LNMP
1,首先,执行apt-get update
2,然后,安装nginx,如何ip地址并测试
3,修改配置文件如下:
# You may add here your
# server {
#        ...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

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

        root /www;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        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
        }

        # 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;
        #}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#        listen 8000;
#        listen somename:8080;
#        server_name somename alias another.alias;
#        root html;
#        index index.html index.htm;
#
#        location / {
#                try_files $uri $uri/ =404;
#        }
#}


# HTTPS server
#
#server {
#        listen 443;
#        server_name localhost;
#
#        root html;
#        index index.html index.htm;
#
#        ssl on;
#        ssl_certificate cert.pem;
#        ssl_certificate_key cert.key;
#
#        ssl_session_timeout 5m;
#
#        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
#        ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
#        ssl_prefer_server_ciphers on;
#
#        location / {
#                try_files $uri $uri/ =404;
#        }
#}

4,重启nginx
service nginx reload
5,安装mysql
apt-get install mysql-server mysql-client
6,安装php模块
apt-get install php5-fpm php5-mysql
7,配置PHP,修改php.ini文件
# 备份php.ini文件cp /etc/php5/fpm/php.ini /etc/php5/fpm/php.ini.back# 取消有安全隐患的pathinfo模式vim /etc/php5/fpm/php.ini# 将cgi.fix_pathinfo=1 设置为 cgi.fix_pathinfo=0cgi.fix_pathinfo=0#启动php-fpmsudo service php5-fpm restart
8,测试php模块在/www下面建立info.php文件<?php        phpinfo();?>浏览器输入:http://47.88.103.44/info.php会显示出php相关信息



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Comsenz Inc.

GMT+8, 2025-12-14 19:06 , Processed in 0.013360 second(s), 9 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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