Wednesday, December 10, 2014

Cài đặt openERP8 Trên CentOS7(how to install OpenERP8 on CentOS 7)

1 .  cấu hình SELinux, thay đổi như bên dưới.
vi /etc/sysconfig/selinux

    2  . ở đây mình tắt firewall. Trên centos7 iptables đã được thay thế bằng firewall.
chkconfig firewalld off
 systemctl stop firewalld
    3. Thường thì MariaDB được cài dặt sẳn trong bản full, nên chúng ta phải remove nó ra. Nếu chúng ta sử dụng bản  simple thì có thể bỏ qua bước này
  # yum remove mariadb mariadb-server
     yum clean all
     yum update
4. Thiết lập một số thư viện cần thiết cho  openERRP.  
  yum install babel python-devel libxslt-python pyparsing python-dateutil python-decorator python-imaging python-jinja2 python-ldap python-lxml python-mako python-psycopg2 python-reportlab python-requests python-werkzeug python-yaml python-docutils  python-matplotlib python-babel python-gevent pygtk2 glade3 pytz libxslt-devel bzr automake gcc gcc-c++ byacc
   5. Tiến hành cài dặt web apache

   yum -y install httpd
xem fle câu hình
    vi /etc/httpd/conf/httpd.conf
     systemctl start httpd
     chkconfig httpd on
    systemctl restart httpd
 6.  cài dặt database cho operrp
  yum install -y postgresql-setup initdb
   yum install postgresql-libs postgresql-server postgresql php-pgsql php-gd
   postgresql-setup initdb
   systemctl enable postgresql.service
    systemctl start postgresql.service
 Tạo user opener như bên dưới.
   su - postgres
   adduser openerp
    passwd opener
tạo user mới cho database.
    su - postgres -c "createuser --pwprompt --createdb --no-createrole --no-superuser openerp"
ý nghĩa của các tham số trên:
·         --createdb : the new user will be able to create new databases
·         --username postgres : createuser will use the postgres user (superuser)
·         --no-createrole : the new user will not be able to create new users
·         --pwprompt : createuser will ask you the new user's password
·         openerp : the new user's name


7.cài đặt python + openerp8    
yum -y install python.
yum install epel-release
yum-config-manager --add-repo=
https://nightly.odoo.com/8.0/nightly/rpm/odoo.repo

yum update
 yum install odoo
 systemctl start odoo
cấu hình file opener.
    vi /etc/odoo/openerp-server.conf

    Phân quyền và tạo file ghi log.
   mkdir -p /var/log/openerp/
   touch /var/log/openerp/openerp-server.log
  chown openerp /var/log/openerp/openerp-server.log
   chmod 644 /var/log/openerp/openerp-server.log
  vi /var/lib/pgsql/data/pg_hba.conf
    su - postgres
    systemctl restart postgresql.service
8.tạo file  khởi động openerp khi mở OS.
     vi /usr/lib/systemd/system/openerp.service
[Unit]
Description=Advanced OpenSource ERP and CRM server
Requires=postgresql.service
After=postgresql.service
[Install]
Alias=openerp.service
[Service]
Type=simple
PermissionsStartOnly=true
EnvironmentFile=-/etc/conf.d/openerp-server
User=openerp
Group=openerp
SyslogIdentifier=openerp-server
PIDFile=/run/openerp/openerp-server.pid
ExecStartPre=/usr/bin/install -d -m755 -o openerp -g openerp /run/openerp
ExecStart=/usr/local/bin/openerp-server -c /etc/openerp-server.conf --pid=/run/openerp/openerp-server.pid --syslog $OPENERP_ARGS
ExecStop=/bin/kill $MAINPID
[Install]
WantedBy=multi-user.target

     systemctl enable openerp.service
     systemctl enable openerp
     chown openerp -R /usr/lib/python2.7/site-packages/openerp/
 9. Đăng nhập:


tạo database và đăng nhập với user admin (mặc định).
hưởng thành quả.
note: bài viết có thamk khảo tài liệu từ doc.odoo.com và rosehosting.com

Tuesday, September 30, 2014

Cài worldclient chạy cùng ISS 7.5

Nguồn: http://vn.tips4admin.com/
Yêu cầu:
  • Đã cài đặt MDaemon Email Server
  • Đã cài đặt Internet Information Services (IIS)
Tiến hành:
Vào IIS, tạo một Application Pool mới bằng cách nhấn vào Add Application Pool…như hình bên dưới
Cửa sổ Add Application Pool hiện ra. Trong Name nhập tên tùy ý (vd: MDeamon). Trong .NET Framework version chọn No Managed Code
MDaemon_WorldClient_on_IIS_7_2
Tiếp theo, chọn Application MDeamon vừa ta ra, bên cột phải ta chọn Advanced Settings
MDaemon_WorldClient_on_IIS_7_3
Nếu hệ thống Windows bạn đang chạy là 64-bit, hãy thiết đặt giá trị True cho mục Enable 32-Bit Applications.
Mục Identity chỉ định User để chạy Application Pool này. Mặc định giá trị của Identity là ApplicationPoolIdentity. Bạn có thể chỉ định 1 User mà bạn tạo ra (vd: Administrator).
MDaemon_WorldClient_on_IIS_7_4

Sau khi tạo Application Pool xong, chúng ta sẽ tạo ra một Website mới. Click phải chuột lên Site và chọn Add Web Site….
MDaemon_WorldClient_on_IIS_7_5
Cửa sổ Add Web Site hiện ra. Trong Site name bạn nhập 1 tên tùy ý (vd: MDaemon). Trong Application pool, nhấn Select…và chọn Application pool mà ta vừa tạo ở trên. Trong Physical path nhập vào đường dẫn chứa WorldClient (ở đây là C:\MDaemon\WorldClient\HTML). Trong Host name nhập vào địa chỉ web mail của bạn.
MDaemon_WorldClient_on_IIS_7_6
Tiếp tục, vào Handler Mappings
MDaemon_WorldClient_on_IIS_7_7
Bên cột phải, nhấn chọn Add Module Mapping…
MDaemon_WorldClient_on_IIS_7_8
Cửa sổ Add Module Mapping hiện ra, nhập vào các giá trị. Trong Request path nhập worldclient.dll. TrongModule chọn IsapiModule. Trong Executable (optional) chọn đường dẫn tới file WorldClient.dll (vd: C:\MDaemon\WorldClient\HTML\WorldClient.dll). Trong Name nhập tùy ý (vd: worldclient).
MDaemon_WorldClient_on_IIS_7_9
Cửa sổ Confirm hiện ra. Nhấn Yes
MDaemon_WorldClient_on_IIS_7_10
Tiếp tục, ta cần chỉnh lại tài khoản Anonymous sử dụng website này. Vào Authentication
MDaemon_WorldClient_on_IIS_7_11
Chọn tài khoản Anonymous Authentication. Ở cột bên phải, nhấn Edit
MDaemon_WorldClient_on_IIS_7_12
Chuyển qua chế độ Application pool identity
MDaemon_WorldClient_on_IIS_7_13
Mặc định, IIS sẽ thiết lập Default page là các trang có đuôi mở rộng là .html hay .aspx. Ta cần chuyển qua fileworldclient.dll trong trường hợp này. Vào Default Document như hình bên dưới.
 MDaemon_WorldClient_on_IIS_7_14
Bên cột phải, nhấn Add…
MDaemon_WorldClient_on_IIS_7_15
Cửa sổ Add Default Document hiện ra, trong Name ta nhập vào worldclient.dll rồi nhấn OK
MDaemon_WorldClient_on_IIS_7_16
Bước cấu hình ở IIS như vậy là xong. Bây giờ ta trở lại với MDaemon để cấu hình. Vào menu Setup, chọn Web, Sync, & IM Services…
MDaemon_WorldClient_on_IIS_7_17
Trong WorldClient (web mail) chọn WorldClient run using external webserver (IIS, Apache, etc) rồi nhấn OK
MDaemon_WorldClient_on_IIS_7_18
Quá trình cấu hình như vậy là xong. Bây giờ mở trình duyệt lên để kiểm tra. Ta vào địa chỉ web mail như đã đặt làhttp://mail.vn.tips4admin.com. Nếu quá trình cài đặt và cấu hình thành công thì sẽ có kết quả tương tự như hình dưới đây.
MDaemon_WorldClient_on_IIS_7_19
Đăng nhập với tài khỏan quản trị vào được hòm mail với giao diện như dưới đây Smile
MDaemon_WorldClient_on_IIS_7_20
Quá trình cài đặt và cấu hình WorldClient chạy trên IIS như vậy là thành công!

Giới Thiệu các Web server phổ biến hiện nay

Nguồn http://anninhmang.net/
Một số máy chủ Web (web server) trên thị trường hiện nay
web server 300x198 Bạn chọn  Web server nào trên thị trường hiện nay?
1. Lighttpd
Thông tin sơ lược: Webserver này tương đối nhẹ và chiếm ít tài nguyên của hệ thống. Hoạt động tốt khi thực thi web tĩnh và web động. Được cộng đồng PHP công nhận và sử dụng
  • Chi phí: miễn phí
  • Mã nguồn mở: Có
  • Nền tảng hệ điều hành: Linux, FreeBSD, Solaris, MacOS X, Windows
  • Trang chủ: www.lighttpd.net
