一、配置server 1
1.1 配置编译安装环境
- Development Tools
- Development Libraries
- #yum -y groupinstall "Development Libraries"
1.2 安装httpd 2.4.2 版本
- #yum -y install pcre-devel 解决依赖关系
- # tar xf httpd-2.4.2.tar.bz2
- # cd httpd-2.4.2
- # less INSTALL 查看安装说明
- $ ./configure --prefix=PREFIX
- $ make
- $ make install
- $ PREFIX/bin/apachectl start
- # ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd
- --enable-so --enable-rewrite --with-zlib --with-pcre
- --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
- --enable-modules=most --enable-ssl --enable-modules-shared=most
- #make && make install
- #vim /etc/httpd/httpd.conf
- idFile "/var/run/httpd.pid" 添加
#vim /etc/rc.d/init.d/httpd
- #!/bin/bash
- #
- # httpd Startup script for the Apache HTTP Server
- #
- # chkconfig: - 85 15
- # description: Apache is a World Wide Web server. It is used to serve \
- # HTML files and CGI.
- # processname: httpd
- # config: /etc/httpd/conf/httpd.conf
- # config: /etc/sysconfig/httpd
- # pidfile: /var/run/httpd.pid
- # Source function library.
- . /etc/rc.d/init.d/functions
- if [ -f /etc/sysconfig/httpd ]; then
- . /etc/sysconfig/httpd
- fi
- # Start httpd in the C locale by default.
- HTTPD_LANG=${HTTPD_LANG-"C"}
- # This will prevent initlog from swallowing up a pass-phrase prompt if
- # mod_ssl needs a pass-phrase from the user.
- INITLOG_ARGS=""
- # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
- # with the thread-based "worker" MPM; BE WARNED that some modules may not
- # work correctly with a thread-based MPM; notably PHP will refuse to start.
- # Path to the apachectl script, server binary, and short-form for messages.
- apachectl=/usr/local/apache/bin/apachectl
- httpd=${HTTPD-/usr/local/apache/bin/httpd}
- prog=httpd
- pidfile=${PIDFILE-/var/run/httpd.pid}
- lockfile=${LOCKFILE-/var/lock/subsys/httpd}
- RETVAL=0
- start() {
- echo -n $"Starting $prog: "
- LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && touch ${lockfile}
- return $RETVAL
- }
- stop() {
- echo -n $"Stopping $prog: "
- killproc -p ${pidfile} -d 10 $httpd
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
- }
- reload() {
- echo -n $"Reloading $prog: "
- if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
- RETVAL=$?
- echo $"not reloading due to configuration syntax error"
- failure $"not reloading $httpd due to configuration syntax error"
- else
- killproc -p ${pidfile} $httpd -HUP
- RETVAL=$?
- fi
- echo
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status -p ${pidfile} $httpd
- RETVAL=$?
- ;;
- restart)
- stop
- start
- ;;
- condrestart)
- if [ -f ${pidfile} ] ; then
- stop
- start
- fi
- ;;
- reload)
- reload
- ;;
- graceful|help|configtest|fullstatus)
- $apachectl $@
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
- exit 1
- esac
- exit $RETVAL
- # chmod +x /etc/rc.d/init.d/httpd 为此脚本赋予执行权
- # chkconfig --add httpd 加入服务列表:
- #tar -zxvf mod_fastcgi-current.tar.gz
- #cd mod_fastcgi
- #cp Makefile.AP2 Makefile
- #Vim Makefile 修改top_dir=/usr/local/apache #你的apache安装路径
- #make
- #make install
- 增加: LoadModule fastcgi_module modules/mod_fastcgi.so
- 有的话不用添加。
- ScriptAlias /cgi-bin/ "/usr/local/php/bin/"
- FastCgiExternalServer /usr/local/php/bin/php-fpm -host 172.16.2.3:9000
- AddType application/x-httpd-php .php
- AddHandler php-fastcgi .php
- Action php-fastcgi /cgi-bin/php-fpm
- <Directory "/usr/local/php/bin/">
- Options -Indexes FollowSymLinks +ExecCGI
- Order allow,deny
- Allow from all
- </Directory>
- Redhat5.8默认已经安装好了NFS,直接配置即可
- vim /etc/exports
- /usr/local/apadhe/htdocs 172.16.0.0/16(rw,no_root_squash)
- 保存退出
- #exportfs -arv 使其配置生效
- #unzip Discuz_7.2_FULL_SC_GBK.zip -d /usr/local/apadhe/htdocs 解压缩
- #cd /usr/local/apadhe/htdocs
- # ls
- index.php readme upload utilities 只要upload 其他三个不要
- # rm -rf index.php readme/ utilities/
- # mv upload/* ./ 把upload 目录下的所有网页文件 移动到当前目录下
- http://www.magedu.com/install/ 第一次 要安装一下 安装时指定数据库的服务器时
- 写入172.16.2.3 既是server 3 的IP
- Mount -t nfs 172.16.2.1:/usr/local/apadhe/htdocs /usr/local/apadhe/htdocs
- 挂载同一个网页文件,是两个web服务访问页面一样
- #yum -y install bind97 bind97-devel bind97-libs bind97-utils
- #vim /etc/named.conf
- options {
- directory "/var/named";
- };
- zone "." IN {
- type hint;
- file "named.ca";
- };
- zone "localhost.localdomain" IN {
- type master;
- file "named.localhost";
- allow-update { none; };
- };
- zone "localhost" IN {
- type master;
- file "named.localhost";
- allow-update { none; };
- };
- zone "test.com." IN {
- type master;
- file "test.com.zone";
- allow-update { none; };
- };
- # vim test.com.zone
- $TTL 600
- @ IN SOA ns.test.com. admin.test.com. (
- 0 ; serial
- 1D ; refresh
- 1H ; retry
- 1W ; expire
- 3H ) ; minimum
- IN NS ns.test.com.
- ns IN A 172.16.2.1
- www IN A 172.16.2.1
- www IN A 172.16.2.2
- 配置两条A记录,实现轮询
- 修改区域文件的数组 为named
- #fdisk /dev/sda 创建分区 t 调整类型为8e
- #partprobe /dev/sda
- #pvcreate /dev/sda{5,6}
- #vgcreate myvg /dev/sda{5,6}
- #lvcreate -L 5G -n mydata myvg
- #mke2fs -j -L MYDATA /dev/myvg/mydata
- #mkdir /data
- #vim /etc/fstab 开机自动挂载
- #mkdir /data/mysql 存mysql的数据
- #chown mysql:mysql /data/mysql/
- # tar xf mysql-5.5.24-linux2.6-i686.tar.gz -C /usr/local
- #cd /usr/local
- # ln -sv mysql-5.5.24-linux2.6-i686 mysql 创建连接 方便以后升级
- #cd mysql
- # chown -R mysql:mysql . 修改当前目录下所有文件的属主 数组 为mysql
- 手动初始化
- # scripts/mysql_install_db --datadir=/data/mysql/ 指定数据存放位置
- --user=mysql指定用户
- # cd /usr/local/mysql
- # cp support-files/my-large.cnf /etc/my.cnf
- thread_concurrency = 2 修改为你的CPU个数乘以2
- datadir=/data/mysql 写入 数据存放位置
- # cd /usr/local/mysql
- # cp support-files/mysql.server /etc/rc.d/init.d/mysqld
- # chkconfig --add mysqld 添加至服务列表:
- # chkconfig mysqld on
- 输出mysql的man手册至man命令的查找路径:
- #vim /etc/man.config
- MANPATH /usr/local/mysql/man 添加
- 输出mysql的头文件至系统头文件路径/usr/include:
- # ln -sv /usr/local/mysql/include /usr/include/mysql
- 输出mysql的库文件给系统库查找路径:
- # echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
- # ldconfig 让系统重新载入系统库:
- 修改PATH环境变量,让系统可以直接使用mysql的相关命令。
- # vim /etc/profile
- PATH=/usr/local/mysql/bin:$PATH
- # export PATH=/usr/local/mysql/bin:$PATH 立即生效
- # tar xf php-5.4.4.tar.bz2
- # cd php-5.4.4
- # ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql
- --with-openssl --enable-fpm --enable-sockets --enable-sysvshm
- --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring
- --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir
- --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt
- --with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php
- --with-bz2 --with-curl --with-libevent-dir=/usr/local/libevent
- --enable-fpm 一启用mpm 也就是 以fastCGI的方式 和php 通信
- # make
- # make test
- # make intall
- 为php提供配置文件:
- # cp php.ini-production /etc/php/php.ini
- 为php-fpm提供Sysv init脚本,并将其添加至服务列表:
- # cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
- # chmod +x /etc/rc.d/init.d/php-fpm
- # chkconfig --add php-fpm
- # chkconfig php-fpm on
- # cp /usr/local/php4nginx/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
- 编辑php-fpm的配置文件:
- # vim /usr/local/php/etc/php-fpm.conf
- 配置pm.的相关选项为你所需要的值,
- pm.max_children = 50
- pm.start_servers = 5
- pm.min_spare_servers = 2
- pm.max_spare_servers = 8
- pid = /usr/local/php/var/run/php-fpm.pid 启用pid文件
- 接下来就可以启动php-fpm了:
- # service php-fpm start
- 使用如下命令来验正(如果此命令输出有中几个php-fpm进程就说明启动成功了):
- # ps aux | grep php-fpm
- 1. 配置DNS 时 一定要把区域文件的数组改为named,不然解析不到 ,这是我前几次做都失败
- 的原因,让我做的很崩溃。
- 2. 装discuz时 权限 不对,只要按它上面提示的,找到每一项修该一下
- 例如 # setfacl -m u:apache:rw config.inc.php 如果是目录就改为rwx
- 如果出现乱码 则 # vim /etc/httpd/conf/httpd.conf 默认语言
- #AddDefaultCharset UTF-8 注释掉这一行
- 3.安装完mysql 启动一直失败,一次是把 数据库重新初始化了一下也就是重新执行了一次
- # scripts/mysql_install_db --datadir=/data/mysql/ 还有可能就是端口被占用了
终于写完了,也算对自己有一个交代,不过实验做完了,却感觉问题越来越多了,总是想只是实际生活中是怎么做的,到底apache php mysql 是放在一台的