zoukankan      html  css  js  c++  java
  • LNMP

    Linux + niginx + php(fpm) 安装与配置

    1、安装nginx   

      更新好源之后,运行     

    sudo apt-get install nginx

      nginx运行指令:

    sudo /etc/init.d/nginx {start|stop|restart|reload|force-reload|status|configtest} 
    

      Nginx服务器开启之后在浏览器地址栏输入localhost后出现nginx服务器欢迎语则说明服务器安装成功。 

    2、安装MYSQL

    sudo apt-get install mysql-server mysql-client

    3、安装php   

    sudo apt-get install php5-fpm php5-cli php5-mysql

    4、配置nginx服务器   

      当php5-fpm安装完成后我们开始配置nginx服务器,在/etc/nginx/nginx.conf文件的http{}部分下添加:

    # Upstream to abstract back-end connection(s) for PHP
    upstream php {
        server unix:/tmp/php5-fpm.sock;
    }

      虚拟主机配置文件的修改(/etc/nginx/sites-enabled/default): 

     server {
            listen   80; ## listen for ipv4; this line is default and implied
            listen   [::]:80 default ipv6only=on; ## listen for ipv6
            root /usr/share/nginx/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 index.html
                    try_files $uri $uri/ /index.html;
            }
    
            #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/www;
            #}
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ .php$ {
            #       proxy_pass http://127.0.0.1;
            #}
            # 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)(/.+)$;
               #fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
             include fastcgi_params;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /.ht { deny all;   } }

      完成虚拟主机的配置后还需要修改php5-fpm的配置文件(/etc/php5/fpm/pool.d/www.conf):

    listen = 127.0.0.1:9000
    改为:
    listen = /tmp/php5-fpm.sock

     4、完成虚拟主机配置文件的修改后重启nginx服务器以及php5-fpm,运行:

    sudo service nginx restart
    sudo service php5-fpm restart

     5、测试环境

      //Info.php
      <?php 
        Echo phpinfo();
      ?>
    

    6、安装phpmyadmin

    sudo apt-get install phpmyadmin
    cd /usr/share/nginx/www
    sudo ln -s  /usr/share/phpmyadmin 
    
  • 相关阅读:
    idea的tomcat配置
    idea设置类文件的头部信息
    设置idea注释颜色
    Idea设置字体
    python 全栈开发,Day11(函数名应用,闭包,装饰器初识,带参数以及带返回值的装饰器)
    python 全栈开发,Day10(动态参数,命名空间,作用域,函数嵌套)
    python 全栈开发,Day9(函数的初始,返回值,传参,三元运算)
    python 全栈开发,Day8(文件操作)
    python 全栈开发,Day7(元组转换,列表以及字典的坑,集合,关系测试,深浅copy,编码补充)
    python 全栈开发,Day6补充(is,小数据池,编码转换)
  • 原文地址:https://www.cnblogs.com/MonkeyF/p/3430342.html
Copyright © 2011-2022 走看看