`

centos 下手动安装mysql,php,apache,zend,zlib

 
阅读更多

安装ncurses
# yum install ncurses-devel -y
# tar -zxvf ncurses-5.9.tar.gz
# ./configure
# make
# make install

安装 zlib包:

找到相应的下载地址:

http://sourceforge.net/projects/libpng/files/zlib/1.2.7/

$tar -xvzf zlib-1.2.3.tar.gz
$cd zlib-1.2.3.tar.gz
$./configure
$make

$make install 

 

 

安装mysql
tar zxvf mysql-3.23.58.tar.gz  
cd mysql-3.23.58 

#./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql 

 

./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql --with-extra-charsets=gbk,gb2312,utf8

make 

make install 

#prefix=/usr/local/mysql mysql安装的目标目录 

#sysconfdir=/etc my.ini配置文件的路径 

#localstatedir=/var/lib/mysql 数据库存放的路径 

 

安装php

 

yum install libxml2 libxml2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel libtool-ltdl-devel
tar -jxvf php-5.3.6.tar.bz2
cd php-5.3.6
#./configure --prefix=/usr/local/php -with-apxs2=/usr/local/httpd/bin/apxs --with-curl --with-mcry#pt --enable-mbstring

./configure --prefix=/usr/local/php -with-apxs2=/usr/local/httpd/bin/apxs  --with-mysql=/usr/local/mysql  --with-zlib
make && make install
这样报错:
configure: error: mcrypt.h not found. Please reinstall libmcrypt. 
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
#tar -zxvf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#LD_LIBRARY_PATH=/usr/local/lib ./configure
#make & make install

然后再安装PHP

有时候会出现这样的错误

Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/

解决方案:

rm -rf /usr/local/php/lib/php/.channels
/usr/local/php/bin/pecl update-channels

然后再安装PHP

 配置httpd.conf使支持 php

1.httpd.conf配置
(1)、以上全都正确后,会自动加入对php模块支持
# vi /usr/local/apache2/conf/httpd.conf
LoadModule php5_module modules/libphp5.so 
(2)、添加默认的文件格式
# vi /usr/local/apache2/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
(3)、添加默认的首页
DirectoryIndex index.html index.htm index.php
编写index.php
# vi /usr/local/apache2/htdocs/index.php
<?php
phpinfo();
?>
rm /usr/local/apache2/htdocs/index.html
同时移除原来的index.html
重启http服务
/usr/local/apache2/bin/apachectl restart

 

2. 安装 Apache
  2.1 拷贝 Apache 源码包(比如:httpd-2.2.3.tar.gz)到 /usr/local/src 目录下并安装
    #cd /usr/local/src
    #tar -zxvf httpd-2.2.3.tar.gz
    #cd httpd-2.2.3

    // 安装路径、提供DSO支持、支持地址重写功能
    #./configure --prefix=/usr/local/httpd --enable-module=so --enable-module=rewrite 
    #make && #make install

    #/usr/local/httpd/bin/apachectl start  // 启动 apache
    #/usr/local/httpd/bin/apachectl stop  // 停止 apache
    #/usr/local/httpd/bin/apachectl restart  // 重启 apache

复制php.ini-dist为php.ini,并存放到/usr/local/php目录下!
[root@localhost php-5.2.6]# cp php.ini-dist /usr/local/php/php.ini
编辑/usr/local/php/php.ini文件,找到如下的一行
;default_charset = "iso-8859-1"
在这行下面加一行
default_charset = "gb2312
//下边组合apache+php
vim httpd.conf
LoadModule php5_module        modules/libphp5.so 添加到前面

找到#AddType application/x-tar .tgz 这行,在下面加一行。前面不要加#号。

AddType application/x-httpd-php .php


找到下面一行在后面加上index.php,这表示网站的默认页也能够为index.php 

DirectoryIndex index.html index.html.var index.php 
让后我们顺手下个测试php的页面吧
编辑vi /usr/www/html/test.php写入

echo >> <?phpinfo();?> /usr/www/html/test.php即可,到此处php+apache安装成功 

 

安装zend

cd /usr/local/src       #转到指定目录

#下载Zend Opitimizer 3.3.3 (32位版)

wget http://soft.kwx.gd/module/ZendOptimizer-3.3.3-i386.tar.gz

#下载Zend Opitimizer 3.3.3 (64位版)

wget http://soft.kwx.gd/module/ZendOptimizer-3.3.3-x86_64.tar.gz

cd ZendOptimizer*

./install.sh

然后回车,第一要你输入zend安装路径,默认安装就可以了,然后输入php.ini的路径,和Apache控制实用程序(apachectl,这个我的路径是/usr/local/httpd/bin/apachectl).

然后一步步完成就可以了,不用重启apache.

值得注意的是:我填写php.ini的路径写错了,造成安装zend失败,如果不知道现在的PHP的配置文件具体位置的话 可以查看一下:

/usr/local/php/bin/php -i|grep php.ini

  安装完成后:/usr/local/php/bin/php -v 查看 php的详细信息,就可以看到正确的配置信息。

 

下面是mysql 的配置

mysql make完成后:

#groupadd mysql
  #useradd -g mysql mysql  (第一个mysql是组,第二个mysql是用户)
  #cd /usr/local/mysql
  #cp usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf (或cp /root/mysql-5.0.18
  /support-files/my-huge.cnf.sh /etc/my.cnf 网络上是写括号内的,但我试了不行#根据自己主机的情况复制my-*.cnf的一个,huge是应用于内存在2G以上的情况。)
  #bin/mysql_install_db --user=mysql #建立基本数据库,必须指明为mysql用户,只有这一步才能在usr/local/mysql下出现var目录。出现如下:
  Preparing db table
  Preparing host table
  Preparing user table
  Preparing func table
  Preparing tables_priv table
  Preparing columns_priv table
  Installing all prepared tables
  Unknown suffix '@' used for variable 'port' (value '@MYSQL_TCP_PORT@'
  080425  4:38:40 /usr/local/mysql/libexec/mysqld: Error while setting value '@MYSQL_TCP_PORT@' to 'port'
  Installation of grant tables failed!
  Examine the logs in /usr/local/mysql/var for more information.
  You can also try to start the mysqld daemon with:
  /usr/local/mysql/libexec/mysqld --skip-grant &
  You can use the command line tool
  /usr/local/mysql/bin/mysql to connect to the mysql
  database and look at the grant tables:
  shell> /usr/local/mysql/bin/mysql -u root mysql
  mysql> show tables
  Try 'mysqld --help' if you have problems with paths. Using --log
  gives you a log in /usr/local/mysql/var that may be helpful.
  The latest information about MySQL is available on the web at
  http://www.mysql.com
  Please consult the MySQL manual section: 'Problems running mysql_install_db',
  and the manual section that describes problems on your OS.
  Another information source is the MySQL email archive.
  Please check all of the above before mailing us!
  And if you do mail us, you MUST use the /usr/local/mysql/bin/mysqlbug script!
  # bin/mysqld_safe --user=mysql &  #出现如下提示:
  [1] 23095
  [root@localhost mysql]# Starting mysqld daemon with databases from /usr/local/mysql/var
  ###这样就停在这边,就是正常启动。如果想确认用下面命令
  # ps -aux |grep mysql
  Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
  root     23095  0.1  0.2  4408 1084 pts/1    S    04:44   0:00 /bin/sh bin/mysqld_safe --user=mysql
  mysql    23118  3.1  2.4 114464 12676 pts/1  Sl   04:44   0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --pid-file=/usr/local/mysql/var/localhost.localdomain.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock
  root     23128  0.0  0.1  5524  640 pts/1    R+   04:44   0:00 grep mysql
  ###这样表示有mysql进程
  #bin/mysql
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 1 to server version: 4.0.25-log
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql> quit
  Bye        ####只有mysql进程,这一步才能执行,因为最初mysql的root密码是空的,所以回车直接就进入。
  #bin/mysqladmin -uroot password 123456  (设置mysql的root密码为123456)
  #[root@Linux mysql]# bin/mysql -u root -p (用新的密码可以进去,表示设置root密码成功)
  Enter password:            (输入完新密码后变成如下:)
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 4 to server version: 4.0.25-log
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql>
  #bin/mysqld_safe &或/usr/local/mysql/share/mysql/mysql.server start 启动mysql
  #/usr/local/mysql/share/mysql/mysql.server stop 停止mysql
  #ps -aux|grep mysql查看进程
  #kill id号 ----这是杀mysql进程的,id号是在查看mysql进程里面看的到。
  我们来修改一下mysql的启动的方式,让它以系统守护进程的方式开户服务
  #cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld 这样下次就可以用/etc/init.d/mysqld start启动了
  # bin/mysql -uroot -p
  Enter password:
  ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
  这个是mysql没启动
  # /etc/init.d/mysqld start (或/usr/local/mysql/mysql/share/mysql.server start这样启动)
  # bin/mysql -uroot -p
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 2 to server version: 4.0.25-log
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql> show databases;
  +----------+
  | Database |
  +----------+
  | mysql    |
  | test     |
  +----------+
  2 rows in set (0.00 sec)
  mysql>
  #chkconfig --add mysqld 添加mysql为服务
  #chkconfig --del mysqld 删除mysql服务
  service mysqld restart    #重新启动服务查看是否生效
  chkconfig --list mysqld    #查看是否345运行级别都打开mysql
  完成!以上安装过程同样适用于mysql5的安装
  笔者发现mysql5版本在安装后即可直接使用mysql命令进入数据库,而在4版本系列中,mysql路径并没有放入系统环境变量中,输入mysql系统会报找不到这命令的错误,因此笔者擅自修改了环境变量,把mysql的路径添加进环境变量中去。
  修改profile文件,将mysql的路径添加到PATH变量中去。
  vi /etc/profile
  if ! echo $PATH | /bin/egrep -q "(^|: )$1($|: )" ; then
  if [ "$2" = "after" ] ; then
  PATH=$PATH: $1:/usr/local/mysql/bin
  else
  PATH=$1: $PATH:/usr/local/mysql/bin
  或
  编辑/etc/profile文件:
  vi /etc/profile
  在文件最后添加如下两行:
  PATH=$PATH:/usr/local/mysql/bin
  export PATH
  执行下面的命令使所做的更改生效:
  . /etc/profile
本篇文章来源于 黑基网-中国最大的网络安全站点 原文链接:http://www.hackbase.com/tech/2011-10-28/65455.html

 

 

 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics