一.实验环境
OS: rhel5
web服务: nginx-1.8.0.tar.gz
数据库服务: mysql-5.6.25-linux-glibc2.5-i686.tar.gz
php: php-5.4.4.tar.bz2
xcache: xcache-3.0.4.tar.gz
二.安装nginx
1.#mount -r /dev/cdrom /media/cdrom
2.#yum -y install pcre-devel
3.#groupadd -g 108 nginx
4.#useradd -g 108 -u 108 -s /sbin/nologin nginx
5.#id nginx
6.#tar xf nginx-1.8.0.tar.gz
7.#cd nginx-1.8.0
8.#./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre
9.#make && make install
10.#vim /etc/rc.d/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`nginx -V 2>&1 | grep "configure arguments:" | sed ‘s/[^*]*--user=\([^ ]*\).*/\1/g‘ -`
options=`$nginx -V 2>&1 | grep ‘configure arguments:‘`
for opt in $options; do
if [ `echo $opt | grep ‘.*-temp-path‘` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|
configtest}"
exit 2
esac
11.#chmod a+x /etc/rc.d/init.d/nginx
12.#chkconfig --add nginx
13.#chkconfig nginx on
14.#service nginx start
二.安装mysql-5.6.25-linux-glibc2.5-i686.tar.gz
1.#mkdir /mydata/data -pv
2.#groupadd -r mysql
3.#useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
4.#chown -R mysql.mysql /mydata/data
5.#chmod o-rx /mydata/data
6.tar xf mysql-5.6.25-linux-glibc2.5-i686.tar.gz -C /usr/local
7.#cd /usr/local
8.#ln -sv mysql-5.6.25-linux-glibc2.5-i686 mysql
9.#cd mysql
10.#chown -R root.mysql ./*
11.#scripts/mysql_install_db --user=mysql --datadir=/mydata/data
12.#cp support-files/my-default.cnf /etc/my.cnf
13.#vim /etc/my.cnf
datadir = /mydata/data
innodb_file_per_table = YES
socket = /tmp/mysql.sock
14.#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
15.#chkconfig --add mysqld
16.#chkconfig mysqld on
17.#vim /etc/man.config
MANPATH /usr/local/mysql/man
18.#ln -sv /usr/local/mysql/include /usr/include/mysql
20.#echo ‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf
21.#ldconfig
22.#vim /etc/profile.d/mysqld.sh
export PATH=$PATH:/usr/local/mysql/bin
23.#source /etc/profile
24.#service mysqld start
三.安装php-5.4.44.tar.bz2
1.#yum -y groupinstall "X Software Development"
2.#rpm -ivh libevent-2.0.17-2.i386.rpm libevent-devel-2.0.17-2.i386.rpm
3.#rpm -ivh libmcrypt-2.5.8-4.el5.centos.i386.rpm libmcrypt-devel-2.5.8-4.el5.centos.i386.rpm
4.#rpm -ivh mhash-0.9.9-1.el5.centos.i386.rpm mhash-devel-0.9.9-1.el5.centos.i386.rpm mcrypt-2.6.8-1.el5.i386.rpm
5.#tar xf php-5.4.4.tar.bz2
6.#cd php-5.4.4
7.#./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 --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl
8. #make
9.#make test
10.#make install
11.#cp php.ini-production /etc/php.ini
12.#cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
13.#chmod +x /etc/rc.d/init.d/php-fpm
14.#chkconfig --add php-fpm
15.#chkconfig php-fpm on
16.#cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
17.#vim /usr/local/php/etc/php-fpm.conf
pm.max_children = 150
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pid = /usr/local/php/var/run/php-fpm.pid
18.#service php-fpm start
19.#vim /etc/nginx/nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
20.#vim /etc/nginx/fastcgi_params
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
21.#service nginx reload
四.安装xcache-3.0.4.tar.gz
1.#tar xf xcache-3.0.4.tar.gz
2.#cd xcache-3.0.4
3.#/usr/local/php/bin/phpize
4.#./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
5.#make && make install
6.#mkdir /etc/php.d
7.#cp xcache.ini /etc/php.d
8.#touch /tmp/xcache
9.#chmod 777 /tmp/xcache
10.#echo -n "redhat" | md5sum
11.#cp -r /source/xcache-3.0.4/htdocs /usr/html/xcache
12.#chown root.root -R /usr/html/xcache
13.#vim /etc/php.d/xcache.ini
xcache.admin.user = "xcache"
xcache.admin.pass = "e2798af12a7a0f4f70b4d69efbc25f4d"
xcache.mmap_path ="/tmp/xcache"
14.#service php-fpm restart
15.#service nginx restart