分类归档:Linux

Apache header cookie设置

# a2enmod expires
# a2enmod deflate

# vi /etc/apache2/sites-available/example.com.conf
# gzip html, css and js
AddOutputFilterByType DEFLATE text/html text/css application/x-javascript application/javascript

#启用过期header功能
ExpiresActive On
#缺省过期时间为“访问后的1天”
ExpiresDefault "access plus 1 days"
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpg "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
ExpiresByType image/vnd.microsoft.icon "access plus 1 months"
ExpiresByType image/x-icon "access plus 1 months"
ExpiresByType image/ico "access plus 1 months"
ExpiresByType application/javascript "now plus 1 months"
ExpiresByType application/x-javascript "now plus 1 months"
ExpiresByType text/javascript "now plus 1 months"
ExpiresByType text/css "now plus 1 months"

Apache X-Frame-Options配置

X-Frame-Options HTTP 响应头是用来给浏览器指示允许一个页面可否在 <frame>, <iframe> 或者 <object>中展现的标记。网站可以使用此功能,来确保自己网站的内容没有被嵌到别人的网站中去,也从而避免了点击劫持 (clickjacking) 的攻击。

X-Frame-Options有三种可配置值
X-Frame-Options: DENY
X-Frame-Options: SAMEORIGIN
X-Frame-Options: ALLOW-FROM https://example.com/

DENY
表示该页面不允许在 frame 中展示,即便是在相同域名的页面中嵌套也不允许。
SAMEORIGIN
表示该页面可以在相同域名页面的 frame 中展示。
ALLOW-FROM uri
表示该页面可以在指定来源的 frame 中展示。
注: 在网页中设置meta标签是无用的!例如,<meta http-equiv="X-Frame-Options" content="deny"> 是没有效果的。不要使用这种方式。需要在下面的配置实例中配置HTTP Header的方式来进行配置,X-Frame-Options才会起作用。

# a2enmod headers

# vi /etc/apache2/sites-available/example.com.conf

Header always append X-Frame-Options SAMEORIGIN
Header set X-Frame-Options DENY
Header set X-Frame-Options "ALLOW-FROM https://example.com/"

# service apache2 restart

Hive常见操作命令

1. hive模糊搜索表
show tables like ‘*name*’;

2. 查看表结构信息
desc formatted tablename;
desc table_name;

3. 查看分区信息
show partitions tablename;

4. 根据分区查询数据
select table_coulm from tablename where partitionname = ‘2016-02-25’; 阅读全文…

ubuntu 16.04升级php7.0至7.2

直接命令升级
1. apt-get update && apt-get upgrade
2. apt-get install software-properties-common
3. add-apt-repository ppa:ondrej/php
4. apt-get update
5. apt-get upgrade php

升级后安装对应的扩展
apt-get install php7.2-mbstring
apt-get install php7.2-gd
apt-get install php7.2-mysql
apt-get install php7.2-curl

查看已安装的php包

dpkg -l | grep php

删除旧版本

sudo apt-get purge php7.0 php7.0-common

# 查看php版本

php -v

Ubuntu 常用查找文件与文件内容指令

查找文件

locate

作用相当于find -name,但是locate速度会比find快很多,因为locate命令也是用数据库查找的。

因为该数据库默认是一天更新一次的,所有使用locate命令有可能找不到最近新建的文件。这时就需要手动更新数据库,命令很简单,直接在终端中输入sudo updatedb就可以进行更新,更新速度还是比较快的,所以在搜索文件的时候建议使用locate命令。

示例:

locate main.c

find

阅读全文…

在Linux服务器(ubuntu)上使用Apache为odoo openerp配置域名

Odoo is very well known ERP system today. Odoo 9 provides great features that will help to grow business. By default odoo runs over port 8069. So we are accessing server using domain:8069. What if we need to access server using only domain like a standard website? We can do it by configuring web server with odoo. Here I am going to show you configuration of Apache web server for odoo.

阅读全文…

How to Install a LAMP Stack on Ubuntu 16.04

A LAMP (Linux, Apache, MySQL, PHP) stack is a common, free and open-source web stack used for hosting web content in a Linux environment. Many consider it the platform of choice on which to develop and deploy high-performance web apps.

This guide shows how to install and test a LAMP stack on Ubuntu 16.04 (LTS). 阅读全文…