CentOS6.2安装LAMP+DRUPAL网站
(原创,权利保留,如转载请注明出处)
1. apache2+openssl+mysql+ca+php5 完整安装(成功版)
1.1设置好机器名和IP等信息
1.2将以下软件源码copy到/usr/local/src:
1.3安装配置mysql.
1.4安装openssl:
1.5安装apr、apr-util、pcre:
1.6安装apache2:
1.7安装php相关软件
1.8mysql扩展,按如下处理:
1.9openssl扩展支持处理:
2安装drupal.
2.1安装pdo_mysql.
2.2安装drupal前准备
2.3core安装
2.4clean URL
2.5文件系统设置
2.6安装drupal wysiwyg模块(所见即所得)
2.7imce.
2.8安装libraries api/transliteration.
2.9用户相关简单模块..
2.10数学公式.
2.11评价模块
2.12定时备份mysql和drupal主页内容到u盘
2.13扩展支持性模块
2.14Ddblock 安装动态展示图片模块
2.15smart_paging.
2.16用户的锁定机制设置flood_control.
2.17内容类型
2.18验证码模块
2.19用户积分控制模块
2.20产品与购买模块
2.21Ubercart设置
2.22PHP mail.
2.23分享到社交网站模块.
2.24Files下载积分控制
1.1userpoints.
1.2重点.
1.3支付宝接口模块..
1.4QQ登录模块.
2.25网站花生壳解析服务.
2.26在线考试用的模块
2.27hook and module
3网站内容
3.1功能
3.2内容
3.3安装记录
安装好最小版本的CentOS6.2
(root,我58)
(生产机器禁止root远程登录,创建普通登录账号fc,登录后su root切换。
#useradd fc
#passwd fc(Fcisjade!)
#vi /etc/ssh/sshd_config
PermitRootLogin yes �C> PermitRootLogin no
#service sshd restart
)
1.1设置好机器名和IP等信息
vi /etc/hosts
vi /etc/sysconfig/network
(vi /etc/hosts
127.0.0.1 m8 m8.localdomain localhost localhost.localdomain
::1 m8 m8.localdomain localhost localhost.localdomain)
vi /etc/resolv.conf
service network restart(重启生效)
vi /etc/sysconfig/network-scripts/ifcfg-eth0
增加:
IPADDR=xxx.xxx.xxx.xxx
NETMASK=255.255.255.0
NETWORK=xxx.xxx.xxx.0
vi /etc/resolv.conf
(search localdomain
nameserver 202.96.134.133)
u基础准备
yum install -y ntpdate
//安装ntp同步
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
//设置为东8区
ntpdate us.pool.ntp.org
//执行一次同步
crontab -e
0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP
//每10分钟同步一次
yum install �Cy gnome-libs-1.4.2-5.el5.kb.i386.rpm
yum install �Cy libaio
yum install �Cy make gcc
yum install �Cy gcc-c++
yum install �Cy make perl
uU盘挂接
U盘在windows下格式化成fat32格式。
modprobe usb-storage
//启usb支持
fdisk �Cl
//查看设备情况
mount -t vfat /dev/sdb1 /mnt/usb
/mnt/usb就是此u盘在centos中的目录了。
如果不用了,执行:
umount /mnt/usb
//需要退出/mnt/usb目录。
1.2将以下软件源码copy到/usr/local/src:
apr-1.4.6.tar.gz
apr-util-1.4.1.tar.gz
curl-7.27.0.tar.gz
freetype-2.3.5.tar.gz
gd-2.0.33.tar.gz
httpd-2.4.3.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.5.12.tar.gz
libxml2-2.8.0.tar.gz
libxslt-1.1.27.tar.gz
mysql-5.5.27-linux2.6-i686.tar.gz
openssl-1.0.1c.tar.gz
pcre-8.31.tar.gz
php-5.4.0.tar.gz
zlib-1.2.7.tar.gz
依次解压:
tar �Czxvf ….tar.gz
(… 用具体文件名替代)
或全部解压:
for ARK in ./*.tar.gz; do tar -xvf $ARK; done
将属主全部改为root:
chown root:root * -R
u检查、修正系统时间:
date [0926073012]
(2012-09-26 07:30)
1.3安装配置mysql
mv mysql-5.5.27-linux2.6-i686 /usr/local/mysql
cd /usr/local/mysql
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
cp support-files/my-medium.cnf /etc/my.cnf
./scripts/mysql_install_db
增加用户、组:
groupadd mysql
useradd -g mysql mysql
passwd mysql
(输入符合策略的密码:我是幸运的2013!)
授权:
chown mysql:mysql /usr/local/mysql -R
测试运行:
./bin/mysqld_safe &
service mysqld start
检查:
netstat �Cant
可以看到3306端口被侦听。
修改管理账号密码:
./bin/mysqladmin -u root password XXXXXXXX
(我是幸运的2013!)
(如果已经有原始密码,则输入./bin/mysqladmin -u root �Cp password XXXXXXXX,输入原始密码后更改新密码)
登录:
./bin/mysql -u root -p
删除空密码账号:
mysql> use mysql;
mysql> delete from user where User='';
1.4安装openssl:
cd /usr/local/src/openssl-1.0.1c
./config --prefix=/usr/local/openssl
make && make install
(如果GCC报错,要装好GCC
安装程序在光盘server目录。安装顺序
rpm -ivh cpp-3.4.6-3.i386.rpm
rpm -ivh glibc-kernheaders-2.4-9.1.98.EL.i386.rpm
rpm -ivh glibc-headers-2.3.4-2.25.i386.rpm
rpm -ivh glibc-devel-2.3.4-2.25.i386.rpm
rpm -ivh gcc-3.4.6-3.i386.rpm)
1.5安装apr、apr-util、pcre:
cd /usr/local/src/apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install
cd /usr/local/src/apr-util-1.4.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
cd /usr/local/src/pcre-8.31
./configure --prefix=/usr/local/pcre
make && make install
make[1]: *** [pcrecpp.lo] Error 1 说明缺少安装gcc-c++库,安装即可安装命令:yum -y install gcc-c++ 重新configure
1.6安装apache2:
cd /usr/local/src/httpd-2.4.3
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-ssl=/usr/local/openssl --enable-ssl --enable-so --enable-mods-shared=most
make && make install
在/usr/local/apache2/bin目录下创建启动脚本:
cd /usr/local/apache2/bin
vim apache2.sysvinit,内容如下:
(其中# chkconfig: 2345 80 30 # description: apache2 - WWW local 两行是必须的,否则无法设置chkconfig)
#!/bin/sh
#
# This is a sample /etc/init.d file for apache
#
# chkconfig: 2345 80 30
# description: apache2 - WWW local
#
#
#
prefix=/usr/local/apache2
exec_prefix=/usr/local/apache2
bindir=${exec_prefix}/bin
sbindir=${exec_prefix}/sbin
case "$1" in
start)
echo -e "Starting apache2 WWW local:"
/usr/local/apache2/bin/apachectl -f /usr/local/apache2/conf/httpd.conf -k start
echo -e ""
;;
stop)
echo -e "Stopping apache2 WWW local:"
/usr/local/apache2/bin/apachectl -f /usr/local/apache2/conf/httpd.conf -k stop
echo -e ""
;;
restart)
$0 stop
sleep 3s
$0 start
;;
esac
exit 0
将此脚本copy到系统目录:
cp apache2.sysvinit /etc/rc.d/init.d/httpd2
更改权限:
chmod 755 /etc/rc.d/init.d/httpd2
加到自启动列表:
chkconfig --add httpd2
如已有其它apache版本,禁止自启动:
检查:chkconfig --list|grep http
禁止旧版本运行:chkconfig --level 0123456 httpd off
测试:
/etc/rc.d/init.d/httpd2 start
验证端口:
netstat -ant|grep LISTEN
访问验证:浏览器访问http://192.168.216.11/,会显示It works!
nCentos可能防火墙端口没有开:
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 443 -j ACCEPT
开80/443端口
service iptables save
(centos5.2之前:/etc/rc.d/init.d/iptables save)
保存防火墙配置。
如无线路由器设置的虚拟服务器发布不生效,检查下服务器是否将网关设置为路由器的LAN IP:
route add default gw 192.168.0.1
更改无线路由器登录: admin(我58)
l启用ssl模块
cd /usr/local/apache2/conf/
cp httpd.conf httpd.conf.bak
(备份conf文件)
vi /usr/local/apache2/conf/httpd.conf(先cp备份),将下面3个前面的#号去掉:
#Include conf/extra/httpd-ssl.conf
#LoadModule ssl_module modules/mod_ssl.so
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
生成证书:
cd /usr/local/openssl/ssl/certs/
/usr/local/openssl/bin/openssl req -new -x509 -days 3650 -nodes -out cert.pem -keyout cert.pem为www.mathsea.com颁发,属于自颁发证书。
cp cert.pem /usr/local/apache2/conf
cd /usr/local/apache2/conf/extra/
cp httpd-ssl.confhttpd-ssl.conf.bak
vim /usr/local/apache2/conf/extra/httpd-ssl.conf
增加:
SSLCertificateFile "/usr/local/apache2/conf/cert.pem"
而:
#SSLCertificateFile "/usr/local/apache2/conf/server.crt"
#SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
注释掉。
对mod_ssl.so的授权限制处理:
setenforce 0
chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2/modules/mod_ssl.so
(在centos中去掉-c)
setenforce 1
有可能系统提示“setenforce: SELinux is disabled”,则不需要执行。
验证:
service httpd2 restart
netstat -ant |grep LISTEN
应可看到443端口侦听。IE用https访问也可(会提示证书问题)。
1.7安装php相关软件
l安装jpeg6:
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/man
mkdir /usr/local/jpeg6/man1
mkdir /usr/local/jpeg6/man/man1
cd /usr/local/src/jpeg-6b/
./configure --prefix=/usr/local/jpeg6 --enable-shares --enable-static
make && make install
l安装zlib:
cd /usr/local/src/zlib-1.2.7
./configure --prefix=/usr/local/zlib
vim Makefile,在CFLAGS 后面添加 -fPIC 参数(是一个bug),
make && make install
l安装libpng:
cd /usr/local/src/libpng-1.5.12
cp scripts/makefile.std makefile
vim makefile,将里面zlib的路径替代正确。
make && make install
l安装freetype:
cd /usr/local/src/freetype-2.3.5
mkdir /usr/local/freetype
./configure --prefix=/usr/local/freetype
make && make install
l安装gd2:
cd /usr/local/src/gd-2.0.33
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/lib --with-zlib=/usr/local/zlib/lib --with-freetype=/usr/local/freetype
原因是zlib安装路径为/usr/local/zlib,因为不但需要zlib的lib目录,还需要include目录,如下可以解决:
CFLAGS=" -I/usr/local/zlib/include" LDFLAGS="-L/usr/local/zlib/lib" ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/lib --with-freetype=/usr/local/freetype
make && make install
访问phpinfo()确认是否GD支持JPEG Support
vim /usr/local/gd2/include/gd_io.h,在void (*gd_free)结构里面增加一句(是一个bug):
void (*data);
n意外案例解决:
按以上方法,结果访问phpinfo()结果没有JPEGsupport,解决方法:
cd /usr/local/src/gd-2.0.33
make clean
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/lib --with-zlib=/usr/local/zlib/lib --with-freetype=/usr/local/freetype
make && make install
vim /usr/local/gd2/include/gd_io.h,在void (*gd_free)结构里面增加一句(是一个bug):
void (*data);
cd /usr/local/src/php-5.4.0
make clean
./configure --prefix=/usr/local/php --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/bin --with-zlib-dir=/usr/local/zlib --with-freetype-dir=/usr/local/freetype --with-curl=/usr/local/curl --with-xsl=/usr/local/libxslt --enable-soap --enable-sockets --enable-mbstring --enable-ftp
make && make install
/etc/rc.d/init.d/httpd2 restart
恢复。原因:GD没有安装好对JPEG的支持,PHP也需要重新编译安装。
l安装libxml2:
yum install libxml2-devel
cd /usr/local/src/libxml2-2.8.0
./configure --prefix=/usr/local/libxml2 --with-zlib=/usr/local/zlib
vim Makefile,找到起始为CFLAGS的行(vim中/^CFLAGS),在其末尾增加空格和-fPIC(是一个bug)
make && make install
l安装libxslt:
cd /usr/local/src/libxslt-1.1.27
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
make && make install
l安装curl
cd /usr/local/src/curl-7.27.0
./configure --prefix=/usr/local/curl
make && make install
u安装php5:
yum install libjpeg-devel
cd /usr/local/src/php-5.4.0
./configure --prefix=/usr/local/php --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/bin --with-zlib-dir=/usr/local/zlib --with-freetype-dir=/usr/local/freetype --with-curl=/usr/local/curl --with-xsl=/usr/local/libxslt --enable-soap --enable-sockets --enable-mbstring --enable-ftp
(特别说明:--with-mysqli=/your/path/to/mysql_config, /your/path/to/是mysql_config这个可执行文件的路径)
make && make install
#如果configure时OK但make是报错,提示没有data数据类型,修改/usr/local/gd2/gd_io.h,增加如下红色部分:
并且重新在/usr/local/src/php-5.4.6执行make clean,再重新执行configure,make,make install
#另如出现
configure: error: jpeglib.h not found.
安装libjpeg-devel(从安装光盘或者网上下载)
copy ini文件:
cp php.ini-production /usr/local/php/lib/php.ini
vi /usr/local/apache2/conf/httpd.conf,找到 AddType application/x-gzip .gz .tgz,在其下增加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
/usr/local/apache2/bin/apachectl start测试,如果报错:
httpd: Syntax error on line 146 of /usr/local/apache2/conf/httpd.conf: Cannot load modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
执行下面3行命令解决:
setenforce 0
chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2/modules/libphp5.so
setenforce 1
生成测试php脚本:
cd /usr/local/apache2/htdocs/
vi test.php
test.php的内容是:
<?php
phpinfo();
?>
重启apache2:
/etc/rc.d/init.d/httpd2 restart
在客户端IE访问验证:
https://192.168.216.11/test.php
成功!
1.8mysql扩展,按如下处理:
yum install autoconf
cd /usr/local/src/php-5.4.0/ext/mysql
/usr/local/php/bin/phpize
(不先执行yum install autoconf会有如下报错)
./configure --with-php-config=/usr/local/php/bin/php-config --with-mysql=/usr/local/mysql
make && make install
vi /usr/local/php/lib/php.ini,搜索/or under UNIX:,在此处增加:
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20100525/mysql.so
/etc/rc.d/init.d/httpd2 restart
1.9openssl扩展支持处理:
cd /usr/local/src/php-5.4.0/ext/openssl
/usr/local/php/bin/phpize
如出现以下错误:Cannot find config.m4. *****************************************
解决方法:
查看源码包OPENSSL文件夹下是否有config0.m4,如果有可执行,
#mv config0.m4 config.m4,
再次执行/usr/local/php/bin/phpize,然后
http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
tar -zxvf re2c-0.13.5.tar.gz
cd re2c-0.13.5
./configure && make && make install
再安装openssl-devel及其相关包:
yum install openssl-devel,否则会报如下黑框中“…warning:You will need re2c…”错误。
./configure --with-php-config=/usr/local/php/bin/php-config --with-openssl --with-libdir=/usr/lib/(注意后面两个参数,曾经错过。如果对于./configure带什么参数不清楚,可以通过./configure �Chelp来查找)
为避免出现libssl not found!错误,要将openssl-devel***及其依赖的安装包装上。
make && make install
vi /usr/local/php/lib/php.ini,增加:
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20100525/openssl.so
/etc/rc.d/init.d/httpd2 restart