2. Nginx
  • Thông tin sơ lược: Nginx là một WebServer tương đối nhẹ và không chiếm nhiều tài nguyên của hệ thống. Nginx được biết đến với sự ổn định và cấu hình đơn giản. Nó cũng có thể hoạt động như một proxy IMAP/POP3.
  • Chi phí: miễn phí
  • Mã nguồn mở: Có
  • Nền tảng hệ điều hành: Linux, FreeBSD, Solaris, MacOS X
  • Trang chủ: www.nginx.net
3. LiteSpeed
  • Giới thiệu sơ lược: LiteSpeed là một WebServer thương mại dùng trong các hệ thống Website lớn. Một trong những lợi thế của LiteSpeed là nó có thể đọc cấu hình Apache trực tiếp và dể dàng tích hợp các sàn phẩm để thay thế Apache. LiteSpeed hoạt động nhẹ nhàng và không tiếu tốn nhiều tài nguyên của hệ thống
  • Chi phí: $ 1.299 phụ thuộc vào các ấn bản (Có bản miễn phí hỗ trợ 1 domain)
  • Mã nguồn mở: Không có
  • Nền tảng hệ điều hành: Linux, FreeBSD, Solaris, MacOS X
  • Trang chủ: www.litespeedtech.com
4. Zeus
  • Giới thiệu sơ lược: Zeus là WebServer có hiệu suất cao. Nó đã nhận được nhiều giải thưởng lớn . Zeus là một sản phẩm doanh nghiệp rất linh hoạt.
  • Chi phí: $ 1.700 Cho 2 CPU vật lý; $ 850 cho mỗi CPU bổ sung.
  • Mã nguồn mở: Không có
  • Nền tảng hệ điều hành: Linux, FreeBSD, Solaris, HP-UX
  • Trang chủ: www.zeus.com/products/zws
II. Một vài so sánh
so sanh webserver 300x251 Bạn chọn  Web server nào trên thị trường hiện nay?
Apache vs Nginx:
  • Apache + mod_php thì xử lý php script nhanh hơn Nginx + PHP-FPM
  • Nhưng nếu xét về static page thì Nginx handler nhanh hơn PHP.
Nginx vs Litespeed vs Apache
  • Nginx có chức năng giới hạn và quản lý tốc độ gửi http request rất linh động, sau bao nhiêu request thì limit.
  • Litespeed thì không được như vậy (hoặc phải kết hợp với giải pháp khác), Litespeed chỉ có limit cố định (không có burst),
  • Apache thì linh động hơn Nginx với mod_reqtimeout hoặc mod_qos.
- Tuy nhiên trong các hệ thống high load người ta chuộng Nginx hơn.
- Mô hình được khá nhiều người sử dụng hiện nay: Apache làm Webserver, Nginx làm reverse proxy.
  • static có thể được phục vụ trực tiếp từ nginx, chỉ forward dynamic đến apache -> giảm tải.
  • Thêm vào đó reverse proxy có thể gửi đến nhiều backend server -> load balancing (clustering)
- Nhược điểm:
  • Tuy nhiên khi Nginx đứng trước chịu trách nhiệm front end cho các apache request phía sau mình nghĩ cũng vẫn có mặt hạn chế nếu như các statics cache file làm việc không tốt.
  • Ngoài ra có 1 điểm bất lợi khác mà nginx mắc phải, đó là các file configuration không có dynamically , tất cả các cấu hình ngnix nó store trong file config đó. Vậy nên việc thay đổi có tính áp dụng ngay tức thì sẽ không thể. Điều này cũng hạn chế ít nhiều đến việc apply hay change trong thời điểm run time. Đặc biệt là các hệ thống yêu cầu có tính ổn định 24/7
