Linux/lnmp安裝/lnmp Redis/SSL配置/LNMP刪除.user.ini


幾個Linux命令
php

reboot   #哈哈
rm -rf #刪除文件夾
chmod -R 755 路徑  #給權限
unlink  #刪除文件

nginx重啓:css

service nginx restart
#or
/a/apps/nginx/sbin/nginx -s reload   #換成你本身的路徑,有云鎖的卸載了


LNMP安裝:html

yum install screen
wget -c https://dn-wsy.qbox.me/lnmp1.2-full.tar.gz && tar zxf lnmp1.2-full.tar.gz && cd lnmp1.2-full && ./install.sh lnmp

鏡像:mysql

下載版:http://soft.vpser.net/lnmp/lnmp1.2.tar.gz  (115KB)
MD5:75429551c2614e298e6df5ccda0d3968
完整版:http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz  (303MB)
MD5:9fda60bd8d699ec53c16545af6c16360
國內下載地址:
https://api.sinas3.com/v1/SAE_lnmp/soft/lnmp1.2-full.tar.gz 下載時wget須要加–no-check-certificate參數
http://7xjkan.com1.z0.glb.clouddn.com/lnmp1.2-full.tar.gz
LNMP狀態管理命令:
LNMP 1.2狀態管理: lnmp {start|stop|reload|restart|kill|status}
LNMP 1.2各個程序狀態管理: lnmp {nginx|mysql|mariadb|php-fpm|pureftpd} {start|stop|reload|restart|kill|status}
LNMP 1.1狀態管理: /root/lnmp {start|stop|reload|restart|kill|status}
Nginx狀態管理:/etc/init.d/nginx {start|stop|reload|restart}
MySQL狀態管理:/etc/init.d/mysql {start|stop|restart|reload|force-reload|status}
Memcached狀態管理:/etc/init.d/memcached {start|stop|restart}
PHP-FPM狀態管理:/etc/init.d/php-fpm {start|stop|quit|restart|reload|logrotate}
PureFTPd狀態管理: /etc/init.d/pureftpd {start|stop|restart|kill|status}
ProFTPd狀態管理: /etc/init.d/proftpd {start|stop|restart|reload}
如重啓LNMP,輸入命令:/root/lnmp restart 便可,單獨重啓mysql:/etc/init.d/mysql restart


zip -q -r bak.zip /home/wwwroot/dir  #打包壓縮

重置MySQL密碼nginx

wget http://soft.vpser.net/lnmp/ext/reset_mysql_root_password.sh;sh reset_mysql_root_password.sh


Redis安裝:

在lnmp安裝目錄下[root@iZ28vomvjlnZ lnmp1.2-full]#  ./addons.sh redisredis


選擇5:Redis  ,版本的話因爲我須要用到阿里雲的KV-STORE這裏選擇2:2.89了sql


命令行操做redis:shell

lnmp redis安裝在:/usr/local/redis/binvim

因此:api

[root@iZ28fcou6hqZ /]# cd /usr/local/redis/bin
[root@iZ28fcou6hqZ bin]# ./redis-cli


列出全部KEY:

keys *

清空key

flushdb

LNMP刪除.user.ini

LNMP 1.1及以前的版本使用php.ini裏面,open_basedir設置

LNMP 1.2及更高版本防跨目錄功能使用.user.ini,該文件在網站根目錄下,能夠修改open_basedir的值來設置限制目錄的訪問。
.user.ini文件沒法直接修改,並且是隱藏文件可能在winscp下可能沒法看到,建議使用vim編輯器nano編輯器進行修改。
如要修或刪除須要先執行:chattr -i /網站目錄/.user.ini
修改完成後再執行:chattr +i /網站目錄/.user.ini


SSL配置

這裏用到的是沃通wosign的免費數字證書

申請地址:https://buy.wosign.com/

第一步:將下載的證書文件for Nginx.zip中的

1_ssl.domain.com_bundle.crt  和  2_ssl.domain.com.key 上傳到root目錄下,並將其更名爲  ssl.crt和ssl.key


第二步:

openssl rsa -in ssl.key -out /root/ssl.key
chmod 600 /root/ssl.key

第三步:修改vhost配置

server {
    listen       80;
    server_name t5.domain.com;
    rewrite ^/(.*) https://t5.domain.com/$1 permanent;
}
server
    {
        listen 80;
        listen 443 ssl;
        #listen [::]:80;
        ssl on;
        ssl_certificate /root/ssl.crt;
        ssl_certificate_key /root/ssl.key;
        server_name t5.zy62.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/t5.domain.com;
 
        include none.conf;
        #error_page   404   /404.html;
        location ~ [^/]\.php(/|$)
        {
            # comment try_files $uri =404; to enable pathinfo
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            #include pathinfo.conf;
        }
 
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }
 
        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }
 
        access_log  /home/wwwlogs/ssl.domain.com.log  access;
    }

最後 lnmp restart 重啓就行了

CSR在線生成:

https://www.chinassl.net/ssltools/generator-csr.html

LNMP/nginx Comodo Positive SSL證書配置


t5_domain_com.crt
COMODORSADomainValidationSecureServerCA.crt
COMODORSAAddTrustCA.crt
AddTrustExternalCARoot.crt

按前後順序合併到一個文件,

t5_domain_com.crt

上傳t5_domain_com.key, nginx配置:

server {
    listen       80;
    server_name t5.domain.com;
    rewrite ^/(.*) https://t5.domain.com/$1 permanent;
    }
server
    {
        listen 443 ssl;
        #listen [::]:80;
        ssl on;
        ssl_certificate /root/t5_domain_com.crt;
        ssl_certificate_key /root/t5_domain_com.key;
        ssl_session_timeout 5m;   
        ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
        ssl_prefer_server_ciphers on;
        server_name t5.domain.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/t5.domain.com;

        include other.conf;
        #error_page   404   /404.html;
        location / {
index index.php;
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
        location ~ [^/]\.php(/|$)
        {
            # comment try_files $uri =404; to enable pathinfo
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            #include pathinfo.conf;
        }

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

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

        access_log  /home/wwwlogs/t5.domain.com.log  access;
    }

最後重啓nginx,有圖有真相:


更新系統時間:

ntpdate time-a.nist.gov
相關文章
相關標籤/搜索