LAMP组合: httpd 2.4.2 + mysql-5.5.24 + php-5.3.14编译安装过程:(Red Hat Enterprise Linux Server release 5.8 )
- pvcreate /dev/sda5
- vgcreate myvg /dev/sda5
- lvcreate -L 10G -n mydata myvg
- mke2fs -j /dev/myvg/mydata
- mkdir /data
- vim /etc/fstab #开机自动挂载
- /dev/myvg/mydata /data ext3 defaults 0 0
- mount -a #自动挂载一下
- groupadd -r mysql
- useradd -r -g mysql mysql
- chown -R mysql.mysql /data/mydata
- tar xf mysql-5.5.28-linux2.6-i686.tar.gz -C /usr/local
- cd /usr/local
- ln -sv mysql-5.5.28-linux2.6-i686 mysql
- cd mysql
- chown -R mysql.mysql . #将当前目录中的所有文件属主属组改为mysql别少了最后的'.'哦
- scripts/mysql_install_db --user=mysql --datadir=/data/mydata #指定路径为/data/mydata 用户为mysql
- chown -R root . #将其属主再更改为root
- cp support-files/my-large.cnf /etc/my.cnf
- 修改thread_concurrency的值为你的cpu的个数的2倍,不并添加行数据库的路径
- thread_concurrency =2 #我的cpu个数为1
- datadir = /data/mydata
- cd /usr/local/mysql
- cp support-files/mysql.server /etc/rc.d/init.d/mysqld
- chmod +x /etc/rc.d/init.d/mysqld
- chkconfig --add mysqld
- chkconfig mysqld on
- vim /etc/mysql.sh
- PATH=$PATH:/usr/local/mysql/bin
- export PATH
- vim /etc/man.config找到MANPATH 添加如下行:
- MANPATH /usr/local/mysql/man
- ln -sv /usr/loal/mysql/include /usr/include/mysql
- vim /etc/ld.so.conf.d/mysql.conf
- /usr/local/mysql/lib
- ldconfig
- tar xf apr-1.4.6.tar.bz2
- cd apr-1.4.6
- ./congfigure --prefix=/usr/local/apr #指定安装路径
- make && make install
- tar xf apr-uitl-1.4.1.tar.bz2
- cd apr-util-1.4.1
- ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr #apr-util的安装依赖于apr,所以为其指定apr的路径
- make && make install
- tar xf httpd-2.4.3.tar.bz2
- cd httpd-2.4.3
- ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mpms-shared=all --with-mpm=prefork
- make && make install
- vim /etc/httpd/httpd.conf
- PidFile "/var/run/httpd.pid" #指定Pid文件的路径
- vim /etc/profile.d/apachectl
- PATH=$PATH:/usr/local/apache/bin
- export PATH
- 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
- rpm -ivh libmcrypt-2.5.7-5.el5.i386.rpm
- rpm -ivh libmcrypt-devel-2.5.7-5.el5.i386.rpm
- tar xf php-5.4.8.tar.bz2
- cd php-5.4.8
- ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
- make
- make test #进行安装测试 (建议在生成环境中使用)
- make install
- cp php.ini-production /etc/php.ini #我们是生产环境中使用,所以拷贝production的配置文件即可
- vim /etc/httpd/httpd.conf
- 1),在末尾处添加如下2行:指定所能够识别php的类型
- AddType application/x-httpd-php .php
- AddType application/x-httpd-php-source .phps
- 2),定位至DirectoryIndex index.html
- 修改:
- DirectoryIndex index.php index.html
- cd /usr/local/apache/htdocs
- mv index.html index.php
- vim index.php
- 添加:
- <?php
- phpinfo();
- ?>
- vim /etc/httpd/httpd.conf
- #DocumentRoot "/usr/local/apache/htdocs" 在前面加'#'将其注释掉
- Include /etc/httpd/extra/httpd-vhosts.conf #将虚拟主机这项启用起来
- <VirtualHost *:80>
- DocumentRoot "/web/test"
- ServerName www.test.com
- <Directory "/web/test">
- AllowOverride none
- Options none
- Require all granted
- </Directory>
- </VirtualHost>
- tar xf xcache-2.0.0.tar.gz
- cd xcache-2.0.0
- /usr/local/php/bin/phpize #生成php扩展模块
- ./configure --enable-xchahe --with-php-config=/usr/local/php-config #为其指定php的配置文件路径
- make && make install
- mkdir /etc/php.d
- cp xcache.ini /etc/php.d #xcache.ini 在当前目录下
- vim /etc/php.d/xcache.ini
- zend_extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
- touch tmp #将解压缩后的文件放在该文件中
- unzip Discuz_7.2_FULL_SC_GBK.zip > tmp
- cd upload
- mv * /web/test #将该目录下的文件全部移到/web/test下
- vim /etc/php.ini
- short_open_tag = On #这一项默认为off,将其启动
- [root@www ~]# cd /web/test
- [root@www test]# setfacl -m u:daemon:rw- config.inc.php
- [root@www test]# setfacl -m u:daemon:rwx attachments/
- [root@www test]# setfacl -m u:daemon:rwx forumdata/
- [root@www test]# setfacl -m u:daemon:rwx forumdata/cache/
- [root@www test]# setfacl -m u:daemon:rwx forumdata/templates/
- [root@www test]# setfacl -m u:daemon:rwx forumdata/threadcaches/
- [root@www test]# setfacl -m u:daemon:rwx forumdata/logs/
- [root@www test]# setfacl -m u:daemon:rwx uc_client/data/cache/