斑竹网络专注为中小企业客户提供以管理服务为核心的IT全方位服务 https://www.sysadm.cn
分类: 系统运维
2013-12-20 10:12:36
mysql+nginx+resin安装
(时间:2010-4-6)
一、 Mysql 数据库的安装
# tar -zxvf mysql-5.1.42.tar.gz
# mkdir /mysql/data
./configure --prefix=/usr/local/server/mysql --sysconfdir=/usr/local/server/mysql/etc/my.cnf --datadir=/mysql/data --with-big-tables --with-plugins= partition,ftexample,archive,innodb_plugin,innobase,ndbcluster,myisam --with-ndb-test --with-mysqlmanager
# make
# make install
# mkdir /usr/local/server/mysql/etc
注意:
从mysql5.2开始innodb的引擎默认是不安装的,如果要使用这个上引擎就需要在安装编译是加 –with-plugins显示安装这个引擎,否这个引擎就不会安装的。
# cp /backup/software/mysql-5.1.42/support-files/my-medium.cnf /usr/local/server/mysql/etc/my.cnf
# mkdir /mysql/data/innodb
#./mysql_install_db --defaults-file=/usr/local/server/mysql/etc/my.cnf --basedir=/usr/local/server/mysql --datadir=/mysql/data --user=mysql --pid-file=/usr/local/server/mysql/var/mysql.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock
# cp /backup/software/mysql-5.1.42/support-files/mysql.server /etc/init.d/mysql
# chkconfig –add server
二、 Apache安装
# tar -zxvf httpd-2.2.11.tar.gz
# ./configure --prefix=/usr/local/apache --enable-modules=all --enable-isapi --enable-file-cache --enable-ext-filter --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer --enable-ssl --enable-cgi --enable-cgid --enable-so --enable-rewrite --enable-vhost-alias --enable-info --with-mpm=worker --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
# make
# make install
三、 PHP安装(带Fast-CGI支持)
a. 安装libiconv (这个软件包提供一个编码转换的动态库)
# tar -zxvf libiconv-1.13.1.tar.gz
# ./configure --prefix=/usr/local/libiconv
# make
# make install
b. 安装libmcrypt-2.5.8
# wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz
# tar -zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure
# make
# make install
# /sbin/ldconfig
# ./configure --enable-ltdl-instal
# make
# make install
c. 安装mhash 生成和访问hash数据的动态库
# wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
# tar -zxvf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9
# ./configure
# make && make install
# ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
# ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
# ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
# ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
# ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
# ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
# ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
d. 安装mcrypt 一个简单的加密程序
# wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz
# tar -zxvf mcrypt-2.6.8.tar.gz
# cd mcrypt-2.6.8
# /sbin/ldconfig
# ./configure
# make
# make install
e. 安装php-5.2.8
# wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.8.tar.gz
# tar -zxvf php-5.2.8.tar.gz
# wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.8-fpm-0.5.10.diff.gz
# gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1
# cd php-5.2.8
# ./configure --prefix=/usr/local/server/php --with-config-file-path=/usr/local/server/php/etc --with-mysql=/usr/local/server/mysql --with-mysqli=/usr/local/server/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-ldap --with-ldap-sasl
# make ZEND_EXTRA_LIBS='-liconv'
# make install
# cp php.ini-dist /usr/local/server/php/etc/php.ini
f. 安装memcache 内存共享缓充,一般用于集群上
# wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
# tar zxvf memcache-2.2.5.tgz
# cd memcache-2.2.5
# /usr/local/server/php/bin/phpize
# ./configure --with-php-config=/usr/local/server/php/bin/php-config
# make
# make install
g. 安装eaccelerator PHP的加速器
# wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.5.3.tar.bz2
# tar jxvf eaccelerator-0.9.5.3.tar.bz2
# cd eaccelerator-0.9.5.3
# /usr/local/server/php/bin/phpize
# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/server/php/bin/php-config
# make && make install
h. 安装PDO_MYSQL 为php提供了一个可以访问不同mysql 数据库版本的统一接口
# wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz
# tar zxvf PDO_MYSQL-1.0.2.tgz
# cd PDO_MYSQL-1.0.2
# /usr/local/server/php/bin/phpize
# ./configure --with-php-config=/usr/local/server/php/bin/php-config --with-pdo-mysql=/usr/local/server/mysql
# make && make install
i. 安装ImageMagic 支持对图片进行转化,修改的软件包,详情参看http://www.imagemagick.org/script/index.php网站
# wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
# tar -zxvf ImageMagick.tar.gz
# cd ImageMagick-6.5.1-2
# ./configure
# make && make install
j. 安装imagick 是PHP的一个扩展程序,它是默认的GD图象函数库的绝佳替代方案
# wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.2.2.tgz
# tar zxvf imagick-2.2.2.tgz
# cd imagick-2.2.2
# /usr/local/server/php/bin/phpize
# ./configure --with-php-config=/usr/local/server/php/bin/php-config
# make && make install
k. 修改php.ini文件
# vi /usr/local/server/php/etc/php.ini
修改
extension_dir = "./"
为
extension_dir = "/usr/local/server/php/lib/php/extensions/no-debug-non-zts-20060613"
并在其下添加:
extension = memcache.so
extension = pdo_mysql.so
extension = imagick.so
修改 output_buffering = Off 为output_buffering = On
l. 配置eAccelerator加速PHP
# mkdir -p /jongo/webdata/eaccelerator_cache
然后在/usr/local/server/php/etc/php.ini文件是最后添加下内容
[eaccelerator]
zend_extension="/usr/local/server/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/jongo/webdata/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
m. 修改/usr/local/server/php/etc/ php-fpm.conf文件
# useradd www
修改
Unix group of processes
在这里修改启动fpm的用户和组为www 否则在启动的时候提示如下错误:
Starting php_fpm Apr 23 13:53:45.285639 [ERROR] fpm_unix_conf_wp(), line 124: please specify user and group other than root, pool 'default'
其它的根据需要来调整相应的参数。
四、 Java resin 安装
安装java
rpm -ihv jdk-1_5_0_07-linux-i586.rpm
vi ~/.bash_profile
JAVA_HOME=/usr/java/jdk1.5.0_07
PATH=$PATH:$HOME/bin:/usr/local/server/mysql/bin:/usr/local/liconv/bin:$JAVA_HOME/bin
export PATH
export JAVA_HOME
五、 安装ngnix
# rpm -ihv pcre-4.5-3.i386.rpm
# rpm -ihv pcre-devel-4.5-3.i386.rpm
# tar -zxvf nginx-0.7.63.tar.gz
# cd nginx-0.7.63
#./configure --prefix=/usr/local/server/nginx --user=www --group=www --with-poll_module --with-http_ssl_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-pcre
# make
# make install
# vi /usr/local/server/nginx/conf/nginx.conf
修改nginx的配置文件,修改其中运行的用户帐号,并在http块中添加如下内容:
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
将server块里的location ~ \.php$ {里面修改成:
location ~ \.shtml$ {
root /jongo/webdata/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.shtml;
include fcgi.conf;
}
然后建立fcgi.conf文件,内容如下:
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;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
注意:
1、如果安装好后,没有任何错误提示,但是用游览器打开指定的页面,而显示为404找不到指定的页面时,则可能是上述的配置不正确造成的.
2、关于如果设定上面的这个参数,可以参见在线手册