一、编译安装apache
- # tar xf apr-1.4.6.tar.bz2
- # cd apr-1.4.6
- # ./configure --prefix=/usr/local/apr
- # make && make install
- # tar xf apr-util-1.5.2.tar.bz2
- # cd apr-util-1.5.2
- # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
- # make && make install
- 编辑/etc/httpd/httpd.conf,添加如下行即可:
- PidFile "/var/run/httpd.pid" #此步骤是为了我们下一步的脚本使用的
- #!/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
- # chkconfig --level 35 httpd on
- # service httpd restart
- # vim /etc/profile.d/httpd.sh
- export PATH=$PATH:/usr/local/apache/bin
- # fdisk /dev/sda #创建一个20G的分区
- # partprobe /dev/sda #刷新重读
- # pvcreate /dev/sda6 #创建PV
- # vgcreate myvg /dev/sda6 #创建VG
- # lvcreate -n mydata -L 5G myvg #创建LV
- # mke2fs -j /dev/myvg/mydata #格式化为ext3
- # mkdir /mydata -pv #创建挂载点
- # vim /etc/fstab #修改为开机挂载
- # mount -a #挂载至挂载点
- # mkdir /mydata/data #创建一个数据存储目录
- # chown -R mysql.mysql /mydata/data/ #修改存储目录的属主属组
- # chmod o-rx /mydata/data/ #修改其他用户的读写权限
- # groupadd -r -g 306 mysql
- # useradd -g 306 -r -u 306 mysql
- # less INSTALL-BINARY #可以用来查看软件自带的安装说明
- # chown -R mysql.mysql /usr/local/mysql/* #修改安装文件的属主属组
- # chown -R mysql:mysql /mydata/data
- # tar xf mysql-5.6.10-linux-glibc2.5-i686.tar.gz -C /usr/local
- # cd /usr/local/
- # ln -sv mysql-5.6.10-linux-glibc2.5-i686 mysql
- # cd mysql
- # chown -R mysql:mysql . #修改文件的属主属组
- # scripts/mysql_install_db --user=mysql --datadir=/mydata/data
- # chown -R root .
- # cd support-files/
- # cp mysql.server /etc/init.d/mysqld
- # chmod +x /etc/init.d/mysqld
- 添加到服务启动列表中 # chkconfig --add mysqld # chkconfig mysqld on
- # cd /usr/local/mysql/support-files
- # cp my-default.cnf /etc/my.cnf
- # tar xf php-5.4.13.tar.bz2
- # cd php-5.4.13
- # ./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 --enable-fpm --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2
- # make
- # make install
- # 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/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
- # vim /usr/local/php/etc/php-fpm.conf
- 配置fpm的相关选项为你所需要的值,并启用pid文件(如下最后一行):
- pm.max_children = 50 #同时允许在线人数
- pm.start_servers = 5 #开始启动进程数
- pm.min_spare_servers = 5 #最少空闲进程数
- pm.max_spare_servers = 8 #最多空闲进程数
- pid = /usr/local/php/var/run/php-fpm.pid
- # netstat -tnlp | grep php-fpm
- tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 689/php-fpm
- <VirtualHost *:80>
- ServerName www.1.com
- DocumentRoot "/web/1.com"
- <Directory "/web/1.com">
- Options none
- AllowOverride none
- Require all granted
- </Directory>
- ProxyRequests Off
- ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/web/1.com/$1
- ErrorLog "/var/log/httpd/1.com/error_log"
- CustomLog "/var/log/httpd/1.com/access_log" combined
- </VirtualHost>
- <VirtualHost *:80>
- ServerName www.2.com
- <Directory "/web/2.com">
- Options none
- AllowOverride none
- Require all granted
- </Directory>
- ProxyRequests Off
- ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/web/2.com/$1
- DocumentRoot "/web/2.com"
- ErrorLog "/var/log/httpd/2.com/error_log"
- CustomLog "/var/log/httpd/2.com/access_log" combined
- </VirtualHost>
- # vim /etc/httpd/httpd.conf
- 1、添加如下二行
- AddType application/x-httpd-php .php
- AddType application/x-httpd-php-source .phps
- 2、定位至DirectoryIndex index.html
- 修改为:
- DirectoryIndex index.php index.html
- 充:Apache httpd 2.4以前的版本中,要么把PHP作为Apache的模块运行,要么添加一个第三方模块支持PHP-FPM实现。
- # tar xf xcache-3.0.1.tar.gz
- # cd xcache-3.0.1
- # /usr/local/php/bin/phpize
- # ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
- # make && make install
- 安装结束时,会出现类似如下行:
- Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/
- # mkdir /etc/php.d
- # cp xcache.ini /etc/php.d
- # service php-fpm restart
- 1, tar xvf phpMyAdmin-3.5.1-all-languages -C /www/a.com ##这里是网站目录下
- 2,cd /www/a.com/
- 3, mv phpMyAdmin-3.5.1-all-languages pma
- 4,cd pma
- 5,cp config.sample.inc.php config.inc.php
- 6,vim config.inc.php 添加随机数 大概在17行
- 7,mysqladmin -uroot password 'redhat'
- 8,登陆 www.1.com/pma