Chinaunix首页 | 论坛 | 博客
  • 博客访问: 364353
  • 博文数量: 73
  • 博客积分: 2970
  • 博客等级: 少校
  • 技术积分: 1775
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-15 09:34
文章分类

全部博文(73)

文章存档

2011年(69)

2010年(4)

我的朋友

分类: LINUX

2011-04-07 10:21:27

我在本机安装Nginx时是采用的http://blog.licess.cn/lnmp/提供的一键安装包,这个虽然装起来很方便,但是里面的很多的配置,我都没有亲自去做,这样装了一遍下来,我对Nginx的安装还是不是非常的清楚。我通过查看它的安装脚本,以及网上的资料,整理了一套安装nginx的步骤。以下的内容主要根据我自己使用的实际情况来写的,有的是参考网上的内容来写成的。如您对此文有任何的问题或意见,可以留言给我,希望我们可以互相交流,共同进步!

 

一、软件下载:
    1、官网下载

以下为安装过程中可能需要的安装包
yum -y update
yum -y install patch make gcc gcc-c++ gcc-g77 flex bison
yum -y install libtool libtool-libs autoconf kernel-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel
yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
yum -y install glib2 glib2-devel bzip2
yum -y install bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs
yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
yum -y install openssl openssl-devel vim-minimal sendmail
yum -y install fonts-chinese scim-chewing scim-pinyin scim-tables-chinese

  2、从blog.s135.com下载(比较稳定,只允许在本站,或者在Linux/Unix下通过Wget、Curl等命令下载以下软件):
cd /usr/src
wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.15.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.10.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.10-fpm-0.5.11.diff.gz
wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.1.38.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-7.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.5.3.tar.bz2
wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.2.2.tgz

二、安装PHP 5.2.10(FastCGI模式)
  1、编译安装PHP 5.2.10所需的支持库:
tar -zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure --prefix=/usr/local
make
make install
cd ../

tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../

tar -zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../

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

tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../

  2、编译安装MySQL 5.1.38
tar -zxvf mysql-5.1.35.tar.gz
cd mysql-5.1.35
./configure --prefix=/usr/local/mysql --enable-assembler --with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all --without-isam
make;make install
cd ../
groupadd mysql
useradd -g mysql mysql
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/.
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --level 345 mysql on
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
echo "/usr/local/lib" >>/etc/ld.so.conf
ldconfig
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
service mysql start
/usr/local/mysql/bin/mysqladmin -u root password 123
service mysql restart
service mysql stop



  附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,则执行以下两步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下无需执行。

  ①、创建MySQL数据库存放目录
mkdir -p /data0/mysql/3306/data/
chown -R mysql:mysql /data0/mysql/

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

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


  输入以下内容: 

[client]
default-character-set = utf8
port    = 3306
socket  = /tmp/mysql.sock

[mysql]
prompt="(\u:blog.s135.com:)[\d]> "
no-auto-rehash

[mysqld]
#default-character-set = utf8
user    = mysql
port    = 3306
socket  = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data0/mysql/3306/data
open_files_limit    = 10240
back_log = 600
max_connections = 3000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 300
thread_concurrency = 8
query_cache_size = 32M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
default_table_type = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 1
log_long_format
log-bin = /data0/mysql/3306/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 512M
expire_logs_days = 7
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover

skip-name-resolve
master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

server-id = 1

innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2048M
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
[mysqldump]
quick
max_allowed_packet = 32M


  ④、创建管理MySQL数据库的shell脚本:

vi /data0/mysql/3306/mysql


  输入以下内容(这里的用户名root和密码123接下来的步骤会创建): 

  1. #!/bin/sh   
  2.   
  3. mysql_port=3306   
  4. mysql_username="root"  
  5. mysql_password="123"  
  6.   
  7. function_start_mysql()   
  8. {   
  9.     printf "Starting MySQL...\n"  
  10.     /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data0/mysql/${mysql_port}/my.cnf 2>&1 /dev/null &   
  11. }   
  12.   
  13. function_stop_mysql()   
  14. {   
  15.     printf "Stoping MySQL...\n"  
  16.     /usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown   
  17. }   
  18.   
  19. function_restart_mysql()   
  20. {   
  21.     printf "Restarting MySQL...\n"  
  22.     function_stop_mysql   
  23.     sleep 5   
  24.     function_start_mysql   
  25. }   
  26.   
  27. function_kill_mysql()   
  28. {   
  29.     kill -9 $(ps -ef grep 'bin/mysqld_safe' grep ${mysql_port} awk '{printf $2}')   
  30.     kill -9 $(ps -ef grep 'libexec/mysqld' grep ${mysql_port} awk '{printf $2}')   
  31. }   
  32.   
  33. if "$1" "start" ]; then   
  34.     function_start_mysql   
  35. elif "$1" "stop" ]; then   
  36.     function_stop_mysql   
  37. elif "$1" "restart" ]; then   
  38. function_restart_mysql   
  39. elif "$1" "kill" ]; then   
  40. function_kill_mysql   
  41. else  
  42.     printf "Usage: /data0/mysql/${mysql_port}/mysql {start|stop|restart|kill}\n"  
  43. fi  

 

  ⑤、赋予shell脚本可执行权限:

chmod +x /data0/mysql/3306/mysql

  ⑥、启动MySQL:
/data0/mysql/3306/mysql start

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

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

  ⑨、(可选)停止MySQL:
/data0/mysql/3306/mysql stop
阅读(915) | 评论(0) | 转发(1) |
0

上一篇:LNMP一键安装包

下一篇:Nginx安装笔记(二)

给主人留下些什么吧!~~