美文网首页
ubuntu系统nginx简单安装配置

ubuntu系统nginx简单安装配置

作者: Mr_Laoyu | 来源:发表于2016-11-04 17:24 被阅读0次

    1.安装

    sudo apt-get install nginx
    

    2.配置php模块

    sudo vim /etc/nginx/sites-enabled/default
    
    #默认侦听端口
    listen 80;
    #指定服务器目录
    root /home/laoyu/www; 
    # Add index.php to the list if you are using PHP
    index index.html index.htm index.php;
    #服务名称
    server_name localhost;
    #去掉用到的配置前的‘#’
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
        #
        #   # With php5-cgi alone:
        #   fastcgi_pass 127.0.0.1:9000;
        #   # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
    }
    

    3.运行在nginx服务器上的php文件mkdir创建文件失败

    原因:服务器用户组没有写入权限
    解决:改变服务器根目录的读写操作权限

    4.nginx执行长时间脚本,服务器504错误

    解决办法:

    //1.打开php配置项
    vim /etc/php5/fpm/php.ini
    //设置
    max_execution_time = 300
    
    //2.打开 PHP-FPM配置项
    vim /etc/php5/fpm/pool.d/www.conf
    //设置
    request_terminate_timeout = 300
    
    //3.打开nginx.conf
    vim /etc/nginx/nginx.conf
    //增加一个配置项
    http {  
      #... 
      fastcgi_read_timeout 300; 
      #...
    }
    
    //4.重启服务器
    sudo sevice nginx restart
    

    相关文章

      网友评论

          本文标题:ubuntu系统nginx简单安装配置

          本文链接:https://www.haomeiwen.com/subject/silwuttx.html