Ubuntu 14.04 kernel version: 3.13.0-67-generic

安装

apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y
aptitude update -y && aptitude upgrade -y && aptitude dist-upgrade -y
apt-get install mysql-server mysql-client


mysql_secure_installation
mysql -u root -p
apt-get install -y git php5-fpm php5-cli php5-common php5-curl php5-gd php5-json php5-mysql php5-php5-xmlrpc php5-imagick php5-mcrypt
apt-get autoremove -y
reboot
vim /etc/php5/fpm/php.ini
cgi.fix_pathinfo=0
php5enmod mcrypt
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer config -g repositories.packagist composer http://packagist.phpcomposer.com
mkdir /var/www
mkdir /var/www/ssl
openssl dhparam -out dhparam.pem 2048
chmod -R 600 /var/www/ssl
composer create-project laravel/laravel laravel
chown -R :nginx /var/www/laravel
chmod -R 775 /var/www/laravel/storage

vim /etc/php5/fpm/pool.d/www.conf

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

/etc/nginx/nginx.conf 示例

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    use epoll;
    worker_connections 51200;
    multi_accept on;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile         on;
    tcp_nopush       on;
    tcp_nodelay      on;

    keepalive_timeout  60;

    gzip             on;
    gzip_vary        on;
    gzip_comp_level  6;
    gzip_buffers     16 8k;
    gzip_min_length  1000;
    gzip_proxied     any;
    gzip_disable     "msie6";
    gzip_types
        text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
        text/javascript application/javascript application/x-javascript
        text/x-json application/json application/x-web-app-manifest+json
        text/css text/plain text/x-component
        font/opentype application/x-font-ttf application/vnd.ms-fontobject
        image/x-icon;

    include /etc/nginx/conf.d/*.conf;
}

/etc/nginx/conf.d/laravel.conf 示例

server {
    listen       80;
    server_name  lab.solarhell.com;
    return 301   https://lab.solarhell.com$request_uri;
}

server {
    listen       443 ssl http2 fastopen=3 reuseport;
    server_name  lab.solarhell.com;
    root         /var/www/laravel/public;
    index        index.php index.html;

    ssl_certificate     /var/www/ssl/ssl.crt;
    ssl_certificate_key /var/www/ssl/ssl.key;
    ssl_dhparam         /var/www/ssl/dhparam.pem;

    ssl_protocols TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK';
    ssl_prefer_server_ciphers on;

    ssl_stapling on;
    ssl_stapling_verify on;
    resolver             8.8.4.4 8.8.8.8  valid=300s;
    resolver_timeout     10s;

    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_buffer_size 8k;
    ssl_session_tickets  on;

    add_header Strict-Transport-Security "max-age=15768000";
    add_header X-Frame-Options  deny;
    add_header X-Content-Type-Options  nosniff;

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
}

标签: none

添加新评论