MySQL Replication

文章發佈於 : 2004-09-13 00:26:19 | 文章分類 : 裝機紀錄
標籤 :

-以下這份文件是針對兩台MySQL伺服器進行One-way Replication
-Starting in Version 3.23.15, MySQL supports one-way replication internally.
-參考文件
1. http://www.mysql.com/doc/en/Replication.html

-測試環境
RedHat 7.3 + MySQL 3.23.49
MySQL資料庫路徑: /var/lib/mysql
MySQL設定檔: /etc/my.cnf
Master IP: 192.168.1.1
Slave IP: 192.168.1.2
-設定步驟Master/Slave
-設定Master
1.確認Master/Slave機器上所裝的MySQL版本能進行replication.Use Version 3.23.29 or higher.
2.在Master MySQL上開放一個帳號給Slave
#mysql –u root –p
mysql>GRANT FILE ON *.* TO repl@192.168.1.2 IDENTIFIED BY ‘abc123’;
mysql>q
#
上面是Master開放一個帳號repl密碼abc123給IP:192.168.1.2有檔案處理的權限.
3.shutdown MySQL on the Master
#mysqladmin –u root –p shutdown
4.備份Master所有資料庫..通常都用tar指令.
#tar –cvf /tmp/mysql-snapshot.tar /var/lib/mysql
注意:tar的時候,MySQL是要在stop情況下
不過在mysql網站的FAQ有不用shutdown的方法
5.在master機器上修改/etc/my.cnf
在[mysqld]區段內加入參數
log-bin
server-id=這邊設定server-id=1
sql-bin-update-same
binlog-do-db=phpBB只針對phpBB資料庫做紀錄
6.Restart MySQL on the master
此時因為有加入log-bin參數,因此開始有index產生了,在/var/lib/mysql目錄下有.index檔案紀錄資料庫的異動log.

-接下來設定Slave
7.在slave設定/etc/my.cnf
在[mysqld]區段加入
master-host=
master-user=
master-password=
master-port=
server-id=
這邊設定
master-host=192.168.1.1
master-user=repl
master-password=abc123
master-port=3306
server-id=2
master-connect-retry=60預設重試間隔60秒
replicate-do-db=phpBB告訴slave只做phpBB資料庫的更新
log-slave-updates
8.將master上的mysql-snapshot.tar copy到slave上
用ftp傳到slave的/tmp
9.解壓縮
#cd /var/lib/
#tar xvf /tmp/mysql-snapshot.tar
#chown –R mysql:mysql mysql
#chmod –R 770 mysql(視情況)
10.Restart MySQL on the slave server
這時在/var/lib/mysql目錄會出現master.info,此檔案紀錄了Master MySQL server的資訊.

-狀況測試
1.Master跟Slave網路及服務都正常情況下,由Master端異動資料後,
到Slave端瀏覽資料,檢視是否有進行replication?!
2.模擬Slave掛點,可用在於slave真的掛點,或是slave不一定需要一直跟master connect.
將Slave MySQL server shutdown,由Master端異動資料,到slave端瀏覽,
此時Slave應該沒有被replication更新,然後再將Slave端MySQL server start起來,
預設60秒後Slave會嘗試跟Master要求進行replication.再去Slave端檢視是否有更新資料?!
3.模擬Master掛點.那沒搞頭了,因為是設定One-way replication.一旦Master掛點,
Slave端沒有Master的source可以download,所以沒搞頭了.
4.基於第3點狀況於是發展雙向Replication,即A/B都分別擔任Master/Slave身分

-以下是針對兩台MySQL伺服器進行雙向Replication
觀念同單向replication只是改成Master也有Slave身分, Slave也有Master的身分.
先分別在A/B都去grant一個進行replication的身分
[A]mysql>GRANT FILE ON *.* TO repl@192.168.1.2 IDENTIFIED BY ‘abc123’;
[B]mysql> GRANT FILE ON *.* TO repl@192.168.1.1 IDENTIFIED BY ‘abc123’;

做完單向replication後,stop A/B MySQL service,此時A/B資料是一樣的.

修改/etc/my.cnf設定
範例:
Server A
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
server-id=1
log-bin
sql-bin-update-same
binlog-do-db=phpBB

master-host=192.168.1.2
master-user=repl
master-password=abc123
log-slave-updates
master-connect-retry=60
replicate-do-db=phpBB
Server B
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
server-id=2
log-bin
sql-bin-update-same
binlog-do-db=phpBB

master-host=192.168.1.1
master-user=repl
master-password=abc123
log-slave-updates
master-connect-retry=60
replicate-do-db=phpBB

分別start A/B MySQL後,此時雙方都是Master/Slave身分,
一但哪一方資料異動就會通知對方來replication.
-若replication失效,我的做法是將A/B的master.info及.index,.00x都砍掉,
然後分別restart MySQL server,進行測試.檢視成果.

-再來由雙向replication延伸出replication chain/(circular),即A->B->C->…(->A)
觀念chain是單向replication的延伸, circular是chain的尾巴接回頭.
舉例A-B-C-A
A為B的master,B是C的master,而C是A的master.
反過來說
B是A的slave,C是B的slave,而A是C的slave.
只要將/etc/my.cnf檔案[mysqld]區段都加入master/slave對應的參數
宣告為master是
server-id=x其中x為主機id=1,2,3
log-bin
sql-bin-update-same
binlog-do-db=phpBB

