2014-03-22 17:00:02
来 源
kejihao
Nginx
本文介绍Llinux系统配置NginxPHP(fastcgi)MySQLWEB服务环境,希望对于初学Nginx服务器相关的朋友有帮助,更多Nginx安装、配置、报错处理等资源请本站内搜索。。
本文主要是配置nginx+php(fastcgi)   

ESX4虚拟机环境:

  Redhat 5.4 x32

  CPU: i5 E2300 2.8G 4核

  内存:2GB

  

安装顺序:

  1、libiconv-1.14.tar.gz

  2、libmcrypt-2.5.8.tar.gz

  3、mhash-0.9.9.9.tar.bz2

  4、mcrypt-2.6.8.tar.gz

  5、cmake-2.8.4.tar.gz

  6、mysql-5.5.13.tar.gzl

  7、php-5.3.6.tar.bz2 (pdo-mysql,php-pfm已经被加到里面去了)

  8、memcached-1.4.6.tar.gz

  9、eaccelerator-0.9.6.1.zip

  10、Imagemagick

  11、imagick-3.0.1.tgz

  12、pcre-8.02.tar.bz2

  13、nginx-1.0.5.tar.gz

  

假定所有包均已经下载:<这么多包,装起来头晕@_@!>

  一、安装所有包

  #install libiconv-1.1.4.tar.gz

  [[email protected] lnmp]# mkdir /usr/src/lnmp

  [[email protected] lnmp]# tar -xzf libiconv-1.14.tar.gz -C /usr/src/lnmp/

  [[email protected] lnmp]# cd /usr/src/lnmp/libiconv-1.14/

  [[email protected] libiconv-1.14]# mkdir /usr/local/lnmp

  [[email protected] libiconv-1.14]# ./configure --prefix=/usr/local/lnmp/libiconv

  [[email protected] libiconv-1.14]# make && make install

  #install libmcrypt-2.5.8.tar.gz

  [[email protected] lnmp]# tar -xzf libmcrypt-2.5.8.tar.gz -C /usr/src/lnmp/

  [[email protected] lnmp]# cd /usr/src/lnmp/libmcrypt-2.5.8/

  [[email protected] libmcrypt-2.5.8]# ./configure

  [[email protected] libmcrypt-2.5.8]# make && make install

  [[email protected] libmcrypt-2.5.8]# cd libltdl/

  [[email protected] libltdl]# ./configure --enable-ltdl-install

  #install mhash-0.9.9.9.tar.bz2

  [[email protected] lnmp]# tar -xjf mhash-0.9.9.9.tar.bz2 -C /usr/src/lnmp/

  [[email protected] lnmp]# cd /usr/src/lnmp/mhash-0.9.9.9/

  [[email protected] mhash-0.9.9.9]# ./configure

  [[email protected] mhash-0.9.9.9]# make && make install

  #install mcrypt

  [[email protected] lnmp]#tar -xzf mcrypt-2.6.8.tar.gz -C /usr/src/lnmp/

  [[email protected] lnmp]#cd /usr/src/lnmp/mcrypt-2.6.8/

  [[email protected] mcrypt-2.6.8]# ./configure

  *** Could not run libmcrypt test program, checking why...

  *** The test program compiled, but did not run. This usually means

  *** that the run-time linker is not finding LIBMCRYPT or finding the wrong

  *** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you'll need to set your

  *** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point

  *** to the installed location Also, make sure you have run ldconfig if that

  *** is required on your system

  ***

  *** If you have an old version installed, it is best to remove it, although

  *** you may also be able to get things to work by modifying LD_LIBRARY_PATH

  ***

  configure: error: *** libmcrypt was not found

  出现以上报错时,建立两个软连接就解决了。

  [[email protected] mcrypt-2.6.8]# ln -s /usr/local/lib/libmcrypt* /usr/lib/

  [[email protected] mcrypt-2.6.8]# ln -s /usr/local/lib/libmhash.* /usr/lib/

  [[email protected] mcrypt-2.6.8]# /sbin/ldconfig

  [[email protected] mcrypt-2.6.8]# make && make install

  #install cmake

  [[email protected] lnmp]# tar -xzf cmake-2.8.4.tar.gz -C /usr/src/lnmp/

  [[email protected] lnmp]# cd /usr/src/lnmp/cmake-2.8.4/

  [[email protected] cmake-2.8.4]# ./configure

  [[email protected] cmake-2.8.4]# make && make install

  mysql是我的弱项,相关编译方法参见http://heylinux.com/archives/993.html网友

  #install mysql

  [[email protected] ~]# useradd mysql

  [[email protected] ~]# mkdir -p /data/mysql

  [[email protected] ~]# chown -R mysql.mysql /data/mysql

  [[email protected] ~]# tar -xzf lnmp/mysql-5.5.13.tar.gz -C /usr/src/lnmp/

  [[email protected] ~]# cd /usr/src/lnmp/mysql-5.5.13/

  [[email protected] mysql-5.5.13]# cmake -DCMAKE_INSTALL_PREFIX=/data/mysql

  -DSYSCONFDIR=/opt/mysql/etc

  -DMYSQL_DATADIR=/opt/mysql/data

  -DMYSQL_TCP_PORT=3306

  -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock

  -DMYSQL_USER=mysql

  -DEXTRA_CHARSETS=all

  -DWITH_READLINE=1

  -DWITH_SSL=system

  -DWITH_EMBEDDED_SERVER=1

  -DENABLED_LOCAL_INFILE=1

  -DWITH_INNOBASE_STORAGE_ENGINE=1

  -DWITHOUT_PARTITION_STORAGE_ENGINE=1

  出现警告,可以忽略,对mysql没有影响。

  CMake Warning: The variable, 'MYSQL_USER', specified manually, was not used during the generation.

  CMake Warning: The variable, 'WITH_MEMORY_STORAGE_ENGINE', specified manually, was not used during the generation.

  [[email protected] mysql-5.5.13]# make

  [[email protected] mysql-5.5.13]# make install

  [[email protected] mysql-5.5.13]# mkdir /usr/local/mysql/{etc,log}

  [[email protected] mysql-5.5.13]# cp support-files/my-medium.cnf /usr/local/mysql/etc/my.cnf

  [[email protected] mysql-5.5.13]# chmod 755 scripts/mysql_install_db

  [[email protected] mysql-5.5.13]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --

  datadir=/usr/local/mysql/data/

  PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

  To do so, start the server, then issue the following commands:

  /usr/local/mysql//bin/mysqladmin -u root password 'new-password'

  /usr/local/mysql//bin/mysqladmin -u root -h svr1.labexam.com password 'new-password'

  Alternatively you can run:

  /usr/local/mysql//bin/mysql_secure_installation

  which will also give you the option of removing the test

  databases and anonymous user created by default. This is

  strongly recommended for production servers.

  See the manual for more instructions.

  You can start the MySQL daemon with:

  cd /usr/local/mysql/ ; /usr/local/mysql//bin/mysqld_safe &

  You can test the MySQL daemon with mysql-test-run.pl

  cd /usr/local/mysql//mysql-test ; perl mysql-test-run.pl

  Please report any problems with the /usr/local/mysql//scripts/mysqlbug script!

  #设置一个密码

  [[email protected] etc]# /usr/local/mysql/bin/mysqladmin -u root password 'redhat'

  [[email protected] etc]# /usr/local/mysql/bin/mysqld_safe &

  #启来了

  [[email protected] etc]# lsof -i:3306

  COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME

  mysqld 7123 mysql 10u IPv6 TCP *:mysql (LISTEN)

  #登录mysql

  [[email protected] etc]# /usr/local/mysql/bin/mysql -u root -p -S /tmp/mysql.sock

  Enter password: redhat

  Welcome to the MySQL monitor. Commands end with ; or g.

  Your MySQL connection id is 4

  Server version: 5.5.13 Source distribution

  Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

  Oracle is a registered trademark of Oracle Corporation and/or its

  affiliates. Other names may be trademarks of their respective

  owners.

  Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

  mysql> GRANT ALL PRIVILEGES ON *.* TO [email protected]' IDENTIFIED BY 'redhat';

  Query OK, 0 rows affected (0.00 sec)

  添加admin用户并设置密码

  mysql> GRANT ALL PRIVILEGES ON *.* TO '' IDENTIFIED BY 'redhat';

  Query OK, 0 rows affected (0.00 sec)

  mysql> use mysql;

  Reading table information for completion of table and column names

  You can turn off this feature to get a quicker startup with -A

  Database changed

  mysql> select Host,User,Password from user; #查看所有用户,密码情况

  +------------------+-----------------+------------ -------------------------------+

  | Host | User | Password |

  +------------------+-----------------+------------ -------------------------------+

  | localhost | root | *84BB5DF4823DA319BBF86CA198E6EEE9 |

  | svr1.labexam.com | root | |

  | 127.0.0.1 | root | |

  | ::1 | root | |

  | localhost | | |

  | svr1.labexam.com | | |

  | % | [email protected] | *84BB5DF4823DA319BBF86CA198E6EEE9 |

  | % | | *84BB5DF4823DA319BBF86CA198E6EEE9 |

  +------------------+-----------------+------------ -------------------------------+

  8 rows in set (0.00 sec)

  mysql> delete from user where password=""; #删除所有空密码的用户

  Query OK, 5 rows affected (0.00 sec)

  mysql> flush privileges;

  Query OK, 0 rows affected (0.00 sec)

  mysql> select Host,User,Password from user; #确认删除情况

  +-----------+-----------------+------------------- ------------------------+

  | Host | User | Password |

  +-----------+-----------------+------------------- ------------------------+

  | localhost | root | *84BB5DF4823DA319BBF86CA198E6EEE9 |

  | % | [email protected] | *84BB5DF4823DA319BBF86CA198E6EEE9 |

  | % | | *84BB5DF4823DA319BBF86CA198E6EEE9 |

  +-----------+-----------------+------------------- ------------------------+

  3 rows in set (0.00 sec)

  mysql> exit

  #my.cnf文件暂未做任何修改。

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。