阿里云 debian 下 apt-get 搭建 nginx+php环境

1. 更新apt-get源

apt-get update

2. 安装Nginx

apt-get install nginx

nginx相关操作

service nginx start
service nginx restart
service nginx stop

3. 安装php

apt-get install php5-fpm php5-gd php5-mysql php5-memcache php5-curl

4. 配置Nginx让其支持php

cd /etc/nginx/conf.d #进入nginx虚拟站点配置目录
vi xxx.com.conf #创建域名配置文件

然后把下面的代码拷贝进去

server {
    listen 80;
    server_name phpmyadmin.xxx.com;
    root /home/wwwroot/phpMyadmin;
    index index.php;
    location / {
        try_files $uri $uri/ =404;
    }
    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;
    }
}

附上nginx方向代理到nodeJs的配置

server{
    listen 80;
    server_name open.xxx.com;
    access_log off;
    location / {
        #proxy_cache_key "$scheme://$host$request_uri";
        #proxy_cache cache_one;
        #proxy_cache_valid  200 304 3h;
        #proxy_cache_valid 301 3d;
        #proxy_cache_valid any 10s;
        proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        #proxy_set_header   Referer http://xxxx;
        proxy_set_header   Host $host;
        #proxy_hide_header Set-Cookie;
        proxy_pass http://xx.xx.xx.xx:8080;
    }
}
标签:DebianPHPNginx 发布于:2019-11-05 11:08:49