一、安装MySQL
Linux安装mysql——源码安装
一、mysql安装前准备工作
1.安装make编译器
make编译器下载地址:http://www.gnu.org/software/make/
(系统默认自带)查看自己的系统是否安装某个软件,如果已经有了,就不用在安装了,但是也有可能之前被卸载了。
如果你之前是使用rpm -ivh make装的,用
# rpm -qa | grep make肯定是能够找到的。
如果你是用
make && make install装的。那么最好直接去找执行程序,就知道有没装上去
# find / -name matlab
如果装了,它会告诉你执行程序被释放到哪个目录了。
++++++++++++++++++++++++++++++++++++++++++
# rpm -qa 是查看该软件是否被安装,# grep和# find是查看文件位置
++++++++++++++++++++++++++++++++++++++++++
# tar zxvf make-3.82.tar.gz
# cd make-3.82
# ./configure
# make
# make install
2.安装bison
bison下载地址:http://www.gnu.org/software/bison/
# tar zxvf bison-2.5.tar.gz
# cd bison-2.5
# ./configure
# make
# make install
3.安装gcc-c++
gcc-c++下载地址:http://www.gnu.org/software/gcc/
# tar zxvf gcc-c++-4.4.4.tar.gz
# cd gcc-c++-4.4.4
#./configure
# make
# make install
4.安装cmake (mysql5.5以后是通过cmake来编译的)
cmake下载地址:http://www.cmake.org/
# tar zxvf cmake-2.8.4.tar.gz
# cd cmake-2.8.4
#./configure
# make
# make install
5.安装ncurses
ncurses下载地址:http://www.gnu.org/software/ncurses/
# tar zxvf ncurses-5.8.tar.gz
# cd ncurses-5.8
#./configure
# make
# make install
或者:rpm -ivh ncurses-5.7-3.20090208.el6.x86_64.rpm
6.安装 ncurses-devel
rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
7、检查是否有已经安装过MySQL,如果有的话先卸载
查看是否有安装没卸载的版本 rpm -qa|grep -i MySQL
如果有强制卸载:rpm -e –nodeps 版本名称
二、开始安装MySQL
(1)MySQL5.5下载
MySQL5.5下载地址:http://dev.mysql.com/
这里我在这里下载的mysql-5.5.10.tar.gz
ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.5/
准备工作
(2)创建mysql的安装目录及数据库存放目录
[root@ rhel5~]#mkdir -p /usr/local/mysql //安装mysql
[root@ rhel5~]#mkdir -p /usr/local/mysql/data //存放数据库
(3)创建mysql用户及用户组
[root@ rhel5~]groupadd mysql
[root@ rhel5~]useradd mysql -g mysql -M -s /sbin/nologin
参数说明:
#增加一个名为 mysql的用户。
-g:指定新用户所属的用户组(group)
-M:不建立根目录
-s:定义其使用的shell,/sbin/nologin代表用户不能登录系统。
(4)安装mysql
[root@ rhel5 local]#tar zxvf mysql-5.5.10.tar.gz
[root@ rhel5 local]#cd mysql-5.5.10
[root@ rhel5 mysql-5.5.10]#cmake .
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data
-DSYSCONFDIR=/etc
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
-DMYSQL_TCP_PORT=3306
-DENABLED_LOCAL_INFILE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
(/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci)
[root@ rhel5 mysql-5.5.10]#make
[root@ rhel5 mysql-5.5.10]#make install
参数说明:
# cmake ./
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #安装路径
-DMYSQL_DATADIR=/usr/local/mysql/data \ #数据文件存放位置
-DSYSCONFDIR=/etc \ #my.cnf路径
-DWITH_MYISAM_STORAGE_ENGINE=1 \ #支持MyIASM引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ #支持InnoDB引擎
-DWITH_MEMORY_STORAGE_ENGINE=1 \ #支持Memory引擎
-DWITH_READLINE=1 \ #快捷键功能(我没用过)
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \ #连接数据库socket路径
-DMYSQL_TCP_PORT=3306 \ #端口
-DENABLED_LOCAL_INFILE=1 \ #允许从本地导入数据
-DWITH_PARTITION_STORAGE_ENGINE=1 \ #安装支持数据库分区
-DEXTRA_CHARSETS=all \ #安装所有的字符集
-DDEFAULT_CHARSET=utf8 \ #默认字符
-DDEFAULT_COLLATION=utf8_general_ci
注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# make clean
# rm -f CMakeCache.txt
# rm -rf /etc/my.cnf
2.配置
(1)设置目录权限
[root@ rhel5~]# cd /usr/local/mysql
[root@ rhel5 mysql]# chown -R root:mysql . //把当前目录中所有文件的所有者所有者设为root,所属组为mysql
[root@ rhel5 mysql]# chown -R mysql:mysql data
(2)设置mysql配置文件my.cnf
[root@ rhel5 mysql]# cp support-files/my-medium.cnf /etc/my.cnf //将mysql的启动服务添加到系统服务中
vi /etc/my.cnf
//加上以下内容
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/mysql_error.log
pid-file = /usr/local/mysql/mysql.pid
user = mysql
tmpdir = /tmp
(3)创建系统数据库的表
[root@ rhel5 mysql]# cd /usr/local/mysql
[root@ rhel5 mysql]# scripts/mysql_install_db –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data –user=mysql
(4)设置环境变量
[root@ rhel5~]# vi /root/.bash_profile
在PATH=$PATH:$HOME/bin添加参数为:
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
[root@ rhel5~]#source /root/.bash_profile
(5)手动启动mysql
[root@ rhel5~]# cd /usr/local/mysql
[root@ rhel5 mysql]# ./bin/mysqld_safe –user=mysql & //启动MySQL,但不能停止
启动日志写在此文件下:/usr/local/mysql/data/localhost.err
关闭MySQL服务
[root@ rhel5 mysql]# mysqladmin -u root -p shutdown //这里MySQL的root用户还没有配置密码,所以为空值。需要输入密码时,直接点回车键即可。
(6)另一种简单的启动mysql的方法(mysql已经被添加到系统服务中)
[root@ rhel5~]# service mysql.server start
[root@ rhel5~]# service mysql.server stop
[root@ rhel5~]# service mysql.server restart
如果上述命令出现:mysql.server 未识别的服务
则可能mysql还没添加到系统服务中,下面用另一种方法添加:
[root@ rhel5 mysql]# cp support-files/mysql.server /etc/init.d/mysql //将mysql的启动服务添加到系统服务中
注意:主要是将mysql.server拷贝到/etc/init.d中,命名为mysql。在有的系统中,mysql.server在/usr/local/mysql/share/mysql/mysql.server中,而本系统中,mysql.server在/usr/local/mysql/support-files/mysql.server中。
然后再用#service mysql start 来启动mysql即可。
(7)–注意这里,因为MySQL默认没有密码,所以这里我们没有输入密码就直接连上了。
–修改密码,这个是安装Server 中提示的:
[root@rac2 ~]# /usr/bin/mysqladmin -u root password root
[root@rac2 ~]# mysql
ERROR 1045 (28000): Access denied for user’root’@’localhost’ (using password: NO)
–修改密码之后,就提示要使用密码了。
[root@rac2 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.15 MySQL CommunityServer (GPL)
2.3.3 查看MySQL端口 3306, 这个是默认端口:
[root@rac2 ~]# netstat -nat|grep 3306
tcp 0 0 192.168.3.100:32842 192.168.3.100:3306 TIME_WAIT
tcp 0 0 :::3306 :::* LISTEN
(8)设置开机自启动
–查看MySQL 开机自启动设置:
[root@rac2 ~]# chkconfig –list |grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
这里的数字分别代表Linux启动的不同模式,3是命令行,5是窗口。
(9)关闭开机自启动
[root@rac2 ~]# chkconfig mysql off
[root@rac2 ~]# chkconfig –list |grep mysql
mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
(10)启用开机自启动:
[root@rac2 ~]# chkconfig mysql on
[root@rac2 ~]# chkconfig –list |grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@rac2 ~]#
(11)将Mysql 从chkconfig服务里删除:
[root@rac2 ~]# chkconfig –del mysql
[root@rac2 ~]# chkconfig –list |grep mysql
(12)将Mysql 添加到chkconfig里:
[root@rac2 ~]# chkconfig –add mysql
[root@rac2 ~]# chkconfig –list |grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
(13)修改MySQL的root用户的密码以及打开远程连接
[root@ rhel5~]# mysql -u root mysql
mysql>use mysql;
mysql>desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@”%” IDENTIFIED BY “root”; //为root添加远程连接的能力。
mysql>update user set Password = password(‘xxxxxx’) where User=’root’;
mysql>select Host,User,Password from user where User=’root’;
mysql>flush privileges;
mysql>exit
重新登录:mysql -u root -p
若还不能进行远程连接,则关闭防火墙
[root@ rhel5~]# /etc/rc.d/init.d/iptables stop
注意:如果不能远程连接,出现错误mysql error number 1130,则加入下面语句试试:
mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘******’ WITH GRANT OPTION;
三、MySQL的用户权限设置
首先要声明一下:一般情况下,修改MySQL密码,授权,是需要有mysql里的root权限的。
注:本操作是在WIN命令提示符下,phpMyAdmin同样适用。
用户:lamp 用户数据库:lampDB
用户所有的权限:
–权限1,权限2,…权限n代表select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限。
–当权限1,权限2,…权限n被all privileges或者all代替,表示赋予用户全部权限。
–当数据库名称.表名称被*.*代替,表示赋予用户操作服务器上所有数据库所有表的权限。
–操作完成每一项之后,想及时生效 执行flush privileges;
1.新建用户。
//登录MYSQL
@>mysql -u root -p
@>密码
//创建用户
mysql> CREATE USER ‘lamp’@’192.168.0.219’ IDENTIFIED BY ‘123456’;
//刷新系统权限表
mysql>flush privileges;
这样就创建了一个名为:lamp 密码为:123456 的用户。
然后登录一下。
mysql>exit;
@>mysql -u lamp -p
@>输入密码
mysql>登录成功
2.为用户授权。
//登录MYSQL(有ROOT权限)。我里我以ROOT身份登录.
@>mysql -u root -p
@>密码
//首先为用户创建一个数据库(lampDB)
mysql>create database lampDB;
//授权lamp用户拥有lamp数据库的所有权限。
>grant all privileges on lampDB.* to lamp@192.168.0.219 identified by ‘123456’ with grant option;;
//刷新系统权限表
mysql>flush privileges;
mysql>其它操作
/*
如果想指定部分权限给一用户,可以这样来写:
mysql>grant select,update on lampDB.* to lamp@192.168.0.219 identified by ‘123456’ with grant option;;
//刷新系统权限表。
mysql>flush privileges;
*/
3.删除用户。
@>mysql -u root -p
@>密码
mysql>DELETE FROM user WHERE User=’lamp’ and Host=’192.168.0.219′;
mysql>flush privileges;
//删除用户的数据库
mysql>drop database lampDB;
4.修改指定用户密码。
@>mysql -u root -p
@>密码
mysql>update mysql.user set password=password(‘新密码’) where User=’lamp’ and Host=’192.168.0.219′;
mysql>flush privileges;
5、删除某个用户
drop user 用户名@’%’;
drop user 用户名@ localhost;
6、取消某个用户的某些权限;
revoke insert,select,update,delete ON lampDB.* from ‘lap’@’192.168.0.219’ IDENTIFIED BY ‘123’;
7、取消用户所有权限:
revoke all on *.* from myroot@192.168.0.219;
8、增加某个用户的某些权限;
grant insert,select,update,delete on lampDB.* to lap@192.168.0.219 identified by ‘123456’ with grant option;
9、查询用户具有什么权限:
show grants for lap@192.168.0.219;
10、查询用户密码:
mysql密码是动态md5加密,是不可逆向查询的
修改用户密码:
update mysql.user set password=password(‘新密码’) where User=’test’ and Host=’localhost’;
11、运程用客户端连接MYSQL:
格式: mysql -h主机地址 -u用户名 -p用户密码
mysql -h 192.168.0.15 -u lap -p123456
通过dos窗口登陆MySQL,首先找到MySQL安装目录下的bin目录,格式如下:
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -h 192.168.0.15 -u lap -p123456
grant all privileges on auction.* to myroot@192.168.0.211 with grant option;
grant insert,select,update,delete,create on fund.* to myroot@192.168.0.210 with grant option;
update mysql.user set Host=’192.168.0.211′ where User=’myroot’;
flush privileges;
二、安装httpd-2.4.1.tar.gz
安装httpd时需要参数:
Optional Packages:
–with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
–without-PACKAGE do not use PACKAGE (same as –with-PACKAGE=no)
–with-included-apr Use bundled copies of APR/APR-Util
–with-apr=PATH prefix for installed APR or the full path to
apr-config
–with-apr-util=PATH prefix for installed APU or the full path to
apu-config
–with-pcre=PATH Use external PCRE library
–with-port=PORT Port on which to listen (default is 80)
–with-sslport=SSLPORT Port on which to securelisten (default is 443)
–with-z=DIR use a specific zlib library
–with-lua=PATH Path to the Lua 5.1 prefix
–with-serf=PREFIX Serf client library
–with-sslc=DIR RSA SSL-C SSL/TLS toolkit
–with-ssl=DIR OpenSSL SSL/TLS toolkit
–with-mpm=MPM Choose the process model for Apache to use by
default. MPM={simple|event|worker|prefork|winnt}
This will be statically linked as the only available
MPM unless –enable-mpms-shared is also specified.
–with-module=module-type:module-file
Enable module-file in the modules/<module-type>
directory.
–with-program-name alternate executable name
–with-suexec-bin Path to suexec binary
–with-suexec-caller User allowed to call SuExec
–with-suexec-userdir User subdirectory
–with-suexec-docroot SuExec root directory
–with-suexec-uidmin Minimal allowed UID
–with-suexec-gidmin Minimal allowed GID
–with-suexec-logfile Set the logfile
–with-suexec-safepath Set the safepath
–with-suexec-umask umask for suexec’d process
-1.安装前电脑上要装有g++,否则安装过程会出现错误。
0.下载httpd并解压
在解压后的文件夹里面有一个srclib文件夹,下面用到的apr, apr-util,pcre应该都在里面,要用这些安装,不要从网上下,因为可能出现版本不兼容的问题。如果srclib里面没有这些软件,那么在apache官网上找到httpd***deps***的压缩包,意思就是问安装httpd所用到的信赖文件,用里面的进行安装。如果这个包再没有,那就只能从网上下了。
1、安装apache apr
./configure –prefix=/usr/local/apr
make
make test
make install
注意:安装apr报错rm: cannot remove `libtoolT’: No such file or directory
直接打开/usr/local/src/apr-1.4.6/configure 把 $RM“$cfgfile” 那行删除掉
$RM“$cfgfile” 大约在 42302行
然后再重新运行 ./configure –prefix=/usr/local/apr 就可以了
网上说的其他解决办法如下,但我应用都不行:
#aclocal
# autoconf
# automake
# libtoolize –force
或者:
#autoreconf –force –install
# libtoolize –automake –force
# automake –force –add-missing
我是在Asianux Server 4 编译安装的,也可能跟我使用的系统有关
2、安装apr-util和apr-iconv
./configure –prefix=/usr/local/apr-util/ –with-apr=/usr/local/apr/bin/apr-1-config
make
make install
./configure –prefix=/usr/local/apr-iconv –with-apr=/usr/local/apr
make
make install
3、安装pcre
./configure –prefix=/usr/local/pcre –with-apr=/usr/local/apr/bin/apr-1-config
make
make install
4、安装 zlib-1.2.8.tar.gz
tar zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8.
./configure –prefix=/usr/local/zlib
make
make install
5、安装httpd(红色的配置是必须要配置的)
./configure –prefix=/usr/local/apache/httpd –with-apr=/usr/local/apr/ –with-apr-iconv=/usr/local/apr-iconv –with-apr-util=/usr/local/apr-util/bin/apu-1-config –with-pcre=/usr/local/pcre/bin/pcre-config
./configure –prefix=/usr/local/apache/httpd –with-z=/usr/local/zlib –with-apr=/usr/local/apr/ –with-apr-util=/usr/local/apr-util/bin/apu-1-config –with-pcre=/usr/local/pcre/bin/pcre-config –with-apr-iconv=/usr/local/apr-iconv –with-included-apr –disable-userdir –enable-so –enable-deflate=shared –enable-expires=shared –enable-rewrite=shared –enable-static-support
说明:
./configure –prefix=安装的目录
./configure \
> –prefix=/usr/local/apache/httpd \ //指定Apache软件安装的位置
> –with-z=/usr/local/zlib/ \ //指定zlib库文件的位置
> –with-apr=/usr/local/apr/
> –with-apr-util=/usr/local/apr-util/bin/apu-1-config
> –with-pcre=/usr/local/pcre/bin/pcre-config
> –with-apr-iconv=/usr/local/apr-iconv
> –with-included-apr \ //使用捆绑APR/APR-Util的副本
> –disable-userdir \ //请求的映象到用户特定目录
> –enable-so \ //以动态共享对象(DSO)编译
> –enable-deflate=shared \ //缩小传输编码的支持
> –enable-expires=shared \ //期满头控制
> –enable-rewrite=shared \ //基于规则的URL操控
> –enable-static-support //建立一个静态链接版本的支持
make
make install
6、安装apache2 , ./configure ;make;make install。安装完毕后却不能找到mod_proxy和mod_rewrite模块,主要原因是APACHE2.2默认的安装选项是最小化的安装,一些扩展模块在默认的状态下都没有被安装,如果需要要在./configure后用参数指定,比方要用到mod_proxy和mod_rewrite两个模块进行实验,所以命令行是:./configure –enable-mods-shared=’proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http proxy_rewrite’。这个配置不仅指定了这些模块,同时也默认安装其他最小项。这样配置完后make和make install后,mod_proxy和mod_rewrite两个模块都能找到了
另外在安装apache同时可以添加以下配置项
> –prefix=/usr/local/apache2 \ //指定Apache软件安装的位置
> –sysconfdir=/etc/httpd \ //指定Apache服务器的配置文件存放位置
> –with-z=/usr/local/zlib/ \ //指定zlib库文件的位置
> –with-included-apr \ //使用捆绑APR/APR-Util的副本
> –disable-userdir \ //请求的映象到用户特定目录
> –enable-so \ //以动态共享对象(DSO)编译
> –enable-deflate=shared \ //缩小传输编码的支持
> –enable-expires=shared \ //期满头控制
> –enable-rewrite=shared \ //基于规则的URL操控
> –enable-static-support //建立一个静态链接版本的支持
7、安装成功后配置apache
打开apache的配置文件
vi /usr/local/apache/httpd/conf/httpd.conf
部分配置项说明
(1)apache的安装目录
ServerRoot “当前的安装目录”
如:ServerRoot “/usr/local/apache/httpd”
(2)apache使用的端口
Listen端口[1-65535中的一任意一个,一般默认为80]
Listen 80
(3)服务器根目录即用户访问的目录
DocumentRoot “根目录”
DocumentRoot “/usr/local/apache/httpd/htdocs”
(4)服务器索引文件即默认返回给用户的文件
DirectoryIndex索引文件名
DirectoryIndex index.html index.php
8、修改文件的所有者和所有组
cd /usr/local/apache/httpd
chown -R nobody:root ./htdocs
9、修改apache下所有文件权限
cd /usr/local/apache/httpd
chmod -R 755 *
10、apache启动停止重启:
/usr/local/apache/httpd/bin/apachectl -f /usr/local/apache/httpd/conf/httpd.conf
/usr/local/apache/httpd/bin/apachectl start
/usr/local/apache/httpd/bin/apachectl stop
/usr/local/apache/httpd/bin/apachectl restart
/usr/local/apache/httpd/bin/apachectl -k start
/usr/local/apache/httpd/bin/apachectl -k stop
/usr/local/apache/httpd/bin/apachectl -k restart
好的关闭方式
/usr/local/apache/httpd/bin/apachectl -k stop
更好的关闭方式
/usr/local/apache/httpd/bin/apachectl -k graceful-stop
11、设置apache开机自动启动
vi /etc/rc.d/rc.local
在最后一行添加
/usr/local/apache/bin/apachectl start
也可以直接执行
echo “/usr/local/apache/bin/apachectl start” >> /etc/rc.d/rc.local
12、遇到问题解决办法:
解决apache启动错误”httpd:Could not reliably determine…”
启动apache遇到错误:httpd: Could not reliably determine the server’s fully qualified domain name
[root@server httpd-2.2.4]# /usr/local/apache/bin/apachectl start
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
1)进入apache的安装目录:(视个人安装情况而不同) [root@server ~]# cd /usr/local/apache/conf
2)编辑httpd.conf文件,搜索”#ServerName”,添加ServerName localhost:80
[root@server conf]# ls
extra httpd.conf magic mime.types original
[root@server conf]# vi httpd.conf
#ServerName www.example.com:80
ServerName localhost:80
3)再重新启动apache 即可。
[root@server ~]# /usr/local/apache/bin/apachectl restart
cd ..
<Directory “/”>
Options FollowSymLinks Includes
AllowOverride All
Order deny,allow
Allow from all
</Directory>
chown -R 755 * /usr/local/apache/httpd/htdocs/temp/caches/f/index_40F756F0.php
三、安装PHP
PHP之服务器环境搭建
安装软件准备
PHP和各个组件包
libxml2-2.6.30.tar.gz xml c语言版的解析器
libmcrypt-2.5.8.tar.gz 加密算法扩展库
zlib-1.2.3.tar.gz 压缩图像组件
gd-2.0.35.tar.gz 处理图片的API
autoconf-2.61.tar.gz 自动配置源代码的shell脚本
freetype-2.3.5.tar.gz 操作字体的函数库
libpng-1.2.26.tar.gz 解析PNG图象格式的库
jpegsrc.v6b.tar.gz
ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz zend加速器
1、安装libxml2-2.6.30.tar.gz
tar zxvf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure –prefix=/usr/local/libxml2
make
make install
如果安装成功以后,在/usr/local/libxml2/目录下将生成bin、include、lib、man和share五个目录。
2、安装libmcrypt-2.5.8.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8.tar.gz
./configure –prefix=/usr/local/libmcrypt
make
make install
如果安装成功就会在/usr/local/libmcrypt/目录下生成bin、include、lib、man和share五个目录。
3、安装zlib-1.2.3.tar.gz
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3.
./configure –prefix=/usr/local/zlib
make
make install
如果安装成功将会在/usr/local/zlib目录下生成include、lib和share三个目录。
4、安装libpng-1.2.26.tar.gz
tar zxvf libpng-1.2.26.tar.gz
cd libpng-1.2.26
./configure –prefix=/usr/local/libpng
make
make install
如果安装成功将会在/usr/local/libpng目录下生成bin、include、lib和share四个目录。
5、安装jpegsrc.v6b.tar.gz
mkdir /usr/local/jpeg7 \ //建立jpeg6的软件安装目录
mkdir /usr/local/jpeg7/bin \ //建立存放命令的目录
mkdir /usr/local/jpeg7/lib \ ///建立jpeg6库文件所在目录
mkdir /usr/local/jpeg7/include \ //建立存放头文件的目录
mkdir /usr/local/jpeg7/man/man1 \ //建立存放手册的目录
tar zxvf jpegsrc.v6b.tar.gz
ll
cd jpeg-6b
./configure -prefix=/usr/local/jpeg7 –enable-shared –enable-static
CFLAGS=”-O3 -fPIC” ./configure -prefix=/usr/local/jpeg7 –enable-shared –enable-static (如果64位处理器需要)
./configure –prefix=/usr/local/jpeg7 \ //在安装时将软件安装到/usr/local/jpeg6目录下
–enable-shared \ //建立共享库使用的GNU的libtool
–enable-static //建立静态库使用的GNU的libtool
make
make install
6、安装freetype-2.3.5.tar.gz
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure –prefix=/usr/local/freetype
make
make intall
安装(可选)
tar zxvf expat-2.1.0.tar.gz
cd expat-2.1.0
./configure –prefix=/usr/local/expat
make
make intall
tar zxvf fontconfig-2.3.2.tar.gz
cd fontconfig-2.3.2
./configure –prefix=/usr/local/fontconfig –with-freetype-config=/usr/local/freetype/bin/freetype-config –with-expat=/usr/local/expat
make
make intall
7、安装autoconf-2.61.tar.gz
tar zxvf autoconf-2.61.tar.gz
cd autoconf-2.61
./configure
make
make install
8、安装gd-2.0.35.tar.gz
tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure –prefix=/usr/local/gd2 -with-jpeg=/usr/local/jpeg7 -with-png=/usr/local/libpng -with-zlib=/usr/local/zlib2.3 -with-freetype=/usr/local/freetype –with-fontconfig=/usr/local/fontconfig
make
make install
./configure –prefix=/usr/local/gd2/ \
–with-zlib=/usr/local/zlib/ \ //指定到zlib库文件的位置
–with-jpeg=/usr/local/jpeg6/ \ //指定到jpeg6库文件的位置
–with-png=/usr/local/libpng/ \ //指定到png库文件的位置
–with-freetype=/usr/local/freetype //指定到freetype2字体库文件的位置
–with-fontconfig=/usr/local/fontconfig //字体库
注意:安装的时候出现错误
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory `/tmp/gd-2.0.26gif’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/gd-2.0.26gif’
make: *** [all] Error 2
[root@RHEL3 gd-2.0.26gif]#
解决方法
cd gd-2.0.35
vi gd_png.c
找到“png.h”改成“/usr/local/libpng/include/png.h”
需要复制/usr/local/libpng/include/目录下两个文件,
#cp /usr/local/libpng/include/pngconf.h /home/hao32/php/pk2/gd-2.0.33
#cp /usr/local/libpng/include/png.h /home/hao32/php/pk2/gd-2.0.33
9、php的安装
tar zxvf php-5.2.9.tar.gz
cd php-5.2.9.tar.gz
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-apxs2=/usr/local/apache/httpd/bin/apxs –with-mysql=/usr/local/mysql/ –with-libxml-dir=/usr/local/libxml2/ –with-png-dir=/usr/local/libpng/ –with-jpeg-dir=/usr/local/jpeg6/ –with-freetype-dir=/usr/local/freetype/ –with-gd=/usr/local/gd2 –with-zlib-dir=/usr/local/zlib/ –with-mcrypt=/usr/local/libmcrypt/ –with-mysqli=/usr/local/mysql/bin/mysql_config –enable-soap –enable-mbstring=all –enable-sockets
make
make test
make install
说明:
./configure \ //执行当前目录下软件自代的配置命令
> –prefix=/usr/local/php \ //设置PHP5的安装路径
> –with-config-file-path=/usr/local/php/etc \ //指定PHP5配置文件存入的路径
> –with-apxs2=/usr/local/apache/httpd/bin/apxs \ //告诉PHP查找Apache 2的地方
> –with-mysql=/usr/local/mysql/ \ //指定MySQL的安装目录
> –with-libxml-dir=/usr/local/libxml2/ \ //告诉PHP放置libxml2库的地方
> –with-png-dir=/usr/local/libpng/ \ //告诉PHP放置libpng库的地方
> –with-jpeg-dir=/usr/local/jpeg6/ \ //告诉PHP放置jpeg库的地方
> –with-freetype-dir=/usr/local/freetype/ \ //告诉PHP放置freetype库的地方
> –with-gd2=/usr/local/gd2 \ //告诉PHP放置gd库的地方
> –with-zlib-dir=/usr/local/zlib/ \ //告诉PHP放置zlib库的地方
> –with-mcrypt=/usr/local/libmcrypt/ \ //告诉PHP放置libmcrypt库的地方
> –with-mysqli=/usr/local/mysql/bin/mysql_config \ //变量激活新增加的MySQLi功能
> –enable-soap \ //变量激活SOAP和Web services支持
> –enable-mbstring=all \ //使多字节字符串支持
> –enable-sockets //变量激活socket通讯特性
10、修改phpdphp.ini
如果安装后在/usr/local/php/etc/目录下没有找到php.ini配置文件,可以在php源码包中复制php.ini-dist文件到/usr/local/php/etc/并改名为php.ini
cp php.ini-production /usr/local/php5/etc/php.ini #复制php配置文件到安装目录
rm -rf /etc/php.ini #删除系统自带的配置文件
ln -s /usr/local/php5/etc/php.ini /etc/php.ini #创建配置文件软链接
vi /usr/local/php5/etc/php.ini #编辑
找到:;open_basedir =
修改为:open_basedir = .:/tmp/ #防止php木马跨站,重要!!
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC
找到:expose_php = On
修改为:expose_php = OFF #禁止显示php版本的信息
找到:display_errors = On
修改为:display_errors = OFF #关闭错误提示
11、安装ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
cd ZendOptimizer-3.3.9-linux-glibc23-x86_64
cp ZendGuardLoader.so /usr/local/php/lib/
编辑PHP.INI
zend_extension=/usr/local/php/lib/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
Zend Guard Loader的发布,而且Zend Optimizer不会再更新,并且由于差异很大使用Zend Guard加密代码时将提示你是否使用php5.3,如果使用5.3那么代码就无法在php5.2上运行。
Zend Guard Loader安装说明
1。下载Zend Guard Loader包。(官方地址:http://www.zend.com/en/products/guard/downloads)
Linux:
x86:http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
x64:http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
Windows:
http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-Windows.zip
2. 并提取ZendGuardLoader.so(Linux)或ZendLoader.dll(Windows)上传到服务器。
3. 加载ZendGuardLoader,配置PHP.INI
例子:
zend_extension=C:\web\PHP\ext\ZendLoader.dll
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
下面逐一说明:
注意windows版的只支持NTS(非线程安全)版的PHP5.3,即phpinfo中Thread Safety为disabled的!
在你的php.ini文件中添加以下行:
Linux和Mac OS X:zend_extension=<ZendGuardLoader.so的绝对路径>
Windows的非线程安全的:zend_extension=<ZendLoader.dll的绝对路径>
4. 添加下面这行加载ZendGuardLoader:
;启用加载编码脚本。默认开启
zend_loader.enable=1
5. 可选:配置ZendGuardLoader
;禁用检查授权(出于性能原因)
zend_loader.disable_licensing=0
;配置混淆水平 0 – 不支持混淆
zend_loader.obfuscation_level_support=3
;配置寻找授权文件的路径
zend_loader.license_path=
6. 如果你同时使用Zend debugger,请保证加载Zend guard Loader后再加载Zend debugger
7. 如果你同时使用Ioncube loader,请保证加载Ioncube loader后再加载Zend guard Loader
8. 重启Web服务。
如果在phpinfo中看到如下内容(不同的版本可能会有所不同):
This program makes use of the Zend Scripting Language Engine:Zend Engine v2.4.0, Copyright (c) 1998-2011 Zend Technologies
说明安装已经成功!
12、修改Apache配置文件 httpd.conf
需要修改Apache配置文件,添加PHP的支持,告诉Apache将哪些后缀作为PHP解析。例如,让Apache把.php或.phtml后缀的文件解析为PHP。使用vi打开Apache的配置文件/etc/httpd/httpd.conf,找到“AddType application/x-gzip.gz.tgz”指令项,并在其下方添加一条指令“Addtype application/x-httpd-php .php .phtml”。也可以将任何后缀的文件解析为PHP,只要在添加的语句中加入并用空格分开,这里以多添加一个.phtml来示例。
vi /etc/httpd/httpd.conf
If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在这行下面添加
Addtype application/x-httpd-php .php .phtml #添加这一条
#添这一个是为了将.phps作为PHP的源文件进行语法高亮显示
Addtype application/x-httpd-php-source .phps
# AddHandler allows you to map certain file extensions to “handlers”:
# actions unrelated to filetype. These can be either built into the server
13、对apache进行重启
修改apache的配置文件后,需要重启服务器才能重新加载修改后的配置文件
/usr/local/apache/httpd/bin/apachectl stop
/usr/local/apache/httpd/bin/apachectl start
14、安装成功
环境搭建完毕!
15、测试php是否成功安装
写一个php测试页info.php,放到apache2/htdocs中。
<?php
phpinfo();
?>;
或
<?php
$link=mysql_connect(‘localhost’,’root’,’123456′);
if(!$link) echo ” You’re a failure!”;
else echo “You’re a success!”;
mysql_close();
?>
在浏览器中输入:服务器地址/info.php
如果能正常显示出php的信息,则说明Apche+Mysql+PHP安装成功!
安装php可能遇到的问题:
[root@zjeasy15 hao32]# rpm -ivh krb5-libs-1.10.3-10.el6_4.6.x86_64.rpm
warning: krb5-libs-1.10.3-10.el6_4.6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing… ########################################### [100%]
package krb5-libs-1.10.3-10.el6_4.6.x86_64 is already installed
[root@zjeasy15 hao32]# rpm -ivh openssl-devel-1.0.1e-15.el6.i686.rpm
warning: openssl-devel-1.0.1e-15.el6.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
krb5-devel is needed by openssl-devel-1.0.1e-15.el6.i686
libcrypto.so.10 is needed by openssl-devel-1.0.1e-15.el6.i686
libssl.so.10 is needed by openssl-devel-1.0.1e-15.el6.i686
[root@zjeasy15 hao32]# rpm -ivh krb5-devel-1.10.3-10.el6_4.6.x86_64.rpm
warning: krb5-devel-1.10.3-10.el6_4.6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
keyutils-libs-devel is needed by krb5-devel-1.10.3-10.el6_4.6.x86_64
libcom_err-devel is needed by krb5-devel-1.10.3-10.el6_4.6.x86_64
libselinux-devel is needed by krb5-devel-1.10.3-10.el6_4.6.x86_64
[root@zjeasy15 hao32]#
libsepol-devel >= 2.0.32-1 is needed by libselinux-devel-2.0.94-5.3.el6_4.1.x86_64
pkgconfig(libsepol) is needed by libselinux-devel-2.0.94-5.3.el6_4.1.x86_64
1、安装php时的报错
checking libxml2 install dir… no
checking for xml2-config path…
configure: error: xml2-config not found. Please check your libxml2 installation.
检查是否安装了libxm包
[root@XKWB3403 php-5.3.8]# rpm -qa |grep libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.12
重新安装libxml2和libxml2-devel包
yum install libxml2
yum install libxml2-devel -y
安装完之后查找xml2-config文件是否存在
[root@XKWB3403 php-5.3.8]# find / -name “xml2-config”
/usr/bin/xml2-config
2、
When compiling a software package that is dependent on OpenSSL, it might happen that your compiler will give you the following error:
configure: error: Cannot find OpenSSL’s <evp.h> or <hmac.h>
in this case, the compiler wants to tell you that you haven’t the openSSL developer library installed. Do so by:
sudo apt-get install openssl-dev
on some systems, like Ubuntu Feisty, you might need to use this command:
sudo apt-get install libcurl3-openssl-dev