mysql的安装:

./configure \

--prefix=/application/mysql5.1.72 \

--with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock \

--localstatedir=/application/mysql5.1.72/data \

--enable-assembler \

--enable-thread-safe-client \

--with-mysqld-user=mysql \

--with-big-tables \

--without-debug \

--without-pthread \

--enable-assembler \

--with-extra-charsets=complex \

--with-readline \

--with-ssl \

--with-embedded-server \

--enable-local-infile \

--with-plugins=partition,innobase \

--with-mysqld-ldflags=-all-static \

--with-client-ldflags=-all-static

#--with-plugin-PLUGIN \

 

安装时会报错找不到curses包,所以yum install ncurses-devel

 

cat x.txt |bash 可以把编译源码放到文件里,然后交给bash执行

/etc/my.cnfmysql默认的配置文件路径

ln -s /application/mysql5.1.27 /application/mysql

mkdir /application/mysql/data -p

chown -R mysql.mysql /application/mysql/

cp /home/weipeng/tools/mysql5.1.27/support-files/my-small.cnf /etc/my.cnf

然后初始化数据库:

/application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql

 

*初始化完成后可按照提示有如下两种方式启动,但一旦选择一种另外一种就不能用了,切记。

一、(mysql软件文件夹里有mysql启动的脚本,将其加入到启动项即可启动,操作如下:

1.cp /home/weipeng/tools/mysql5.1.27/support-files/mysql.server  /etc/init.d/mysqld

2.basedir=/application/mysql/  datadir=/application/mysql/data添加到/etc/init.d/mysqld里。

3.然后加入chkconfig 开启onchkconfig --add mysqld chkconfig mysqld on

chmod +x /etc/init.d/mysqld)

 

二、或者用/application/mysql/bin/mysqld_safe &启动,如果报锁错误,可如下操作:

chown mysql.mysql /application/mysql5.1.72/tmp/ 然后kill 进程 ,重启mysql即可。

 

 

vi /etc/profile在最后加入以下:

PATH=$PATH:/application/mysql/bin

source /etc/profile

 

然后mysql直接就可以进入,可以show databases

mysqladmin shutdown是关闭mysql的方式,不要强行kill

 

添加用户名及密码:/application/mysql/bin/mysqladmin -u root password weipeng

mysql -uroot -pweipeng即可登陆

drop database test;

select user,host from mysql.user;

select user();

drop user ""@localhost;

 

开始安装php

检查安装php所需lib

rpm -qa zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel

安装:

yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel -y

还有一个包安装不少,通过如下方式解决:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

tar xf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure --prefix=/usr/local/libiconv

make&&make install

 

安装php

./configure \

--prefix=/application/php5.3.27 \

--with-apxs2=/application/apache/bin/apxs \

--with-mysql=/application/mysql \

--with-xmlrpc \

--with-openssl \

--with-zlib \

--with-freetype-dir \

--with-gd \

--with-jpeg-dir \

--with-png-dir \

--with-iconv=/usr/local/libiconv \

--enable-short-tags \

--enable-sockets \

--enable-zend-multibyte \

--enable-soap \

--enable-mbstring \

--enable-static \

--enable-gd-native-ttf \

--with-curl \

--with-xsl \

--enable-ftp \

--with-libxml-dir

 

make&&make install

 

configure: error: Cannot find OpenSSL's <evp.h>会报错

yum install openssl* -y

configure: error: Please reinstall the iconv library.

yum install iconv*

ls /home/weipeng/tools/php-5.3.27/php.ini*底下会有两个文件:

/home/weipeng/tools/php-5.3.27/php.ini-development 开发用的配置文件,会打开很多测试开关。

/home/weipeng/tools/php-5.3.27/php.ini-production  实际生产用的

 

cp php.ini-production  /application/php/lib/php.ini

然后让php能解析apachevi /application/apache/conf/httd.conf

311gg行添加如下两行:

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

 

由于是对外提供网站服务,需要修改配置文件里的用户名和组,默认是daemon,***都知道,所以先自己添加用户useradd www -s /sbin/nologin -M,所以需要修改:比如用户和组都是www,当然需要添加:

User www

Group www

然后:

chown -R  /application/apache

还需在httpd.conf里修改首页文件166gg加入index.php:

<IfModule dir_module>

    DirectoryIndex index.php index.html

</IfModule>

 

/application/apache/htdocs下添加index.php,vi index.php:

<?php

  phpinfo();

?>

后重启apache先检查语法:/application/apache/bin/apachectl -t

再重启:/application/apache/bin/apachectl graceful

 

成功解析phpinfo后,工作场景要尽快删除,因为phpinfo展示了所有的目录的安装相关内容。

测试本机与本机mysql连通通过php解析脚本:

<?php

  $link_id=mysql_connect('localhost','root','weipeng') or mysql_error();

 

  if($link_id){

          echo "mysql successful by weipeng,you are very good!";

  }else{

          echo mysql_error();

  }

?>