cd /usr/local/src/
wget http://nginx.org/download/nginx-1.2.3.tar.gz
wget http://cn.php.net/distributions/php-5.3.16.tar.gz
wgethttp://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
(PHPlibmcrypt模块)
wget http://fossies.org/unix/www/gd-2.0.35.tar.gz(支持nginx伪静态)
wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz
安装pcre
tar xvf pcre-8.31.tar.gz
cd pcre-8.31
./configure --prefix=/usr/local/pcre
make && make install
安装Mysql
mkdir –p /data/mysql
tar xvf mysql-5.5.27.tar.gz
cmake . -DCMAKE-INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc
cd mysql-5.5.27
make
make install
cd ../mysql
cp ./support-files/my-huge.cnf /etc/my.cnf
vim /etc/my.cnf
cp ./support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
vim /etc/init.d/mysqld
./scripts/mysql_install_db --user=mysql
service mysqld start
vim /etc/profile
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
安装Nginx
cd ..
groupadd www
useradd -g www www -s /bin/false
tar xvf nginx-1.2.3.tar.gz
cd nginx-1.2.3
./configure--prefix=/usr/local/nginx\
--without-http_memcached_module\
--user=www--group=www\
--with-http_stub_status_module\
--with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.31
make&&makeinstall
vim /etc/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
chmod 775 /etc/init.d/nginx
chkconfig nginx on
chkconfig --add nginx
service nginx start
lsof -i:80
安装libmcrypt
cd ..
tar xvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make&&make install
cd ..
安装php
cd ..
mkdir –p /usr/local/php5/etc
tar xvf php-5.3.16.tar.gz
cd php-5.3.16
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd=/usr/local/gd --with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-freetype-dir=/usr/lib --with-iconf --with-zlib --enable-xml --enable-magic-quotes --enable-safe-mode-enable-bcmath--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets--with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt--with-curl --enable-ctype
make
makeinstall
cp /usr/local/src/php-5.3.16/php.ini-production ./php.ini
rm -rf /etc/php.ini
ln -s /usr/local/php5/etc/php.ini /etc/php.ini
cp /usr/local/src/php-5.3.16/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on
vim /etc/php.ini
找到:date.timezone=
改成:date.timezone = PRC 设置时区
找到:expose_php = on
改成:expose_php = off 不显示php版本信息
找到:short_open_tag = off
改成:short_open_tag = on 支持php短标签
vim /etc/init.d/php-fpm
user = www 设置运行php-fpm的用户
group = www 设置运行php-fpm的组
pid = run/php-fpm.pid
service php-fpm start
安装gd
cd /usr/local/src
cd gd-2.0.35
./configure –enabke-m4_pattern_allow –prefix=/usr/local/gd –with-jpeg=/usr/lib –with-png=/usr/lib –with-xpm=/usr/lib –with-freetype=/usr/lib –with-fontconfig=/usr/lib
make &&make install