Nginx默认配置文件

Nginx的默认配置文件,default:
(空主机头访问返回500。)

server {
    listen       80 default;
    server_name  _;
    return 500;
}

SSL站点和WordPress配置

还是Nginx的配置,SSL站点的配置文件,如果是Typecho博客程序,例如ssl.com.conf:

  • 证书目录规划在:/etc/nginx/ssl;放一个key,放一个crt。
  • 建立例如:/var/www/ssl.com;文件全部丢上去后。
  • 修正用户和用户组:chown -R www-data.www-data /var/www
  • chown -R www-data.www-data /etc/nginx/ssl
server {
    listen    80;
    server_name    ssl.com *.ssl.com;
    return    301 https://$server_name$request_uri;
}

server {
    listen    443;
    server_name ssl.com *.ssl.com;
    index index.php index.html;
    root /var/www/ssl.com;
    charset utf8;

    ssl on;
    ssl_certificate /etc/nginx/ssl/ssl.com.crt;
    ssl_certificate_key /etc/nginx/ssl/ssl.com.key;

    if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php$1 last;
    }

    location / {
        gzip    on;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires    30d;
        gzip    on;
    }

    location ~ .*\.(js|css)?$ {
        expires    1h;
    }

    location ~ .*\.php(\/.*)*$ {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index    index.php;
        include        /etc/nginx/fastcgi_params;
    }
}

Typecho博客配置

还是Nginx的配置,WordPress站点的配置,例如:www.wp.com:

  • 站点根目录放在:/var/www/www.wp.com
  • 修正用户和用户组:chown -R www-data.www-data /var/www
server {
    listen    80;
    server_name    wp.com;
    return    301 http://www.wp.com$request_uri;
}

server {
    listen    80;
    server_name www.wp.com wp.com;
    index index.php index.html;
    root /var/www/www.wp.com;
    charset utf8;

    location / {
        gzip    on;
    try_files $uri $uri/ /index.php?$args;
    }

    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires    24h;
        gzip    on;
    }

    location ~ .*\.(js|css)?$ {
        expires    1h;
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index    index.php;
        include        /etc/nginx/fastcgi_params;
    }
}

数据库创建一个拥有全部权限的用户

MySQL新建一个拥有全部权限的用户。

数据库导入导出都用phpMyAdmin,要不然会出现各样的问题,例如表被锁定不能导入之类。
mysql -u root -p
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin-password';
GRANT ALL ON *.* TO 'admin'@'localhost';
quit;

phpMyAdmin配置文件

phpMyAdmin软件包放在:/var/www/phpMyAdmin。
注意弄个短语密码。 \

libraries/config.default.php > $cfg['blowfish_secret'] = ''; \
config.sample.inc.php > $cfg['blowfish_secret'] = ''; \
S21fGlR

修正用户和用户组:chown -R www-data.www-data /var/www

server {
    listen    10932;
    server_name mysqladmin.domain.com;
    index index.php index.html;
    root /var/www/phpMyAdmin;
    charset utf8;

    location ~ [^/]\.php(/|$) {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index    index.php;
        include        /etc/nginx/fastcgi_params;
    }
}

备份

  • 网站文件:/var/www
  • SSL证书:/etc/nginx/ssl
  • Nginx 配置文件:/etc/nginx/sites-e*

额外

nginx -t
nginx -s reload

文件管理可以用sftp,或者eXtplorer之类的PHP在线文件管理工具;
phpMyAdmin设置为其他端口,或者必要的话在/etc/nginx/sites-enabled目录下删除配置文件,用到的时候再增加。

一个Dockerfile:

FROM stenote/docker-lemp

RUN sed -i 's/archive.ubuntu/cn.archive.ubuntu/g' /etc/apt/sources.list && \
    apt-get update && \
    apt-get install curl wget unzip nano -y && \
    rm -rf /var/lib/apt/lists/*

RUN sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 100M/" /etc/php5/fpm/php.ini && \
    sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 100M/" /etc/php5/cli/php.ini && \
    sed -i "s/post_max_size = 8M/post_max_size = 100M/" /etc/php5/fpm/php.ini && \
    sed -i "s/post_max_size = 8M/post_max_size = 100M/" /etc/php5/cli/php.ini && \
    sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 100M/" /etc/php5/cli/php.ini

EXPOSE 80 443 3388 3389

ENTRYPOINT ["/entrypoint.sh"]