首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

Fedora13 x86_64环境上搭建 nginx 0.8.x + PHP 5.3.3 (php-fpm) + MySQL 5.5.3-m3 服务器

2012-07-31 
Fedora13 x86_64环境下搭建 nginx 0.8.x + PHP 5.3.3 (php-fpm) + MySQL 5.5.3-m3 服务器最近,有些朋友一

Fedora13 x86_64环境下搭建 nginx 0.8.x + PHP 5.3.3 (php-fpm) + MySQL 5.5.3-m3 服务器
最近,有些朋友一直在问怎么在Fedora13 x86_64环境下搭建 nginx 0.8.x + PHP 5.3.3 (php-fpm) + MySQL 5.5.3-3,编译过程总出错,不知道怎么办,这里分享一下我的经验,供需要的朋友交流经验。

一、获取相关开源程序:

yum -y install gcc gcc-c++ autoconf automake libtoolyum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers


二、下载程序源码包
mkdir -p /web/softcd /web/soft

wget http://nginx.org/download/nginx-0.8.52.tar.gz
wget?http://cn.php.net/get/php-5.3.3.tar.bz2/from/this/mirror
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.3-m3.tar.gz/from/http://mysql.he.net/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0
wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0
wget http://pecl.php.net/get/memcache-2.2.5.tgz
wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz
wget http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz


三、安装支持库
tar zxvf libiconv-1.13.1.tar.gzcd libiconv-1.13.1/./configure --prefix=/usr/localmakemake installcd ../tar zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8/./configuremakemake install/sbin/ldconfigcd libltdl/./configure --enable-ltdl-installmakemake installcd ../../tar zxvf mhash-0.9.9.9.tar.gzcd mhash-0.9.9.9/./configuremakemake installcd ../ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.laln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.soln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.aln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.laln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.soln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-configtar zxvf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8//sbin/ldconfig./configuremakemake installcd ../tar zxvf libevent-1.4.14b-stable.tar.gzcd cd libevent-1.4.14b-stable./configure --prefix=/usr/localmake && make install


四、安装MySQL

1、编译安装MySQL 5.5.3-m3
/usr/sbin/groupadd mysql/usr/sbin/useradd -g mysql mysqltar zxvf mysql-5.5.3-m3.tar.gzcd mysql-5.5.3-m3/./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrgmake && make installchmod +w /usr/local/webserver/mysqlchown -R mysql:mysql /usr/local/webserver/mysqlcd ../

2、创建MySQL数据库存放目录
mkdir -p /web/mysql/3306/data/mkdir -p /web/mysql/3306/binlog/mkdir -p /web/mysql/3306/relaylog/chown -R mysql:mysql /web/mysql/

3、以mysql用户帐号的身份建立数据表
/usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/web/mysql/3306/data --user=mysql

4、创建my.cnf配置文件
vi /data0/mysql/3306/my.cnf

输入以下内容:
[client]character-set-server = utf8port = 3306socket = /tmp/mysql.sock[mysqld]character-set-server = utf8replicate-ignore-db = mysqlreplicate-ignore-db = testreplicate-ignore-db = information_schemauser = mysqlport = 3306socket = /tmp/mysql.sockbasedir = /usr/local/webserver/mysqldatadir = /data0/mysql/3306/datalog-error = /data0/mysql/3306/mysql_error.logpid-file = /data0/mysql/3306/mysql.pidopen_files_limit = 10240back_log = 600max_connections = 5000max_connect_errors = 6000table_cache = 614external-locking = FALSEmax_allowed_packet = 32Msort_buffer_size = 1Mjoin_buffer_size = 1Mthread_cache_size = 300#thread_concurrency = 8query_cache_size = 512Mquery_cache_limit = 2Mquery_cache_min_res_unit = 2kdefault-storage-engine = MyISAMthread_stack = 192Ktransaction_isolation = READ-COMMITTEDtmp_table_size = 246Mmax_heap_table_size = 246Mlong_query_time = 3log-slave-updateslog-bin = /data0/mysql/3306/binlog/binlogbinlog_cache_size = 4Mbinlog_format = MIXEDmax_binlog_cache_size = 8Mmax_binlog_size = 1Grelay-log-index = /data0/mysql/3306/relaylog/relaylogrelay-log-info-file = /data0/mysql/3306/relaylog/relaylogrelay-log = /data0/mysql/3306/relaylog/relaylogexpire_logs_days = 30key_buffer_size = 256Mread_buffer_size = 1Mread_rnd_buffer_size = 16Mbulk_insert_buffer_size = 64Mmyisam_sort_buffer_size = 128Mmyisam_max_sort_file_size = 10Gmyisam_repair_threads = 1myisam_recoverinteractive_timeout = 120wait_timeout = 120skip-name-resolve#master-connect-retry = 10slave-skip-errors = 1032,1062,126,1114,1146,1048,1396#master-host = 192.168.1.2#master-user = username#master-password = password#master-port = 3306server-id = 1innodb_additional_mem_pool_size = 16Minnodb_buffer_pool_size = 512Minnodb_data_file_path = ibdata1:256M:autoextendinnodb_file_io_threads = 4innodb_thread_concurrency = 8innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 16Minnodb_log_file_size = 128Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120innodb_file_per_table = 0#log-slow-queries = /data0/mysql/3306/slow.log#long_query_time = 10[mysqldump]quickmax_allowed_packet = 32M


5、创建管理MySQL数据库的shell脚本
#!/bin/shmysql_port=3306mysql_username="admin"mysql_password="12345678"function_start_mysql(){printf "Starting MySQL...\n"/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/data0/mysql/${mysql_port}/my.cnf 2>&1 > /dev/null &}function_stop_mysql(){printf "Stoping MySQL...\n"/usr/local/webserver/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown}function_restart_mysql(){printf "Restarting MySQL...\n"function_stop_mysqlsleep 5function_start_mysql}function_kill_mysql(){kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')}if [ "$1" = "start" ]; thenfunction_start_mysqlelif [ "$1" = "stop" ]; thenfunction_stop_mysqlelif [ "$1" = "restart" ]; thenfunction_restart_mysqlelif [ "$1" = "kill" ]; thenfunction_kill_mysqlelseprintf "Usage: /data0/mysql/${mysql_port}/mysql {start|stop|restart|kill}\n"fi

6、赋予shell脚本可执行权限
chmod +x /data0/mysql/3306/mysql

7、启动MySQL
/data0/mysql/3306/mysql start

8、通过命令行登录管理MySQL服务器(提示输入密码时直接回车)
/usr/local/webserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock

9、输入以下SQL语句,创建一个具有root权限的用户(admin)和密码(12345678)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'sa';GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'sa';

10、停止MySQL
/web/mysql/3306/mysql stop


[b]五、安装PHP[\b]
1、编译PHP
tar zxvf php-5.2.14.tar.gzgzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1cd php-5.2.14/./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/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 --with-xmlrpc --enable-zip --enable-soapmake ZEND_EXTRA_LIBS='-liconv'make installcp php.ini-dist /usr/local/webserver/php/etc/php.inicd ../

[b]未完待续[\b]

热点排行