discuz 环境安装

1、检查系统是否正常

more /var/log/messages(检查有无系统级错误信息)

dmesg (检查硬件设备是否有错误信息)

cat /proc/cpuinfo (检查 CPU 频率是否正常)

top (按 1 检测 CPU 核数是否正常,内存大小是否正常)

ifconfig(检查网卡设置是否正确)

ping www.qq.com(检查网络是否正常)

2、关闭不需要的服务

执行 ntsysv 命令:

ntsysv

在服务设置界面,设置各项服务的开关。以下仅列出需要启动的服务,未列出的服务一律推荐关闭:

atd

crond

irqbalance

microcode_ctl

network

sendmail

sshd

syslog

关闭 SElinux ,关闭方法如下:

修改 /etc/selinux/config 文件中的 SELINUX= 为 disabled。

3、更换快速下载源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.old

cd /etc/yum.repos.d/

wget http://c.sihost.net/CentOS-Base-sohu.repo

mv CentOS-Base-sohu.repo CentOS-Base.repo

yum clean

yum -y update

lsb_release -a

yum -y erase mysql

yum -y erase php

yum -y erase httpd

4、使用 yum 程序安装所需开发包(以下为标准的 RPM 包名称)

yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libtiff-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel fontconfig-devel zlib zlib-devel libevent-devel gcc gcc-c++ flex bison bzip2-devel libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

5、定时校正服务器时钟,定时与中国国家授时中心授时服务器同步

编辑计划任务:

crontab �Ce

加入下面一行:

*/30 * * * * ntpdate 210.72.145.44 > /dev/null 2>&1

编辑完成后,保存即可。

6、下载程序包

Apache

推荐稳定版 2.2.21,下载地址为 http://archive.apache.org/dist/httpd/

PHP

推荐稳定版 5.2.17,下载地址为 http://cn.php.net/downloads.php

Mysql

推荐稳定版 5.5.18,下载地址为 http://www.mysql.com/downloads/mysql/

文中的配置文件和脚本限于篇幅,请到以下地址下载(仅支持 Linux 下使用 wget 下载)

Apache控制脚本,下载地址为 http://c.sihost.net/jb/httpd

Apache配置文件,下载地址为 http://c.sihost.net/jb/httpd.conf

单独下载各程序及文件的方式较为繁琐,我们将上面所需程序和文件整理成下载列表,如下:

http://c.sihost.net/lamp_tools.list

在 /usr/local/src 目录下执行下面两个命令,下载 lamp_tools.list 及该列表中的程序:

wget http://c.sihost.net/lamp_tools.list

wget -i lamp_tools.list

7、创建 web 运行用户

groupadd www

useradd -g www www

mkdir -p /data/wwwroot

chmod +w /data/wwwroot

chown www:www /data/wwwroot -R

8、重新启动

init 6


编译安装环境

1、安装 MySQL

cd /usr/local/src

tar zxvf cmake-2.8.5.tar.gz

cd cmake-2.8.5/

./configure

gmake &&gmake install

groupadd mysql

useradd -g mysql mysql

mkdir -p /data/mysql

chown -R mysql:mysql /data/mysql

cd /usr/local/src

tar zxvf mysql-5.5.18.tar.gz

cd mysql-5.5.18

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/Comsenz/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/usr/local/Comsenz/etc/ -DWITH_BLACKHOLE_STORAGE_ENGINE=1

make && make install

cd /usr/local/Comsenz/mysql

./scripts/mysql_install_db --user=mysql

cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod 755 /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig --level 3 mysqld on

编辑 /etc/rc.d/init.d/mysqld,找到

basedir=
datadir=

改成

basedir=/usr/local/Comsenz/mysql
datadir=/data/mysql

然后在 Comsenz 目录下创建 etc 目录,并将 MySQL 配置文件拷贝到该目录下:

mkdir -p /usr/local/Comsenz/etc

cp ./support-files/my-huge.cnf /usr/local/Comsenz/etc/my.cnf

编辑配置文件 /usr/local/Comsenz/etc/my.cnf,在 [mysqld] 段增加

datadir = /data/mysql

wait-timeout = 10

max_connections = 512

max_connect_errors = 10000000

local-infile=0

在 [mysqld] 段修改

max_allowed_packet = 16M

thread_cache_size = CPU个数*2

将 log-bin 注释

