Table of Contents
1. Install Required System Packages
2. Install Extra Packages
3. Compile and Install MySQL
4. Compile and Install Apache
5. Compile and Install PHP
6. Install Zend Optimizer
7. Integrate Apache and PHP
8. Test PHP and Improve its Security
9. Install and Configure Discuz6.0
1 Install Required System Packages
Needless to say, you should install required system packages. So you cancontinue the next steps. :-)
Be sure these packages are installed:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
gcc
gcc-c++
flex
bison
autoconf
automake
bzip2
-devel
ncurses-devel
libjpeg-devel
libpng-devel
libtiff-devel
freetype-devel
pam-devel
|
Well, you can use a command to check them whether installed
1
|
[root@lamp ~]
# for i in gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel ; do rpm -q ${i} ; done
|
2 Install Extra Packages
In this section, we need to compile and install four packages:
-
GD2
-
LibXML2
-
LibMcrypt
-
OpenSSL
I'll show how to compile and install, yeah, it's simple!
-
GD2
123456[root@lamp ~]
# cd /usr/local/src
[root@lamp src]
# tar xzvf gd-2.0.34.tar.gz
[root@lamp src]
# cd gd-2.0.34
[root@lamp gd-2.0.34]
# ./configure --prefix=/usr/local/gd2
[root@lamp gd-2.0.34]
# make
[root@lamp gd-2.0.34]
# make install
-
LibXML2
123456[root@lamp ~]
# cd /usr/local/src
[root@lamp src]
# tar xzvf libxml2-2.6.29.tar.gz
[root@lamp src]
# cd libxml2-2.6.29
[root@lamp libxml2-2.6.29]
# ./configure --prefix=/usr/local/libxml2
[root@lamp libxml2-2.6.29]
# make
[root@lamp libxml2-2.6.29]
# make install
-
LibMcrypt
123456[root@lamp ~]
# cd /usr/local/src
[root@lamp src]
# tar xjvf libmcrypt-2.5.8.tar.bz2
[root@lamp src]
# cd libmcrypt-2.5.8
[root@lamp libmcrypt-2.5.8]
# ./configure 鈥損refix=/usr/local/libmcrypt
[root@lamp libmcrypt-2.5.8]
# make
[root@lamp libmcrypt-2.5.8]
# make install
-
OpenSSL
1234567[root@lamp ~]
# cd /usr/local/src
[root@lamp src]
# tar xzvf openssl-0.9.8e.tar.gz
[root@lamp src]
# cd openssl-0.9.8e
[root@lamp openssl-0.9.8e]
# ./config --prefix=/usr/local/openssl
[root@lamp openssl-0.9.8e]
# make
[root@lamp openssl-0.9.8e]
# make test
[root@lamp openssl-0.9.8e]
# make install
3 Compile and Install MySQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
[root@lamp ~]
#tar xzvf mysql-5.0.27.tar.gz
[root@lamp ~]
# cd mysql-5.0.27
[root@lamp mysql-5.0.27]
# ./configure \
"--prefix=/usr/local/mysql"
\
"--localstatedir=/var/lib/mysql"
\
"--with-mysqld-user=mysql"
\
"--without-debug"
\
"--with-big-tables"
\
"--with-extra-charsets=all"
\
"--with-pthread"
\
"--enable-static"
\
"--enable-thread-safe-client"
\
"--with-client-ldflags=-all-static"
\
"--with-mysqld-ldflags=-all-static"
\
"--enable-assembler"
\
"--without-isam"
\
"--without-innodb"
\
"--without-ndb-debug"
[root@lamp msyql-5.0.27]
# make
[root@lamp mysql-5.0.27]
# make install
[root@lamp mysql-5.0.27]
# useradd mysql
[root@lamp mysql-5.0.27]
# cd /usr/local/mysql
[root@lamp mysql]
# bin/mysql_install_db --user=mysql
[root@lamp mysql]
# chown -R root:mysql .
[root@lamp mysql]
# chown -R mysql /var/lib/mysql
[root@lamp mysql]
# cp share/mysql/my-huge.cnf /etc/my.cnf
[root@lamp mysql]
# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
[root@lamp mysql]
# chmod 755 /etc/rc.d/init.d/mysqld
[root@lamp mysql]
# chkconfig --add mysqld
[root@lamp mysql]
# chkconfig --level 3 mysqld on
[root@lamp mysql]
# /etc/rc.d/init.d/mysqld start
[root@lamp mysql]
# bin/mysqladmin -u root password 'clear123'
|
4 Compile and Install Apache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@lamp src]
# cd /usr/local/src
[root@lamp src]
# tar xjvf httpd-2.2.4.tar.bz2
[root@lamp src]
# cd httpd-2.2.4
[root@lamp httpd-2.2.4]
# ./configure \
"--prefix=/usr/local/apache2"
\
"--with-included-apr"
\
"--enable-so"
\
"--enable-deflate=shared"
\
"--enable-expires=shared"
\
"--enable-rewrite=shared"
\
"--enable-static-support"
\
"--disable-userdir"
[root@lamp httpd2.2.4]
# make
[root@lamp httpd2.2.4]
# make install
[root@lamp httpd2.2.4]
# echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local
|
5 Compile and Install PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
[root@lamp ~]
# cd /usr/local/src
[root@lamp src]
# tar xjvf php-5.2.3.tar.bz2
[root@lamp php-5.2.3]
# cd php-5.2.3
[root@lamp php-5.2.3]
# ./configure \
"--prefix=/usr/local/php"
\
"--with-apxs2=/usr/local/apache2/bin/apxs"
\
"--with-config-file-path=/usr/local/php/etc"
\
"--with-mysql=/usr/local/mysql"
\
"--with-libxml-dir=/usr/local/libxml2"
\
"--with-gd=/usr/local/gd2"
\
"--with-jpeg-dir"
\
"--with-png-dir"
\
"--with-bz2"
\
"--with-freetype-dir"
\
"--with-iconv-dir"
\
"--with-zlib-dir "
\
"--with-openssl=/usr/local/openssl"
\
"--with-mcrypt=/usr/local/libmcrypt"
\
"--enable-soap"
\
"--enable-gd-native-ttf"
\
"--enable-memory-limit"
\
"--enable-ftp"
\
"--enable-mbstring"
\
"--enable-exif"
\
"--disable-ipv6"
\
"--disable-cgi"
\
"--disable-cli"
[root@lamp php-5.2.3]
# make
[root@lamp php-5.2.3]
# make install
[root@lamp php-5.2.3]
# mkdir /usr/local/php/etc
[root@lamp php-5.2.3]
# cp php.ini-dist /usr/local/php/etc/php.ini
|
6 Install Zend Optimizer
1
2
3
|
[root@lamp ~]
# cd /usr/local/src
[root@lamp ~]
# tar xf ZendOptimizer-3.2.8-linux-glibc21-i386.tar.gz
[root@lamp ~]
# ./ZendOptimizer-3.2.8-linux-glibc21-i386/install.sh
|
Note:
1
2
3
|
Then pop up a dialog, just type "accept" to continue, it will prompt you
input the php.ini file's path. Ok, input like this: "/usr/local/php/etc"
without double quotes.
|
7 Integrate Apache and PHP
We should modify configure file httpd.conf:
1
|
[root@lamp ~]
# emacs /usr/local/apache2/conf/httpd.conf
|
Find this line,
1
|
AddType application
/x-gzip
.gz .tgz
|
Add one line under this line
1
|
AddType application
/x-httpd-php
.php
|
Find these lines,
1
2
3
|
<IfModule dir_module>
DirectoryIndex index.html
<IfModule>
|
Change them like this,
1
2
3
|
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
<IfModule>
|
Find and uncomment these lines,
1
2
3
4
|
#Include conf/extra/httpd-mpm.conf
#Include conf/extra/httpd-info.conf
#Include conf/extra/httpd-vhosts.conf
#Include conf/extra/httpd-default.conf
|
When finished, save it! Then restart apache service
1
|
[root@lamp ~]
# /usr/local/apache2/bin/apachectl restart
|
8 Test PHP and Improve its Security
PHP provides a function phpinfo() to test php is available, so we need to write a .php file in the root document of our web site.
1
|
[root@lamp ~]
# emacs /usr/local/apache2/docs/dummy-host.example.com/phpinfo.php
|
<?php phpinfo(); ?>
Open our browser, locate this file
http://<ip_addr>/phpinfo.php
After this test, we should disable some functions of php, just to improve its security. We need to modify php.ini file.
1
|
[root@lamp ~]
# emacs /usr/local/php/etc/php.ini
|
Find this line,
1
|
disable_functions =
|
Chang this line to this,
1
|
disable_functions = phpinfo,passthru,
exec
,system,chroot,scandir,
chgrp
,
chown
,escapeshellcmd,escapeshellarg,shell_exec,proc_open,proc_get_status,error_log,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,
symlink
,leak,popepassthru,stream_socket_server
|
9 Install and Configure Discuz6.0
1
2
3
4
5
6
7
|
[root@lamp ~]
# tar xf discuz.tar.gz -C /usr/local/src
[root@lamp ~]
# mv /usr/local/src/discuz/upload /usr/local/apache2/docs/dummy-host
[root@lamp ~]
# mysql -uroot -pclear123
mysql> create database discuz;
mysql> grant all on discuz.* to discuz@
'localhost'
identified by
'clear123'
;
mysql> flush privileges;
mysql> quit
|
Install it, open your browser, input this address: http://<ip_addr>/bbs/install.php
Date: 2011-11-12
Author: LavenLiu
Created: 2014-03-18 周二 17:41
Emacs 24.3.1 (Org mode 8.2.5c)
本文转自 bigstone2012 51CTO博客,原文链接:
http://blog.51cto.com/lavenliu/1378926