(ps:原来的版本是0.8.46,好几年前的一个版本,我在后面编译安装的时候出现了
src/core/ngx_resolver.c: In function ‘ngx_resolver_process_ptr’:
src/core/ngx_resolver.c:1425:43: error: variable ‘qclass’ set but not used
[-Werror=unused-but-set-variable]
src/core/ngx_resolver.c:1425:36: error: variable ‘qtype’ set but not used
[-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[1]: *** [objs/src/core/ngx_resolver.o] Error 1
make[1]: Leaving directory `/usr/local/src/nginx-1.0.0′
make: *** [build] Error 2这个错误,这应该是一个BUG,网上搜了下,说要这个打这个补丁,可是我打上了却没有用,换成这个最新的稳定版就顺利编译通过了)
make
make install #创建mysql用户
groupadd mysql
useradd -g mysql mysql #创建log和data文件夹 mkdir /usr/local/mysql/data/
mkdir /usr/local/mysql/log/
mkdir /usr/local/mysql/log/binlog
mkdir /usr/local/mysql/log/relaylog
chown -R mysql:mysql /usr/local/mysql/
#初始化数据表
/usr/local/mysql/bin/mysql_install_db –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data/ –user=mysql #编写mysql配置
vim /usr/local/mysql/my.cnf
#!/bin/sh
mysql_port=3306
mysql_username="root"
mysql_password="root"
function_start_mysql()
{
printf "Starting MySQL...n"
sudo /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf 2>&1 > /dev/null &
}
function_stop_mysql()
{
printf "Stoping MySQL...n"
sudo /usr/local/mysql/bin/mysqladmin -u${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown
}
function_restart_mysql()
{
printf "Restarting MySQL...n"
function_stop_mysql
sleep 5
function_start_mysql
}
if [ "$1" = "start" ]; then
function_start_mysql
elif [ "$1" = "stop" ]; then
function_stop_mysql
elif [ "$1" = "restart" ]; then
function_restart_mysql
elif [ "$1" = "kill" ]; then
function_stop_mysql
else
printf "Usage: mysql-server {start|stop|restart|kill}n"
fi #赋予可执行权限及启动mysql
chmod +x /etc/init.d/mysql
/etc/init.d/mysql start
#为刚刚在my.cnf中的root建立账户密码
/usr/local/mysql/bin/mysqladmin -u root password ‘root’ 2.编译安装PHP(FastCGI模式)
#首先安装编译时所需的工具及基本库
sudo apt-get install patch
sudo apt-get install libxml2-dev
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libjpeg62-dev
sudo apt-get install libpng12-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libsasl2-dev
sudo apt-get install autoconf
sudo apt-get install libperl-dev
然后编译安装PHP 5.2.14所需的支持库
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure –prefix=/usr/local
sudo make
sudo make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
sudo make
sudo make install
sudo /sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
sudo make
sudo make install
cd http://www.iyunv.com/
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
sudo make
sudo make install
cd ../
sudo ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
sudo ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
sudo ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
sudo ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
sudo ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
sudo ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
sudo ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
sudo ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
sudo ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
sudo ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
sudo /sbin/ldconfig
./configure
sudo make
sudo make install
cd ../
#编译安装fastcgi php
tar zxvf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
cd php-5.2.14/
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap
ps:(这边原来的编译选项里面有–with-ldap –with-ldap-sasl,可是加上这两个选项后会出现一个错误configure: error: LDAP build check failed. Please check config.log for more information. 这似乎是一个BUG,不知道怎么解决,无奈只能去掉这两个参数)
make ZEND_EXTRA_LIBS=’-liconv
(这步又遇到一个错误:undefined reference to `SSLv2_server_method’ ,参考了这篇文章,打上了这个补丁,终于顺利的过了)
make install
cp php.ini-dist /usr/local/php/etc/php.ini
#编译安装PHP5扩展模块
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make install
cd ../
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/usr/local/php/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make install
cd ../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql
sudo make
sudo make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
sudo make
sudo make install
cd ../
tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make install
cd ../
(这边原来要安装一个ghostscript,可是在make的时候出现
./base/time_.h:49:8: error: redefinition of ‘struct timeval’
/usr/include/i386-linux-gnu/bits/time.h:75:8: note: originally defined here
./base/gp_unix.c: In function ‘gp_get_realtime’:
./base/gp_unix.c:148:9: warning: implicit declaration of function ‘gettimeofday’ [-Wimplicit-function-declaration]
make: *** [obj/gp_unix.o] Error 1 找了下没找到解决方法,我又不知道有什么用,就把它给忽略了) #修改php.ini文件
vim /usr/local/php/etc/php.ini
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
sudo make
sudo make install
cd ../
sudo ln -s /usr/local/lib/libpcre.so.0 /usr/lib/libpcre.so.0
#安装Nginx
tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module
make
sudo make install
cd ../
#配置Nginx
vim /usr/local/nginx/conf/nginx.conf
user www www;
#开启的nginx进程个数
worker_processes 8;
error_log /usr/local/nginx/logs/error.log crit;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /usr/local/nginx/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main ’$remote_addr – $remote_user [$time_local] “$request” ‘