mv /usr/local/Comsenz/mysql/data/* /data/mysql

service mysqld start

bin/mysqladmin -u root password 'admin999'

其中 admin999 是要设置的 root 密码。

2、安装 Apache

cd /usr/local/src/

tar zxvf httpd-2.2.21.tar.gz

cd httpd-2.2.21

./configure --prefix=/usr/local/Comsenz/apache --enable-module=rewrite --disable-access --disable-auth --disable-charset-lite --disable-include --disable-log-config --disable-env --disable-setenvif --disable-mime --disable-status --disable-autoindex --disable-asis --disable-cgid --disable-cgi --disable-negotiation --disable-dir --disable-actions --disable-userdir --disable-alias --enable-so --enable-mods-shared='access auth auth_anon auth_dbm auth_digest dav dav_fs actions alias asis autoindex cache cern_meta cgi charset_lite deflate dir disk_cache env expires file_cache headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias'

make && make install

cd /usr/local/src/

mv /usr/local/Comsenz/apache/conf/httpd.conf /usr/local/Comsenz/apache/conf/httpd.conf.old

cp -f /usr/local/src/httpd.conf /usr/local/Comsenz/apache/conf/httpd.conf

cp -f /usr/local/src/httpd /etc/init.d/httpd

chmod 755 /etc/init.d/httpd

chkconfig --add httpd

chkconfig httpd on

3、编译安装 PHP 所需的支持库

tar zxvf libiconv-1.14.tar.gz

cd libiconv-1.14/

./configure --prefix=/usr/local

make && make install

cd /usr/local/src/

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure

make && make install

/sbin/ldconfig

cd libltdl/

./configure --enable-ltdl-install

make && make install

cd /usr/local/src/

tar zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9/

./configure

make && make install

cd /usr/local/src/

64bit 系统执行下面的:

ln -s /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la

ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so

ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4

ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8

ln -s /usr/local/lib/libmhash.a /usr/lib64/libmhash.a

ln -s /usr/local/lib/libmhash.la /usr/lib64/libmhash.la

ln -s /usr/local/lib/libmhash.so /usr/lib64/libmhash.so

ln -s /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2

ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/libiconv.so.2


32bit 系统执行下面的:

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8

ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a

ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la

ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so

ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8

/sbin/ldconfig

./configure

make && make install

4、编译安装PHP

cd /usr/local/src

tar zxvf php-5.2.17.tar.gz

cd php-5.2.17

./configure --prefix=/usr/local/Comsenz/php5 --with-config-file-path=/usr/local/Comsenz/etc --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-magic-quotes --with-mysql=/usr/local/Comsenz/mysql --with-pear --enable-sockets --with-ttf --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --enable-sysvsem --enable-exif --enable-sysvshm --with-libxml-dir=/usr --with-apxs2=/usr/local/Comsenz/apache/bin/apxs --with-iconv=/usr/local/libiconv --with-iconv-dir=/usr/local --with-xmlrpc --enable-xml --enable-shmop --enable-zip --with-mhash --with-mcrypt --enable-discard-path --enable-bcmath --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --with-openssl

make &&make install

./libtool --finish /usr/local/src/php-5.2.17/libs

cp php.ini-dist /usr/local/Comsenz/etc/php.ini

echo 'ulimit -SHn 65535' >> /etc/rc.local

5、安装 PHP 扩展模块(需要此功能的 Discuz! X 用户选装)

安装 APC

cd /usr/local/src

tar zxvf APC-3.1.9.tgz

cd APC-3.1.9

/usr/local/Comsenz/php5/bin/phpize

./configure --enable-apc --enable-mmap --enable-apc-spinlocks --disable-apc-pthreadmutex --with-php-config=/usr/local/Comsenz/php5/bin/php-config

make &&make install

编辑配置文件 /usr/local/Comsenz/etc/php.ini,查找

extension_dir =

在下面一行添加

extension_dir = "/usr/local/Comsenz/php5/lib/php/extensions/no-debug-non-zts-20060613/"

extension="apc.so"

apc.enabled = 1

apc.shm_size = 64M

apc.stat = 1

编辑完成后,保存。

6、查看确认 LAMP 环境信息、提升 PHP 安全性

保存以下内容为 info.php 到 /data/www/,检查 phpinfo 中的各项信息是否正确。

<?

phpinfo();

?>

确认 PHP 能够正常工作后,编辑 /usr/local/Comsenz/etc/php.ini 进行设置提升 PHP 安全性。查找

disable_functions =

修改成

disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,leak,popepassthru,stream_socket_server,popen

然后重启 web 服务:

service httpd restart


你可能感兴趣的:(环境,discuz)