Hiển thị các bài đăng có nhãn Install Software on Linux. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Install Software on Linux. Hiển thị tất cả bài đăng

19/2/13

Hướng dẫn cài đặt Smarty trên hệ điều hành Linux


    Cài đặt SMARTY LIBRARY


Copy các file thư viện Smarty vào
/usr/local/lib/php/Smarty/

$> cd YOUR_DOWNLOAD_DIRECTORY
$> gtar -zxvf Smarty-2.6.7.tar.gz
$> mkdir /usr/local/lib/php/Smarty
$> cp -r Smarty-2.6.7/libs/* /usr/local/lib/php/Smarty

Ta có các file và cấu trúc thư mục như sau:

/usr/local/lib/php/Smarty/
Config_File.class.php
debug.tpl
internals/
plugins/
Smarty.class.php
Smarty_Compiler.class.php

Cài đặt SMARTY DIRECTORIES


You will need four directories setup for Smarty to work. These files are for
templates, compiled templates, cached templates and config files. You may or
may not use caching or config files, but it is a good idea to set them up
anyways. It is also recommended to place them outside of the web server
document root. The web server PHP user will need write access to the cache and
compile directories as well.

In our example, the document root is /web/www.domain.com/docs and the
web server username is "nobody". We will keep our Smarty files under
/web/www.domain.com/smarty

$> cd /web/www.domain.com
$> mkdir smarty
$> mkdir smarty/templates
$> mkdir smarty/templates_c
$> mkdir smarty/cache
$> mkdir smarty/configs
$> chown nobody:nobody smarty/templates_c
$> chown nobody:nobody smarty/cache
$> chmod 775 smarty/templates_c
$> chmod 775 smarty/cache

SETUP SMARTY PHP SCRIPTS

Now we setup our application in the document root:

$> cd /web/www.domain.com/docs
$> mkdir myapp
$> cd myapp
$> vi index.php

Edit the index.php file to look like the following:

<?php

// put full path to Smarty.class.php
require('/usr/local/lib/php/Smarty/Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = '/web/www.domain.com/smarty/templates';
$smarty->compile_dir = '/web/www.domain.com/smarty/templates_c';
$smarty->cache_dir = '/web/www.domain.com/smarty/cache';
$smarty->config_dir = '/web/www.domain.com/smarty/configs';

$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');

?>

SETUP SMARTY TEMPLATE

$> vi /web/www.domain.com/smarty/templates/index.tpl

Edit the index.tpl file with the following:

<html>
<head>
<title>Smarty</title>
</head>
<body>
Hello, {$name}!
</body>
</html>

Now go to your new application through the web browser,
http://www.domain.com/myapp/index.php in our example. You should see the text
"Hello Ned!" in your browser.

Once you get this far, you can continue on to the Smarty Crash Course to learn
a few more simple things, or on to the documentation to learn it all.
Nguồn sưu tầm  

12/2/13

Tạo và chạy ứng dụng Android đầu tiên với Eclipse


Tạo và chạy ứng dụng Android đầu tiên với Eclipse

Ở bài số 1 chúng ta đã học cách cài đặt và cấu hình môi trường lập trình Android trên IDE Eclipse. Các bạn có thể tham khảo bài trước ở đây
Bước 1: Chọn New Android App Project , xuất hiện hộp thoại sau:
Build SDK: mặc định là bản latest SDK bạn đã cái trên máy
MinimumRequired SDK: bản thấp nhất của Android hỗ trợ cho app của bạn

Bước 2: Tạo icon cho ứng dụng
Tham khảo http://developer.android.com/design/style/iconography.html
Bước 3: Chọn template cho project, với VD này là Blank Activity
Bước 4: Chọn next ở màn hình tiếp theo, nếu gặp màn hình này chọn Install/Upgrade
Chọn “Accept” và “Install”
Sau khi upgrade xong , ấn “Finish” và khởi động lại Eclipse
Một vài chú ý trước khi chạy project:
AndroidManifest.xml mô tả những đặc tính cơ bản và xác định các thành phần của ứng dụng. Bạn sẽ được học rõ hơn trong những bài tiếp theo.
Src: folder chính để lưu giữ các fie mã nguồn. Mặc định nó bao gồm lớp Activity sẽ được gọi khi khởi chạy ứng dụng
Res: chứa những thư mục con để lưu trữ hình ảnh âm thanh của ứng dụng
drawable-hdpi/
Thư mục cho các đối tượng drawable( chẳng hạn như ảnh bitmap) được thiết kế mật độ cao (hdpi). Các thư mục drawable khác chứa tài sản được thiết kế cho các mật độ màn hình khác.
layout/
Thư mục định nghĩa giao diện người dùng cho ứng dụng của bạn
values/
Thư mục cho các tập tin XML để định nghĩa màu sắc và chuỗi ký tự.
Trước khi chạy chúng ta phải thiết lập máy ảo như sau:
Chọn biểu tượng ở thanh toolbar, hộp thoại hiện lên chọn New, sau đó nhập một vài thông số:
Name: Tùy ý
Targert:  Chọn phiên bản hệ điều hành bạn muốn
SD Card: gõ size của SD Card ( mình để là 256 MiB)
Skin: Có thể để default (HVGA) hoặc chọn kích cỡ bạn muốn
Sau khi khởi tạo máy ảo chọn máy ảo và nhấn nút Start ở thanh công cụ bên phải. Giao diện sau khi chạy thành công

Quay lại với project MyFirstApp đã tạo ở bước trên, chọn và click Run từ thanh toolbar
Một số chức năng quan trọng cần biết khi lập trình Android
Android có một hệ thống debug hoàn hảo được hỗ trợ bởi logcat. Logcat sẽ thông báo toàn bộ về hệ điều hành, giúp chúng ta biết được  hệ điều hành đang làm gì, gọi đến cái gì, khởi chạy những gì, chiếm dụng bộ nhớ ra sao … (các bạn sẽ được nói rõ hơn trong những bài sau)

File Explorer của Android là tính năng hữu ích của Google đưa vào giúp chúng ta quản lý file trong sd card  và cả file system data. File Explorer giúp bạn dễ dàng đưa file vào/ lấy file ra trong sdcard ảo của simulator, xóa cơ sở dữ liệu để khởi tạo lại (only emulator)
Mở File Explorer bằng cách: Window->ShowView->Other->Android->File Explorer

8/1/12

CÀI ĐẶT VÀ CẤU HÌNH VMWARE PLAYER


1.1.         CÀI ĐẶT VÀ CẤU HÌNH VMWARE PLAYER

a)   Tải phần mềm  VMware-Player-3.1.4-385536.x86_64.bundle  từ website của  Vmware (http://www.vmware.com/products/player/)
b)  Cài đặt VMWare Player
[root@linux ~]#chmod 700 VMware-Player-3.1.4-385536.x86_64.bundle

[root@linux ~]#./VMware-Player-3.1.4-385536.x86_64.bundle

Extracting VMware Installer...done.
Would you like to check for product updates on startup? [yes]:  
# Enter
Would you like to help make VMware software better by sending
anonymous system data and usage statistics to VMware? [yes]:  
# Enter
The product is ready to be installed. Press Enter to begin
installation or Ctrl-C to cancel.  
# Enter
Installing VMware Player Application 3.1.4
    Configuring...
[##################################################################] 100%
Installation was successful.
c)   Từ giao diện đồ họa vào 'System tools'à 'VMware Player'


d)  Click 'Create a New Virtual machine'.


e)   Đặt đĩa cài đặt vào ổ đĩa và nhấn next


f)    Nhập vào thông tin của Windows.


g)   Nhập tên và vị trí lưu Virtual Machine.


h)  Chọn size ổ đĩa


i)    Click 'Cistomize Hardware'


j)    Thay đổi thông tin Virtual Machine nếu cần thiết


k)   Click 'Finish'


l)    Khởi động Virtual Machine và tiến hành cài đặt

JAVA APPLICATION SERVER - TOMCAT 7

1.1.1.     JAVA APPLICATION SERVER - TOMCAT 7

a)    Cài đặt và cấu hình Tomcat 7
[root@linux ~]#wget http://ftp.riken.jp/net/apache/tomcat/tomcat-7/v7.0.23/bin/apache-tomcat-7.0.23.tar.gz

[root@linux ~]#tar zxvf apache-tomcat-7.0.16.tar.gz

[root@linux ~]#mv apache-tomcat-7.0.16 /usr/tomcat7

[root@linux ~]#useradd -d /usr/tomcat7 tomcat

useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
[root@linux ~]#chown -R tomcat. /usr/tomcat7
b)   Tạo script  INIT
[root@linux ~]# vi /etc/rc.d/init.d/tomcat7
#!/bin/bash

# Tomcat7: Start/Stop Tomcat 7
#
# chkconfig: - 90 10
# description: Tomcat is a Java application Server.

. /etc/init.d/functions
. /etc/sysconfig/network

CATALINA_HOME=/usr/tomcat7
TOMCAT_USER=tomcat
LOCKFILE=/var/lock/subsys/tomcat

RETVAL=0
start(){
   echo "Starting Tomcat7: "
   su - $TOMCAT_USER -c "$CATALINA_HOME/bin/startup.sh"
   RETVAL=$?
   echo
   [ $RETVAL -eq 0 ] && touch $LOCKFILE
   return $RETVAL
}

stop(){
   echo "Shutting down Tomcat7: "
   $CATALINA_HOME/bin/shutdown.sh
   RETVAL=$?
   echo
   [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
   return $RETVAL
}

case "$1" in
   start)
      start
      ;;
   stop)
      stop
      ;;
   restart)
      stop
      start
      ;;
   status)
      status tomcat
      ;;
   *)
      echo $"Usage: $0 {start|stop|restart|status}"
      exit 1
      ;;
esac
exit $?

[root@linux ~]#chmod 755 /etc/rc.d/init.d/tomcat7

[root@linux ~]#/etc/rc.d/init.d/tomcat7 start

Starting Tomcat7:
Using CATALINA_BASE:          /usr/tomcat7

Using CATALINA_HOME:          /usr/tomcat7

Using CATALINA_TMPDIR:        /usr/tomcat7/temp

Using JRE_HOME:               /usr/java/default

Using CLASSPATH:  /usr/tomcat7/bin/bootstrap.jar:/usr/tomcat7/bin/tomcat-juli.jar
[root@linux ~]#chkconfig --add tomcat7

[root@linux ~]#chkconfig tomcat7 on



c)   Truy cập vào trình duyệt web theo địa chỉ Access to "http://(your hostname or IP address):8080/,  trong ví dụ này là  http://serverlinux.vn:8080/
d)   Cấu hình truy cập với port khác port 8080 trong URL.

[root@linux ~]#vi /etc/httpd/conf.d/proxy_ajp.conf
# add at the last line
ProxyPass /tomcat/ ajp://localhost:8009/
#Khởi động lại dịch vụ web
[root@linux ~]#/etc/rc.d/init.d/httpd restart

Stopping httpd:                     [  OK  ]
Starting httpd:                     [  OK  ]
e)   Truy cập vào trình duyệt theo địa chỉ http://(your hostname or IP address)/tomcat/" với port mới 8009 như ở bước c
f)    Tạo bài test servlet hiển thị giờ và ngày hiện tại của hệ thống

[root@linux ~]#mkdir /usr/tomcat7/webapps/ROOT/WEB-INF/classes

[root@linux ~]#chown tomcat. /usr/tomcat7/webapps/ROOT/WEB-INF/classes

[root@linux ~]#cd /usr/tomcat7/webapps/ROOT/WEB-INF/classes

[root@linux classes]#vi daytime.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Calendar;

public class daytime extends HttpServlet {
   public void doGet(HttpServletRequest request
      ,HttpServletResponse response)

   throws IOException, ServletException{
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      Calendar cal = Calendar.getInstance();
      out.println("<html>");
      out.println("<head>");
      out.println("<title>DayTime</title>");
      out.println("</head>");
      out.println("<body>");
      out.println("<div style=\"font-size: 40px; text-align: center; font-weight: bold\">");
      out.println(cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" +
      cal.get(Calendar.DATE) + " " + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE));
      out.println("</div>");
      out.println("</body>");
      out.println("</html>");
   }
}

[root@linux classes]#javac -classpath /usr/tomcat7/lib/servlet-api.jar daytime.java

[root@linux classes]#vi /usr/tomcat7/webapps/ROOT/WEB-INF/web.xml
# add follows between <web-app> - </web-app>

<servlet>
   <servlet-name>daytime</servlet-name>
   <servlet-class>daytime</servlet-class>
</servlet>
<servlet-mapping>
   <servlet-name>daytime</servlet-name>
   <url-pattern>/daytime</url-pattern>
</servlet-mapping>

g)   Truy cập vào trình duyệt theo địa chỉ http://(your hostname or IP address)/tomcat/daytime

CÀI ĐẶT JAVA DEVELOPMENT ENVIRONMENT


1.1.1.     CÀI ĐẶT JAVA DEVELOPMENT ENVIRONMENT


 Cài đặt Java SE Development Kit (JDK)

a)    Tải jdk-7-linux-x64.rpm  từ địa chỉ http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.rpm hoặc và địa chỉ của Oracle (http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html)  
b)   Cài đặt JDK

[root@linux ~]#rpm -Uvh jdk-7-linux-x64.rpm
Preparing...      ########################################### [100%]
   1:jdk          ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...

[root@linux ~]#vi /etc/profile
# add at the last line
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
[root@linux ~]#source /etc/profile

c)   Test thử bằng cách tạo chương trình sau

[root@linux ~]#vi day.java
import java.util.Calendar;
class day {
   public static void main(String[] args) {
      Calendar cal = Calendar.getInstance();
      int year = cal.get(Calendar.YEAR);
      int month = cal.get(Calendar.MONTH) + 1;
      int day = cal.get(Calendar.DATE);
      int hour = cal.get(Calendar.HOUR_OF_DAY);
      int minute = cal.get(Calendar.MINUTE);
      System.out.println(year + "/" + month + "/" + day + " " + hour + ":" + minute);
   }
}
[root@linux ~]#javac day.java             # compile
[root@linux ~]#java day                   # execute
2011/7/30 21:7

TRIỂN KHAI THIẾT LẬP CSDL SỬ DỤNG ORACLE


1.1.1.     TRIỂN KHAI THIẾT LẬP CSDL SỬ DỤNG ORACLE

Tạo cơ sở dữ liệu.

a)   Login vào user trong Oracle và nhập vào lệnh "dbca", nhấn "Next" để tiếp tục


b)  Chọn "Create Database" và nhấn next


c)   Chọn "General Purpose ***" và tiếp tục


d)  Nhập tên Grobal Database và SID như bên dưới.


e)   Giữ giá trị mặc định và tiếp tục


f)    Nhập passwords. Nên nhập mật khẩu có tính bảo mật cao


g)   Giữ giá trị mặc định là "File System".


h)  Configure recovery settings. If you'd like to change it, Set it.


i)    Configure sample schema and scripts. If you'd like to add them, Set them.


j)    Configure memory setting. After setting, go to next tab.


k)  Specify max processes.


l)    Set Character setting.


m)Select connection mode. If your server does not have many clients, Select Dedicated server mode. If your server has many clients, Select Shared server mode.


n)  Confirm parameters for Storage settings. If you'd like to change, set them.


o)  Configuration completed. Click "Finish" button to finish.


p)  Confirm settings and Click "OK" if all are OK.


q)  Database creation starts.


r)    Sau khi cơ sở dữ liệu tạo xong nhân "Exit" để hoàn thành.


s)   Access to a URL that is shown on finished screen above with web browser, then follwing screen is shown. Input a user name and password that you configured on the section

Create a init Script make Oracle start automatically on system booting.

t)     Change like folows first.
[root@db01 ~]#vi /etc/oratab
db01:/usr/oracle/app/product/11.2.0/dbhome_1:Y# change
[root@db01 ~]#vi /usr/oracle/.bash_profile
# add your SID at the last line
export ORACLE_SID=db01
u)   Create a init Script

[root@db01 ~]#vi /etc/rc.d/init.d/oracle
# this is an example
#!/bin/bash
# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
# processname: oracle
. /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/usr/oracle/app/product/11.2.0/dbhome_1
ORACLE_USER=oracle
case "$1" in
'start')
   if [ -f $LOCKFILE ]; then
      echo $0 already running.
      exit 1
   fi
   echo -n $"Starting Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
   touch $LOCKFILE
   ;;
'stop')
   if [ ! -f $LOCKFILE ]; then
      echo $0 already stopping.
      exit 1
   fi
   echo -n $"Stopping Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
   rm -f $LOCKFILE
   ;;
'restart')
   $0 stop
   $0 start
   ;;
'status')
   if [ -f $LOCKFILE ]; then
      echo $0 started.
      else
      echo $0 stopped.
   fi
   ;;
*)
   echo "Usage: $0 [start|stop|status]"
   exit 1
esac
exit 0

[root@db01 ~]#chmod 755 /etc/rc.d/init.d/oracle
[root@db01 ~]#/etc/rc.d/init.d/oracle start
Starting Oracle Database:
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-JUL-2011 23:41:57
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Starting /usr/oracle/app/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /usr/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /usr/oracle/app/diag/tnslsnr/db01/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db01.serverlinux)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db01.serverlinux)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                12-JUL-2011 23:41:57
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /usr/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /usr/oracle/app/diag/tnslsnr/db01/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db01.serverlinux)(PORT=1521)))
The listener supports no services
The command completed successfully
Processing Database instance "db01": log file /usr/oracle/app/product/11.2.0/dbhome_1/startup.log
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.
https://db01.serverlinux:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ........ started.
-----------------------------------------------------------
Logs are generated in directory /usr/oracle/app/product/11.2.0/dbhome_1/db01.serverlinux_db01/sysman/log

[root@db01 ~]#chkconfig --add oracle
[root@db01 ~]#chkconfig oracle on

Bài đăng phổ biến