定義slave是
master-host=192.168.1.x其中x為主機ip=1,2,3
master-user=repl
master-password=abc123
log-slave-updates
master-connect-retry=60
replicate-do-db=phpBB

-測試
1.各server(A/B/C)都運作正常下,任一台異動資料,就會通知slave進行replication
2.模擬其中一台掛點.如B,則A異動時,因為B掛點,故此chain已經斷了,所以C並不會被更新.
所以這種chain的方式缺點在於說其中一個環節點失效時,其後的都不會更新了,
但可由手動方式change master將下個節點change master from掛點的 to 上一個ok的節點.
優點是有很多台server都有replication備份.


-------------
作者﹕myz
最後更新日期﹕
2002/09/06

 Love is waiting so you don't have to. Join Date.com for free!
 Join Asia FriendFinder the Largest Asian Dating Site on the Web for FREE!
 Kaspersky Security for Internet Gateway 7.0
 Know when to sell on eBay using research

閱讀全文 | 回 應(0) |

 Secure MySQL Database Design

文章發佈於 : 2004-09-13 00:23:58 | 文章分類 : 裝機紀錄
標籤 :

When it comes to installing software, secure design is often the last consideration.
The first goal is usually just to get it to work. This is particularly true of databases.
Databases are commonly referred to the keys to the kingdom:
meaning that once they are compromised,
all the valuable data that is stored there could fall into the hands of the attacker.
With this in mind, this article will discuss various methods to secure databases,
specifically one of the most popular freeware databases in use today, MySQL.


Introduction to MySQL

MySQL can be found at http://www.mysql.com or at http://sourceforge.net/projects/mysql/.
MySQL is used in over 4 million installations all over the world. It is licensed under both GNU GPL (General Public License) and commercial licenses, depending upon what level of support that you require. It has a large user community, which makes it somewhat easier to use under the GPL license. There are actually four versions of MySQL:

MySQL Standard includes the standard storage TYPE, as well as the InnoDB storage TYPE,
which is touted as a “transaction-safe, ACID-compliant database” with some additional features over the standard version.
MySQL Pro is the commercial version.
MySQL Max includes the more technologically advanced features that are available during early access programs.
MySQL Classic is the standard storage TYPE without the InnoDB TYPE. This is another commercial version.
Most of the recommendations discussed in this article apply to all versions of MySQL unless otherwise noted.

Introducing Security Into MySQL Design

As with securing a network, securing a database by looking at the various layers that are involved is an effective approach. Security of databases can be defined as preventing unauthorized or accidental disclosure, alteration, or destruction of data [2]. In addition, the confidentiality of data that exists in the database must be considered, as should the availability of that data. The following section will discuss a secure database design; while not all-inclusive, it should provide a good, basic starting point.

Three-Tier Design

Also referred to as n-tier design, this design incorporates the three layers of a Web application running on different servers, usually set apart by firewalls that have specific rules to only let traffic through to the specific port on a specific server at whichever layer that the user is trying to access:

Internet -> Firewall -> Web -> Firewall -> Application -> Firewall -> Database

Something else that it should demonstrate is that it is very costly to implement such a design because firewalls and servers are not cheap. Oftentimes, a sys admin will choose a compromise, combining the application and database servers. This isn’t ideal from a security perspective; nevertheless, it is a vast improvement over leaving a sensitive database facing the Internet directly. The point is that if one of the layers closest to the Internet is compromised, then several more layers still need to be compromised before access to the vital information can be gained.

Access Control

Access to information contained in the tables must be properly regulated. This can be done with control over direct access to the tables, and also through views. Views and privileges assigned to the views can be created to limit users to only see specified portions of data contained within a table [2]. Through the use of the selects, projections and joins, existing relations between tables in a relational database, as well as a single table, can be created. Control over the read, insert, update and delete commands must also be assigned appropriately within those views.

Roles

Role-based authentication should be considered when adding access to any database. Typical roles for access include administrator, user, programmer and operator. For the first three roles, it is fairly obvious what access should be granted; it is the operator role that can be a sticking point. Operators are expected to play an essential part in the production operation of a system, yet they are often restricted in what type of access they are granted. Segregation of duties should be considered in the operator role, instead of just granting one operator control over an entire process. Operators’ roles do need to be carefully defined and kept within the realm of production support as much as possible. Furthermore, all roles should have logging enabled to keep track of what occurs [3].

Integrity

Another key ingredient in database design is data integrity, or ensuring that the data that is stored in the database is in fact valid and accurate. It is best to determine very early in the design process that it will be responsible for ensuring the integrity of the database. No matter the sensitivity of the data (credit card information vs. your record collection), if the data isn’t right, then what good is the database? When the owner is determined, they should maintain this role and appropriate access only, not attempting to dole this out to others less it become diluted and possibly become corrupt.

A good process for ensuring the integrity of the data includes understanding what is processed and then identifying what can be considered personal, critical, or proprietary. As with any security issue, risk must be assigned according to the likelihood that something could occur to that data and the potential effect of such an occurence. Most of all, accountability must be assigned and designed into the environment where the database resides. Otherwise, the goals of privacy and security cannot be met [3].

Encryption

The sensitivity of the data will logically determine the need for the use of encryption. There are a few things to consider when thinking about implementing encryption:

Will the data stored in the database need to be encrypted or just the user passwords?
Will you need to encrypt the data only in the local instance of the database, or do you need to also encrypt the data in transit?
Change Control

It is important to remember that changes made to the database, whether structural or to the data itself, must be tracked and regulated by interested parties. Whether formal or informal, the process must be defined and followed by all roles defined in the database structure.

Specific MySQL Security Considerations

Now that we have covered some of the general principals of database security, we can examine some specific considerations for the MySQL database. Please note that many variables that are mentioned in the following discussion are set in the “my.cnf” file. The location of this depends on how the MySQL database is installed. Essentially, you can create the file on your own, or use one of the handy sample files that come with the distribution (see the “support-files” directory). Then, if you would like the parameters to apply all MySQL users, you can place the “my.cnf” file in /etc. If you want the parameters to apply to specific users, then you can set the file in their respective home directory as “.my.cnf”. Make sure that the appropriate permissions are applied to the file wherever it resides, ensuring that the unauthorizedusers cannot write to it.

A discussion of the basic post-installation configuration of MySQL is beyond the scope of this discussion. For that information, please refer to the MySQL documentation, Post-Installation Set-up and Testing, and Setting Up the Initial MySQL Privileges, as well as Ryan W. Maple's article MySQL Security.

The MySQL Permission Model

In order to fully implement a secure MySQL database, it is necessary to learn the MySQL access control system (your friends the GRANT and REVOKE commands). There are four privilege levels that apply:

Global: these privileges apply to all databases on a server.
Database: these privileges apply to all tables in a database.
Table: these apply to all columns within a table.
Column: these apply to individual columns in a table.
The usage of these commands is varied:

GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
ON {tbl_name | * | *.* | db_name.*}
TO user_name [IDENTIFIED BY [PASSWORD] 'password']
[, user_name [IDENTIFIED BY 'password'] ...]
[REQUIRE
NONE |
[{SSL| X509}]
[CIPHER cipher [AND]]
[ISSUER issuer [AND]]
[SUBJECT subject]]
[WITH [GRANT OPTION | MAX_QUERIES_PER_HOUR # |
MAX_UPDATES_PER_HOUR # |
MAX_CONNECTIONS_PER_HOUR #]]

REVOKE priv_type [(column_list)] [, priv_type [(column_list)] ...]
ON {tbl_name | * | *.* | db_name.*}
FROM user_name [, user_name ...]

The privileges can get very granular, so it is important that they are used in a well planned fashion. The types of privileges include:

Alter
Delete
Create
Drop
Execute
Select
Update
Once a database is completely set up, these privileges should be reviewed prior to going to any usage of the database to ensure that the privileges were set up appropriately.

For instance, if you wanted to limit the alter privilege only to the user kristyw for table called CreditCards, you would use the command as follows:

Mysql> GRANT alter on CreditCards to kristyw
Mysql> IDENTIFIED by "password";

This could take some time if multiple privileges for the same user are to be added. In this case, wildcards can be used, but use caution in doing so! You never want to add more privilege than is necessary or intended. Further, if a user account is compromised, then the use of blanket permissions to numerous hosts can open up unexpected trust relationships between systems. Additionally, if the hostname is left blank for connections, which also effectively works as a wildcard [7].

For example, say the user kristyw should now have all the privileges to everything in the database, as well as be required to connect to the database via an SSL connection:

Mysql> GRANT all on *.* to kristyw
Mysql> IDENTIFIED by ‘password’ REQUIRE SSL;

The wildcards that apply with the GRANT and REVOKE permissions include the “*”, which when used with grant privileges to *.* indicates global permissions, the “_”’, which if not used with a “” in front of it (as in “_”) could unintentionally indicate access to other databases, and lastly, the “%” can be used in hostnames.

Another privilege that can be assigned controls via GRANT and REVOKE is the PROCESS privilege, which should be restricted to only appropriate users. When used in the format: “mysqladmin processlist”, disclosure of password information is possible. This is especially true if the user excecuted the query with the syntax of “UPDATE user SET password=PASSWORD(‘not_secure')” in their query. Furthermore, restrict the use of the FILE privilege. This privilege allows the assigned user to write a file wherever the mysqld daemon has privileges too. In addtion, the FILE privilege can be used to view any file within the UNIX filesystem that the user has privileges to [7].

More Advanced Tips…

If a database only needs to be accessed locally, TCP networking can be disabled. You can achieve this by editing the safe_mysqld script (located in /mysq_linstall_dir/bin). Search for “skip-locking”, and add the “skip-networking” flag to the beginning of the line that includes “–skip-locking”:

--skip-networking --skip-locking > > $err_log 2> &1

--skip-networking --skip-locking "$@" > > $err_log 2> &1

Now no one will be able to remotely connect to the database [4].

Start up MySQL with the parameter to disable the use of symlinks (via the –skip-symlink option). This will prevent the possibility of escalated privileges given to the owner of whoever started the mysqld process. Ultimately this could result in accidental or deliberate overwriting of files on your system, so it is best to just remove their usage.

To prevent a type of denial of service by one compromised or careless user account, you should restrict connections for a single user, by setting the max_user_connections variable in mysqld. These options can be viewed via the SHOW VARIABLES command, and can be updated via the SET command [7].

There are a few methods to encrypt stored data in a MySQL database: you can use the ENCRYPT or ENCODE commands. The difference between the two is that ENCRYPT uses the Unix crypt call, where as ENCODE uses a password provided in the command to encrypt the string. Both MD5 and SHA1 hash algorithms are available, as well as AES and DES. (Note: SHA1, DES and AES algorithms only available in version 4.0.2 and later).

By default, passwords are inserted into tables using encryption. Also by default, passwords in MySQL are unrelated to operating system passwords. There is no length limit on passwords in MySQL; they can be as short or as long as you want (however, the OS may restrict that length). User names can be up to sixteen characters, but can also be shorter. Therefore, any strict password parameters will have to be encouraged by setting policies and enforced by auditing. Overall, just make sure that all accounts do have passwords, just like you should on their operating system accounts.

All the Other Goodies

Another thing to keep in mind when securing your database is all of the other possible tools that are installed on your server. If you are on a tight budget, and have placed your Web server with the database (which is still not recommended), then tools like Apache, PHP or Java may be loaded on the same server. If these tools are not kept up-to-date (just as with the OS), then possible exploits may apply, and the server may be vulnerable to intrusion.

The same principle applies to the other utility packages that may be loaded on your server, such as: SSH, zlib, or wu-ftp. Always remember to apply security checklists to your servers, know what is running on them, and keep up with the latest vulnerabilities.

We have considered many things here to design into the database itself, but one item that needs to be considered is how the traffic is transmitted between the client and the server. If the data is sensitive and/or going over the Internet, then SSL should be employed. Version 4.0 of MySQL will satisfy this requirement. To have your version of MySQL use SSL, configure it with the following flags: --with-vio --with-openssl.

There are also ways to lock down the usage of SSL once you have it properly installed. If the REQUIRE SSL option is used, no non-SSL connections can be made to this server. Be cautious when employng the REQUIRE X509 option, though, because its usage alone does not mean that the certificate will be validated, only that the user must have one. Other REQUIRE options must be set to have proper validation (e.g. ISSUER, SUBJECT). Lastly, REQUIRE CIPHER is the parameter that requires that certain ciphers and keylengths be used [6].

For older versions of MySQL, an encrytped SSH tunnel is a viable option.

And All That Other Stuff…

Don’t forget the other layers of your servers!!! When I say this, I mean that the security of the operating system, the server authentication, and the server access control must all be taken care of as well, because if these are weak, then why even bother securing your database?

Database Backups

Another area that often gets lost in the layers of security is the critical area of database backup and recovery. As a part of whatever backup type is used, testing recovery of data is mandatory. Further, since version 3.23.47, checkpointing (where copies of the database are saved at defined times while processing) has been improved to be done more frequently, also easing the recovery process. With frequent checkpointing, as well as transaction logging (now available with InnoDB) and making regular backup copies, backup and recovery of databases is made more straightforward.

Specifically, the InnoDB transactional model allows for commit, rollback and crash recovery. By adding locking capabilities for users, having many users access the database at the same time becomes faster and more stable. To ensure that InnoDB is available with your installation, configure your package with the ‘—with-innodb’ flags. You will also want to specify InnoDB options in your ‘my.cnf’ file. Details on these set-up options can be found at the MySQL Documentation on InnoDB Start-up Options.

Add-Ons

As is the case with a lot of popular freeware tools, MySQL has spawned many other tools that can help improve the management of MySQL databases; thus, making the improving the security of the databases as well. If you are looking for a tool to help scan your network for blank MySQL passwords, try this MySQL Network Scanner script. It was originally compiled for Linux and to scan a class C network, but could be modified if needed.

There are several GUI consoles available to make the management of MySQL database easier. For instance, MySQL Explorer allows several management processes to be done via an interface that runs on several windows platforms. The MySQL team also has a version in beta called MySQLGUI, and the source code is available here. Just keep in mind when using these graphical tools and editors to help you manage a MySQL database that security needs to apply to them as well. This can be done through use of the ACLs to make sure that only certain servers can connect to your database on certain ports.

Conclusion

Many of the standard secure database design principles apply to MySQL. Of course, it has many of its own intricacies that need to be understood and audited carefully before any database is fully implemented. Lastly, it is important to keep in mind that other layers of security apply when hosting a database, such as network and operating system security. The good news is that the makers of MySQL have an excellent documentation area on their Web site that, although sometimes cumbersome to navigate, is well stocked with information for the MySQL developer and administrator.

References

[1] Database Management and Design, Gary W. Hansen and James V. Hansen, Prentice Hall, 1992

[2] A Primer on SQL, Roy Ageloff, Times Mirror/Mosby College Publishing, 1988

[3] Database: Structure Techniques for Design, Performance and Management, 2nd Edition, Shaku Atre, John Wiley and Sons, 1988

[4] mysql security, Ryan W. Maple, http://www.linuxsecurity.com/tips/tip-24.html

[5] General Security Guidelines, http://www.mysql.com/doc/en/General_security.html

[6] SSL Usage Requirements http://www.mysql.com/doc/en/Secure_requirements.html

[7] How to Make MySQL Secure Against Crackers http://www.mysql.com/doc/en/Security.html
 Love is waiting so you don't have to. Join Date.com for free!
 Join Asia FriendFinder the Largest Asian Dating Site on the Web for FREE!
 Kaspersky Security for Internet Gateway 7.0
 Know when to sell on eBay using research

閱讀全文 | 回 應(0) |

 Apache,PHP,MySQL,Java 完整安裝心得

文章發佈於 : 2004-09-13 00:21:51 | 文章分類 : 裝機紀錄
標籤 :

Java+PHP+MySQL+PostgreSQL+Apache 完整安裝心得
這篇文章我已經發表很久了,還曾經被收錄到Linuxfab的精華區中,
我查了紀錄,每個月大約都還有50人次在查閱這篇文章,所以就將這篇文章移轉過來


Source code 名稱 版本 下載位址
1. J2SDK
1.4.0 beta2 http://java.sun.com/j2se/1.4/
2. JSDK
2.0 http://java.sun.com/products/servlet/download.html
3. OpenSSL
0.9.6b http://www.openssl.org/source/
4. mm
1.1.3 http://www.engelschall.com/sw/mm/
5. mod_ssl
1.3.22 http://www.modssl.org/source/
6. mod_perl
1.26 http://perl.apache.org/dist/
7. Apche
1.3.22 http://www.apache.org/dist/
8. imap
2001a ftp://ftp.cac.washington.edu/imap/imap-2001a.RELEASE-CANDIDATE.2.tar.Z
9. MySQL
3.22.43 http://www.mysql.com/downloads/
10. PostgreSQL
7.1.3 ftp://ftp.postgresql.org/pub/
11. pdflib
4.0.1 http://www.pdflib.com/pdflib/download/index.html
12. freetype
2.0.5 http://prdownloads.sourceforge.net/freetype/
13. gd
2.0.1 http://www.boutell.com/gd/http/
14. curl
7.9 http://curl.haxx.se/download.html
15. zlib
1.1.3 http://www.gzip.org/zlib/
16. php
4.0.6 http://www.php.net/downloads.php
17. JAXP
1.0.1 http://java.sun.com/xml/archive.html
18. JSSE
1.0.2 http://java.sun.com/products/jsse/index-102.html
19. Tomcat
4.0 http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0/
20. Tomcat (src)
3.2.3(src) http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.3/src/
21. Tomcat (bin)
3.2.3(bin) http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.3/bin/


@@ 我把所有的source code 都放在 /usr/local/src 這個目錄下

@@ 我使用的 Linux 是 MDK8.1

@@ 安裝前請先更新 libc 到 5.0 的版本...不然在編mod_ssl時候會有問題

1. J2SDK 1.4.0 beta2 and JSDK2.0

 1-1 cp j2sdk-1_4_0-beta2-linux-i386.bin /usr/local/

 1-2 chmod 777 j2sdk-1_4_0-beta2-linux-i386.bin

 1-3 ./j2sdk-1_4_0-beta2-linux-i386.bin

 1-4 按空白鍵,最後輸入Yes

 1-5 mv j2sdk-1_4_0/ j2sdk/

 1-6 cp jsdk20-solaris2-sparc[1].tar.Z /usr/local

 1-7 tar -zxvf jsdk20-solaris2-sparc[1].tar.Z

 1-8 cd /root

 1-9 vi .bashrc

 1-10 加上這幾行

  1-10-1 JAVA_HOME=/usr/local/j2sdk

  1-10-2 PATH=$JAVA_HOME:$JAVA_HOME/bin

  1-10-3 CLASSPATH=/usr/local/j2sdk/lib/tools.jar:/usr/local/JSDK2.0/lib/jsdk.jar:$HOME/java-class

  1-10-4 export JAVA_HOME CLASSPATH

 1-11 rm -rf j2sdk-1_4_0-beta2-linux-i386.bin --> 如果你要節省空間才需要作

 1-12 rm -rf jsdk20-solaris2-sparc[1].tar.Z --> 如果你要節省空間才需要作

  ** 如果你想所有的使用者都可以使用java , 請繼續作下面部分 **

 1-13 cd /etc

 1-14 vi profile

 1-15 add follow lines

  1-15-1 JAVA_HOME=/usr/local/j2sdk

  1-15-2 PATH=$JAVA_HOME:$JAVA_HOME/bin

  1-15-3 CLASSPATH=/usr/local/j2sdk/lib/tools.jar:/usr/local/JSDK2.0/lib/jsdk.jar:$HOME/java-class

  1-15-4 export JAVA_HOME CLASSPATH

  ** ps. 我設定 $HOME/java-class 讓所有使用者的java class都必須放在java-class這個資料夾才可以使用

 1-16 test

  1-16-1 which javait 會顯示 /usr/local/j2sdk/bin/java

  1-16-2 Hello Java World

   1-16-2-1 用 vi 或其他你習慣的編輯器編輯下面這段測試用程式碼

     class HelloJavaWorld

     {

      public static void main(String[] args)

      {

       System.out.println("Hello Java World!");

      }

     }

   1-16-2-2 javac HelloJavaWorld系統會產生一個叫 HelloJavaWorld.class 的檔案

   1-16-2-3 java HelloJavaWorld當你看到 > Hello Java World! 就代表你之前的安裝都已經成功了


--------------------------------------------------------------------------------

2 OpenSSL

 2-1 tar -zxvf openssl-0.9.6b.tar.gz

 2-2 cd openssl-0.9.6b

 2-3 ./config --prefix=/usr/local/openssl

 2-4 make

 2-5 make test2-6 make install


--------------------------------------------------------------------------------

3 mm

 3-1 tar -zxvf mm-1.1.3.tar.gz

 3-2 cd mm-1.1.3

 3-3 ./configure --prefix=/usr/local/lib/mm

 3-4 make

 3-5 make test

 3-6 make install

 3-7 cd /etc

 3-8 vi ld.so.conf and add /usr/local/lib/mm/lib

 3-9 cd /sbin 3-10 ./ldconfing


--------------------------------------------------------------------------------

4 mod_ssl

 4-1 tar -zxvf apache_1.3.22.tar.gz

 4-2 tar -zxvf mod_ssl-2.8.5-1.3.22.tar.gz

 4-3 cd mod_ssl-2.8.5-1.3.22

 4-4 ./configure --with-apache=/usr/local/apache_1.3.22 --with-ssl=/usr/local/openssl --enable-shared=ssl --with-mm=/usr/local/lib/mm/lib


--------------------------------------------------------------------------------

5 mod_perl

 5-1 tar -zxvf mod_perl-1.26.tar.gz

 5-2 cd mod_perl-1.26

 5-3 perl Makefile.PL EVERYTHING=1 APACHE_SRC=../apache_1.3.22/src USE_APACI=1 PREP_HTTPD=1 DO_HTTPD=1

 5-4 make

 5-5 make install


--------------------------------------------------------------------------------

6 Apache

 6-1 cd apache-1.3.22

 6-2 EAPI_MM="/usr/local/lib/mm" SSL_BASE="/usr/local/openssl" ./configure --prefix=/usr/local/apache
   --enable-module=unique_id --enable-module=rewrite --enable-module=speling --enable-module=expires
   --enable-module=info --enable-module=log_agent --enable-module=log_referer --enable-module=usertrack
   --enable-module=proxy --enable-module=userdir --enable-module=so --enable-module=most --enable-shared=max
   --enable-shared=ssl --enable-module=ssl --activate-module=src/modules/perl/libperl.a --enable-module=perl

 6-3 make

 6-4 make certificate TYPE=dummy --> 測試用途

   make certificate TYPE=custom --> 正式用途,你必須回答許多問題

 6-5 make install

 6-6 /usr/local/apache/bin

 6-7 ./apachect1 startssl --> start with ssl./apachect1 start --> start without ssl

 6-8 開啟你的瀏覽器

 6-9 http://localhost/ --> 不論你使用 apachectl start 或 apachectl startssl 啟動 apache 都可以看到這個網頁

 6-10 https://localhost --> 只有使用 apachectl startssl 啟動 apache 才會看到這個頁面

 6-11 測試cgi

 6-12 cd ../

 6-13 chmod +x cgi-bin/*

 6-14 http://localhost/cgi-bin/testcgi

 6-15 http://localhost/cgi-bin/printenv


--------------------------------------------------------------------------------

7 imap c-client

 7-1 tar -zxvf imap-2001a.RELEASE-CANDIDATE.2.tar.Z

 7-2 mv imap-2001a.RELEASE-CANDIDATE.2 imap

 7-3 cd imap

 7-4 make slx


--------------------------------------------------------------------------------

8 MySQL

 8-1 tar -zxvf mysql-3.23.43.tar.gz

 8-2 cd mysql-3.23.43

 8-3 ./configure --prefix=/usr/local/mysql --with-charset=big5

 8-4 make

 8-5 make install

 8-6 cd /etc

 8-7 vi ld.so.conf 然後加上 /usr/local/mysql/lib/mysql

 8-8 cd /sbin

 8-9 ./ldconfig

 8-10 adduser mysql

 8-11 cd /etc

 8-12 vi passwd

 8-13 找出 /home/mysql 並且把他改成 /usr/local/mysql/lib/mysql

 8-14 cd /usr/local/

 8-15 chown -R mysql:mysql mysql/

 8-16 cd mysql/bin

 8-17 ./mysql_install_db

 8-18 cd ../share/mysql

 8-19 ./mysql.server start

 8-20 測試 --> ps -ax 你會看到下面的資訊
    2391 ? S 0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/
    2393 ? S 0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/
    2394 ? S 0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/



--------------------------------------------------------------------------------

9 PostgreSQL

 9-1 tar -zxvf postgresql-7.1.3.tar.gz

 9-2 cd postgresql-7.1.3

 9-3 ./configure --prefix=/usr/local/pgsql --with-perl --with-odbc --enable-multibyte=MULE_INTERNAL

 9-4 gmake

 9-5 gmake install

 9-6 adduser postgres

 9-7 cd /etc

 9-8 編輯 ld.so.conf 加入 /usr/local/pgsql/lib

 9-9 cd /sbin

 9-10 ./ldconfig

 9-11 cd /etc

 9-12 vi passwd

 9-13 找出 /var/lib/pgsql 改成 /usr/local/pgsql

 9-14 su - postgres

 9-15 /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

 9-16 /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &

 9-17 /usr/local/pgsql/bin/createdb test

 9-18 /usr/local/pgsql/bin/psql test

 9-19 測試 -->ps -ax你會看到下面的資訊
    2597 ? S 0:00 /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/d


--------------------------------------------------------------------------------

10 pdflib

 10-1 tar -zxvf pdflib-4.0.1.tar.gz

 10-2 cd pdflib-4.0.1

 10-3 ./configure --prefix=/usr/local/lib/pdf --enable-shared-pdflib --enable-cxx

 10-4 make

 10-5 make install

 10-6 cd /etc

 10-7 編輯 ld.so.conf

 10-8 加入 /usr/local/lib/pdf/lib

 10-9 cd /sbin

 10-10 ./ldconfig


--------------------------------------------------------------------------------

11 freetype

 11-1 tar -zxvf freetype-2.0.5.tar.gz

 11-2 cd freetype-2.0.5

 11-3 make setup CFG="--prefix=/usr/local"

 11-4 make

 11-5 make install


--------------------------------------------------------------------------------

12 gd (我發現 GD-1.8.x 似乎不支援 TrueType version 2 , 所以我安裝 2.0.1)

 12-1 tar -zxvf gd-2.0.1.tar.gz

 12-2 cd gd-2.0.1

 12-3 輸入 freetype-config --cflags 系統會告訴你的freetype lib 裝在哪裡,我的是裝在-I/usr/local/include/freetype2

   @@ 如果你的系統找不到freetype-config這個指令你可以到 cd /usr/bin下執行 ./freetype-config --cflags

 12-4 vi Makefile 找出 INCLUDEDIRS=-I. -I/usr/include/freetype2

   把他改成 INCLUDEDIRS=-I. -I/usr/local/include/freetype2

   @@ 後面那段必須輸入和你剛剛找到的路徑一樣

 12-5 make

 12-6 make install

 12-7 make libgd.a


--------------------------------------------------------------------------------

13 curl1

 13-1 tar -zxvf curl-7.9.tar.gz

 13-2 cd curl-7.9

 13-3 ./configure --prefix=/usr/local/lib

 13-4 make

 13-5 make install


--------------------------------------------------------------------------------

14 zlib

 14-1 tar -zxvf zlib-1.1.3.tar.gz1

 14-2 cd zlib-1.1.3

 14-3 ./configure -s

 14-4 make install


--------------------------------------------------------------------------------

15 php

 15-1 tar -zxvf php-4.0.6.tar.gz

 15-2 cd php-4.0.6

 15-3 ./configure --prefix=/usr/local/php --with-apxs=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql
   --with-pgsql=/usr/local/pgsql --enable-track-vars --enable-trans-sid --enable-safe-mode --enable-versioning
   --enable-ftp --disable-debug --with-ttf --with-xml --with-imap=../imap --with-pdflib=/usr/local
   --with-openssl=/usr/local/openssl --with-mm=/usr/local/lib/mm --with-gd --enable-gd-native-tt --with-freetype-dir
   --with-png-dir --with-jpeg-dir --with-zlib-dir --with-curl

 15-4 make

 15-5 make install

 15-6 cp /usr/local/php-4.0.6/php.ini-dist /usr/local/lib/php.ini

 15-7 cd /usr/local/apache/conf 我們需要編輯下面這幾行

  15-7-1 找出這段
     
      LoadModule ssl_module libexec/libssl.so
      LoadModule php4_module libexec/libphp4.so
     


    把他改成
     
      LoadModule ssl_module libexec/libssl.so
     

      LoadModule php4_module libexec/libphp4.so

  15-7-2 找出這段 DirectoryIndex index.html

     把他改成 DirectoryIndex index.php index.php3 index.htm index.html

  15-7-3 找出這段
      #AddType application/x-httpd-php .php
      #AddType application/x-httpd-php-source .phps

     把他改成
      AddType application/x-httpd-php .php .php3 .phtml
      AddType application/x-httpd-php-source .phps

 15-8 restart apachecd ../bin./apachectl restart

 15-9 edit a phpinfo pagecd ../htdocs編輯一個檔案 info.php 內容 --> < ?php phpinfo(); ?>

 15-10 測試 http://localhost/info.php or https://localhost/info.php
    如果你可以看到 php 的相關資訊 , 那你就完成了剛剛的東西了 ^_^


--------------------------------------------------------------------------------

@@ 下面我們要開始安裝 Tomcat 囉,我把相關的東西都準備安裝在/usr/local/jakarta 這個目錄底下所以我們要先做幾件事情

 M1 cd /usr/local

  M1-1 mkdir jakarta

  M1-2 cd /root

  M1-3 vi .bashrc

   要加幾行東西喔...

    1.JAKARTA_HOME=/usr/local/jakarta

    2.TOMCAT_HOME=$JAKARTA_HOME/tomcat

    3.export JAKARTA_HOME TOMCAT_HOME

@@ 所以現在我們的 /root/.bashrc 和 /etc/profile應該要有下面這些資訊(我有稍微整理過一下^_^)

  JAVA_HOME=/usr/local/j2sdk

  JAKARTA_HOME=/usr/local/jakarta

  TOMCAT_HOME=$JAKARTA_HOME/tomcat

  export JAVA_HOME JAKART_HOME TOMCAT_HOME

  PATH=$JAVA_HOME:$JAVA_HOME/binCLASSPATH=$JAVA_HOME/lib/tools.jar:/usr/local/JSDK2.0/lib/jsdk.jar:$HOME/java-class

  export PATH CLASSPATH


--------------------------------------------------------------------------------

16 JAXP : Java XML Parser Library

 16-1 解開檔案

 16-2 mv jaxp1.0.1 jaxp

 16-3 cd /usr/local/jakarta/jaxp

 16-4 cp *.jar $JAVA_HOME/jre/lib/ext


--------------------------------------------------------------------------------

17 JSSE : Secure Sockets Library

 17-1 解開檔案

 17-2 mv jsse1.0.2 jsse

 17-3 cd jsse

 17-4 cp *.jar $JAVA_HOME/jre/lib/ext

 17-5 測試一下我們的 JAVA 的 SSL 是不是已經安裝完成

  17-5-1 用你習慣的編輯器輸入以下程式碼...檔名叫做TestSSL.java

      import javax.net.ssl.*;

       public class TestSSL

       {

        public static void main(String [] arstring)

        {

          try

          {

           new java.net.URL("https://" + arstring[0] + "/").getContent();

          }

          catch (Exception exception)

          {

           exception.printStackTrace();

          }

        }

       }

  17-5-2 javac TestSSL.java

  17-5-3 接著我們要執行剛剛的java囉...請輸入以下的指令

     [root@demo jsse]# java -Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol TestSSL sourceforge.net

     [root@demo jsse]# echo $?

     0


     [root@demo jsse]#

     這樣就測試ok啦 ^^


--------------------------------------------------------------------------------

@@ 接下來的 Tomcat 你可以依自己的需要安裝3.2.3 或 3.3 或 4.0 的板本

18 Tomcat 4.0

 18-1 tar -zxvf jakarta-tomcat-4.0.tar.gz

 18-2 mv jakarta-tomcat-4.0 tomcat

 18-3 cd tomcat/bin

 18-4 /usr/local/apache/bin/apachectl stop -->如果你的apache原本就是為啟動的狀態,就不需執行此行

 18-5 ./startup.sh

 18-6 /usr/local/apache/bin/apachectl startssl

 18-7 測試一下,用瀏覽器開啟下列網址

  18-7-1 http://localhost/

  18-7-2 https://localhost/

  18-7-3 http://localhost:8080/


--------------------------------------------------------------------------------

19 Tomcat 3.2.3

 19-1 tar -zxvf jakarta-tomcat-3.2.3-src.tar.gz

 19-2 mv jakarta-tomcat-3.2.3-src src-tomcat

 19-3 cd src-tomcat/src/native/apache1.3

 19-4 vi Makefile.linux

  19-4-1 找出 #JAVA_HOME 改成 JAVA_HOME=/usr/local/j2sdk

  19-4-2 找出 APXS=/usr/sbin/apxs改成 APXS=/usr/local/apache/bin/apxs

 19-5 make -f Makefile.linux all

 19-6 cp mod_jk.so /usr/local/apache/libexec

 19-7 tar -zxvf jakarta-tomcat-3.2.3.tar-gz

 19-8 mv jakarta-tomcat-3.2.3 tomcat

 19-9 cd /usr/local/apache/conf

  19-9-1 vi httpd.conf

  19-9-2 在檔案最後加上 Include /usr/local/jakarta/tomcat/conf/mod_jk.conf

 19-10 測試

  19-10-1 cd /usr/local/jakarta/tomcat/bin

  19-10-2 /usr/local/apache/bin/apachectl stop -->如果你的apache原本就是為啟動的狀態,就不需執行此行

  19-10-3 ./startup.sh

  19-10-4 /usr/local/apache/bin/apachectl startssl

  19-10-5 用瀏覽器開啟下列網址

    19-10-5-1 http://localhost/

    19-10-5-2 https://localhost/

    19-10-5-3 http://localhost:8080/


--------------------------------------------------------------------------------

| 後記 |

這是我第一次寫心得分享,因為我對Linux並不是如此熟悉,因此這些東西總共花了我一個多星期.

過程中出現的錯誤訊息,在我的好朋友 darkhero [ darkhero@v-dark.net ] 的協助和我自己努力(^_^)下一一解決了,很謝謝他.

這篇心得分享算是第一步驟,因為現在我正在安裝 Cocoon 和了解 Tomcat 上如何整合 SSL

對於這篇文章如果有任何錯誤與指教請大家不吝指導,

也歡迎到我的網站上大家一起討論 祝大家都能順利安裝成功 ^_^
 Love is waiting so you don't have to. Join Date.com for free!
 Join Asia FriendFinder the Largest Asian Dating Site on the Web for FREE!
 Kaspersky Security for Internet Gateway 7.0
 Know when to sell on eBay using research

閱讀全文 | 回 應(0) |

 文章移轉

文章發佈於 : 2004-09-13 00:19:02 | 文章分類 : 網站更新與公告

我有另外一個網站主要是在放一些PHP文件的地方
我現在決定將那個網站上面的一些文章移轉到這裡來.
那個網站也要直接轉換到這個地方.
這樣我就只要維護一個網站就可以了.:grin:
 Love is waiting so you don't have to. Join Date.com for free!
 Join Asia FriendFinder the Largest Asian Dating Site on the Web for FREE!
 Kaspersky Security for Internet Gateway 7.0
 Know when to sell on eBay using research

閱讀全文 | 回 應(0) |

 BlogShares Links Exchange

1. Step into the Nexus 2. Scary Personals 3. Scared Bunny
4. This Is A Cult 5. Its all about me 6. Webby's World
7. Flower Delivery 8. Mindblogging Stuff 9. Random Thoughts by R. U. Serious
10. Palmistry and Hand Analysis 11. Forward-and-Share 12. The Site With the Lamp
13. Free Sample Forager 14. Kosir 15. CRM Reports

 阿維推薦

1. ㄚ凱隨手記 2. ↖「懿」*瘋*堂↗ 3. A.D. Notepad 西元記事本
4. Liang's Blog 5. 硬是要學! 6. 北國風情
7. 綠色工廠 8. 淡淡的天空藍 9. 班大貓廢紙塗鴉部落格
10. 大豆剝落殼 11. SEO网站优化推广 12. lazy Guy
13. PHP 黑店 14. Meson手扎

 Back Links