- Ngoài các giải pháp trên bạn cũng nên tối ưu lại CSS,JS cũng như cache để tăng performence cho web server của bạn
Khả Năng Triển Khai và thực tiễn:
Bản Quyền Windows Server rất đắt so với Linux Miễn Phí.
Windows Server yêu cầu cấu hình máy chủ cao hơn so với Linux.
Giao diện GUI của Windows Server thân thiện và dễ sử dụng hơn Linux(KDE + GNOME).
Windows Server và Linux đều có 2 kiểu hệ điều hành Command-Line.
Windows Server hỗ trợ đầy đủ nhất các ngôn ngữ kịch bản.
So sánh về khả năng chịu tải:
Apache thua xa IIS do Apache thường xuyên bị nghẽn cổ chai,
So sánh về độ ổn định:
IIS có cơ chế lưu trữ web trong môi trường Share Hosting với từng Pool riêng biệt. Ví dụ như 1 site trong Server Share Hosting bị ddos thì sẽ không ảnh hưởng đến site khác. Apache cũng sẽ làm được điều này nếu như chạy trên hệ điều hảnh Linux trả phí mới nhất là CloudLinux với LVE Manager.
So sánh về tốc độ(chưa cài Module Cache):
IIS xử lý PHP nhanh hơn hẳn so với Apache.Bên mình vẫn đang test và sẽ đưa ra con số cụ thể chính thức.
So sánh về Bảo Mật:
Apache có vô vàn số lỗi mà bạn có thể bị tấn công local khi sử dụng Share Hosting.IIS tỏ ra đáng tin cậy hơn và việc tấn công local bằng Shell PHP là điều gần như không thể.
Mod Rewrite
Apache hỗ trợ .htaccess tốt hơn nhiều so với Module hỗ trợ .htaccess của Windows là ISAPI. Nhưng trên windows thì cũng được hỗ trợ thêm mod Rewrite riêng biệt sử dụng loại file web.config,bạn sẽ gặp file này khi download các loại mã nguồn như vBulletin có đính kèm sẵn trong bộ code đó.

Tuesday, September 23, 2014

Cài đặt Nginx & PHP-FPM trong Centos7

Cài đặt Nginx  và php-fpm trongCentos7.
1.1. cài đặt Nginx.
Cài đặt với lệnh:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
 có nhiều cách cài đặt khác bạn có thể download trực tiếp trên trang Nginx về sau đó tiến hành cài đặt bằng lệnh rpm.
sudo yum install nginx

ở đây lệnh sudo chỉ đảm bảo bạn đang thực hiện với quyền root, nếu bạn chay với quyền root thì có thể bỏ qua lệnh sudo.
Thế là đã cài xong nginx với các   thong số cơ bản giờ start dịch vụ và nó khỏi đọng cùng hệ điều hành nữa là ok.
sudo systemctl start nginx.service
#systemctl enable nginx.service

Giở chung ta truy câm xem demo


Nếu bạn muốn chỉnh sữa thong số trang default thì theo đường dẫn sau:
#vi /usr/share/nginx/html/index.html
Chỉnh sữa thong số cấu hình ta chỉnh file sau
etc/nginx/conf.d/default.conf
kiểm tra version nginx đã cài đặt
#nginx -v 

nginx version: nginx/1.6.2

xem log nginx tại đường dẫn

#cat /var/log/nginx/
ở đây có 2 file: error.log và access.log khỏi cần giới thiệu nhiều về 2 file này nữa

2.1.  cài dặt cấu hình php-fpm
php-fpm là gì:
PHP-FPM (FastCGI Process Manager) :
Một sự thay thế PHP FastCGI để thực hiện một số tính năng bổ sung hữu ích cho các trang web có kích thước bất kỳ, đặc biệt là các trang có lượng truy cập lớn.
Nó có các tính năng như sau:
-       Đáp ứng tốt tiến trình phát sinh.
-       Thống kê cơ bản (giống mod_status apache).
-       Quản lý tốt các tiến trình khởi động và kết thúc.
-       Khả năng start các worker với các UID/GID?CHROOT trong các môi trường khác nhau và file php.ini khác nhau( thay thế cho file safe_mod).
-       Ghi các sự kiện và lỗi.
-       Khỏi động lại khi bộ nhớ cache bị phá hủy.
-       Hỗ trợ tang tốc tải lên.
-       Hỗ trợ slowlog
-       Cải tiến FastCGI.
-        Và nhiều thứ khác …………. Tham khảo them tại trang chủ của nó http://php-fpm.org.
Cài đặt PHP
#yum -y install php php-string php-pear
#yum -y install php-fpm php-mysql
#vi /etc/php.ini
 Tìm tới dòng :
cgi.fix_pathinfo=0
chỉnh sửa 1 thành 0 ý nghĩa thong số này khi chúng ta để 1 thinhg php sẽ sử dụng tất cả tài nguyên dễ sử lý 1 file vấn đề này không tốt cho bảo mật , với  thông số 0 thì ngược lại
tiếp theo chúng ta cấu hình Nginx.
vi /etc/nginx/nginx.conf
chúng ta cần cấu hình woker process, Tùy theo core  CPU mà các bạn chỉnh cho hợp lý, với CPU thời đại giờ chắc chúng ta nên đưa về 4 hoặc 8 *_* bác nào có CPU cao hơn cứ mạnh dạng đẩy
 mặc định nó là 1( theo máy ảo cảu mình *_*).
worker_processes  1;
tiếp theo chỉnh sữa file cấu hình
vi /etc/nginx/conf.d/default.conf
thay đổi giống như dưới
#
# The default server
#
server {
    listen       80;
    server_name example.com;
 
   
    location / {
        root   /usr/share/nginx/html;
        index index.php  index.html index.htm;
    }
 
    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }
 
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
 
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
Uncomment các dòng từ 30 tới 36
Sửa lại thư mục root là /usr/share/nginx/html
thay đổi thong số fastcgi_param  thành $document_root$fastcgi_script_name;
bây giờ tạo 1 file test info.php như sau
vi /usr/share/nginx/html/info.php
với nội dung như sau.
<?php
phpinfo();
?>
Cuối cùng khởi động dịch vụ
#systemctl start php-fpm
 #systemctl enable php-fpm
#systemctl  restart nginx
truy cập kiểm tra kết quả.

Tuesday, July 1, 2014

Squid Proxy Splash Page( default trang web cho wifi)

Squid Proxy Splash Page

0 votes, 0.00 avg. rating (0% score)
Hi All! So after my last article regarding securing a guest network web access with Squid and SquidGuard, I wanted to share how I came about creating a Splash Page for Guest users of my Free WiFi hotspot. My goal was to present new Guests with a splash page identifying certain Terms of Usage, etc. Basically we will need a HTML or PHP Splash Page, an ACL identifying the Guests by IP, an external ACL program (squid_session), and a Deny with Information (deny_info).

Some prelimary info:
  • Squid 3.1.19
  • Ubuntu 12.04.2 64-bit Server Edition
  • Apache2 w/PHP5 Installed
  • Guest’s Subnet 192.168.1.0/24
  1. Confirm you have the External ACL Helper Installed

    Search for a program called squid_session, mine was located in /usr/lib/squid3/squid_session. If you do not have this installed, you will need to uninstall squid, and reinstall it from source with squid_session. (outside the scope of this post.)
  2. Create Session Database file

    NOTICE: You have to give whatever user runs the squid process access to this file.
  3. Configure Squid

    Add the following to the conf file:
    • external_acl_type — denotes that an external ACL helper will be used to determine validity
    • acl guest_sessions external sessions — creates a new ACL called guest_sessions that will use the external ACL from above
    • deny_info – location of page to be presented when user is denied. %s is a dynamic variable that contains the original URL the user tried to go to.
    • http_access deny – in this statement we deny every client in the gNetwork range of 192.168.1.0/24 unless, they are part of the guest_sessions ACL.
  4. Create Splash Page

    A splash page should contain any content that you want to present to your users. In my case I create one with basic Terms of Usage, such as no illegal activity, or downloading of large files, etc. Now remember our last deny_info statment? the splash.php?url=%s This is important as this is how we will remember what URL our user tried to go to before forcing them to the splash page.
    HTML/PHP:
    ?
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    <html>
    ...omitted HTML head and title...
    <body>
     
    ...omitted Content...
     
    <!--Accept Form -->
    <h4>By clicking accept you accept the terms of usage explained below of WiFi Usage:</h4>
    <?php
    echo '<form action="' . htmlspecialchars($_GET["url"])  . '" target="_blank">
    <input type="submit" value="Accept">
    </form>'
    ?>
     
    <body>
    </html>
    NOTICE: I use PHP here to capture the url=value and place it in the HTML form. When a user clicks the form the action is the URL they originally tried to visit, so they will be navigated there.
  5. Restart squid3

    Restart squid3 to ensure that the child process squid_session starts..
    Verify squid_session process:

Other Thoughts

The above example is not entirely secure in presenting the page properly to each user at a set interval. See the squid3 documentation below in the source section. For example, if a user on the gNetwork tries to navigate to a web site, they are presented with the Splash page, once the Splash page has been sent to them they are now stored in the squid_session helper, before they click accept. The concern here is liability, if you are setting this up for a massive Free WiFi network and have legitimate legal concerns, etc. You should look into the active squid_session method. From my understanding, this method allows you to set more than just a client’s IP as a valid check, you could have them enter their email address or something else identifiable. I was unable to figure out how to incorporate Squid Sessions with Active Method, but if someone has please comment! I would like to see what you did to make it work.
Sources: