安装需要的软件包,在http://sourceforge.net/可以找到:
apr-util-1.3.9.tar.gz
apr-1.4.6.tar.bz2
libmcrypt.tar.gz
mysql-5.5.33.tar.gz
httpd-2.4.10.tar.gz
pcre-8.35.tar.bz2
php-5.3.29.tar.bz2
先删除系统自带的依赖包,我这里使用的系统是red hat 5.5
[root@localhost ~]# rpm -e httpd httpd-manual system-config-httpd webalizer subversion php php-cli -php-ldap php-comom mysql mysql-server --nodeps
[root@localhost ~]# tar xf apr-1.4.6tar.bz2
[root@localhost ~]#cd apr-1.4.6
[root@localhost apr-1.4.6]#./configure --prefix=/usr/local/apr
[root@localhost apr-1.4.6]#make && make install
[root@localhost ~]#tar zxf apr-util-1.3.9.tar.gz
[root@localhost ~]# cd apr-util-1.3.9
[root@localhost apr-util-1.3.9]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.3.9]#make && make install
[root@localhost ~]# tar xf pcre-8.35.tar.bz2
[root@localhost ~]# cd pcre-8.35
[root@localhost pcre-8.35]# ./configure --prefix=/usr/local/pcre
[root@localhost pcre-8.35]# make && make install
[root@localhost ~]# tar xf httpd-2.4.10.tar.gz
[root@localhost ~]# cd httpd-2.4.10
[root@localhost httpd-2.4.10]#./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-agi --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
[root@localhost httpd-2.4.10]#make && make install
[root@localhost httpd-2.4.10]#/usr/local/httpd/bin/apachectl start
[root@localhost httpd-2.4.10]#cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
chkconfig --add httpd来添加,但是提示:httpd服务不支持 chkconfig。需要编辑/etc/rc.d/init.d/httpd,添加以***释信息:
# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server
[root@localhost httpd-2.4.10]# chkconfig --add httpd
[root@localhost httpd-2.4.10]# service httpd restart
setup mysql5.53
安装mysql需要用到cmake,请务必先装上cmake,装mysql的过程中免不了会提示缺少那个那个依赖包,缺什么就给它装什么好了,最好使用yum安装吧,方便又快捷。如果装了依赖包还报错,可能是你没有清除编译记录rm -rf CMakeCache.txt,或者,mysql编译过程中找不到那个文件,需要手动指定。
yum install �Cy openssl openssl-devel ncurses ncurses-devel gcc gcc-c++ glibc patch libxml12
[root@localhost ~]# mkdir /usr/local/mysql
[root@localhost ~]# mkdir /usr/local/mysql/data
[root@localhost ~]# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
[root@localhost ~]# tar -zxvpf cmake-2.8.4.tar.gz
[root@localhost ~]# cd cmake-2.8.4
[root@localhost cmake-2.8.4]# ./configure --prefix=/usr/local/cmake2.8.4 && make && make install
[root@localhost cmake-2.8.4]# vim path.sh
PATH=$PATH:$HOME/bin:/usr/local/cmake2.8.4/bin:$PATH
export PATH
[root@localhost cmake-2.8.4]#./path.sh
[root@localhost ~]# tar zxf mysql-5.5.33.tar.gz
[root@localhost ~]# cd mysql5.53
[root@localhost mysql-5.5.33]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/usr/local/mysql/etc \
-DMYSQL_DATADIR=/usr/local/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
cmake . \
-DCMAKE_INSTALL_PREFIX=
/mysql/mysqldir
\
-DMYSQL_DATADIR=
/mysql/mysqldir/data
\
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR==
/mysql/mysqldir/data/mysql
.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
[root@localhost mysql-5.5.33]# cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql-5.5.33]#vim /etc/my.cnf
datadir=/usr/local/mysql/data
[root@localhost mysql-5.5.33]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.5.33]#chmod a+x /etc/init.d/mysqld
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql-5.5.33]# cd /usr/local/mysql/
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql datadir=/usr/local/mysql/data
[root@localhost local]# chown -R root:mysql /usr/local/mysql/
[root@localhost mysql]# chown -R mysql /usr/local/mysql/var
[root@localhost mysql]# ln -s /usr/local/mysql/bin/* /usr/local/bin
[root@localhost mysql]# ln -s /usr/local/mysql/include/* /usr/include/
[root@localhost mysql]# cp/usr/local/mysql/lib/* /usr/lib
(php安装的时候,会到/usr/lib下找mysql的库文件,所以我选择直接把文件复制到/usr/lib下)
[root@localhost mysql]# mysqladmin -u root -p password 123
[root@localhost mysql]# service mysqld start
Starting MySQL.. [确定]
第一次启动mysql可能会报错,请确保在/etc/my.cnf
的mysqld下已经添加了datadir=/usr/local/mysql/data
,可能是第二次在机器上安装mysql,有残余数据影响了服务的启动。
解决方法:去mysql的数据目录/data看看,如果存在mysql-bin.index,就赶快把它删除掉吧,它就是罪魁祸首了,检查一下/etc/my.cnf文件中有没有没被注释掉的skip-federated字段,如果有就立即注释掉吧,注意要确保mysql用户拥有mysql文件的程序运行权限,最后就是关闭selinux减少它对mysql的影响。
Setup php
小弟我装php有点坎坷,一开始我装的php版本是php5.53,装的过程一路披荆砍棘,到了最后发现
apache2.4竟不支持,后来改用php5.3.29就没有问题啦:
Syntax error on line 135 of /usr/local/httpd/conf/httpd.conf: Cannot load /usr/local/httpd/modules/libphp5.so into server: /usr/local/httpd/modules/libphp5.so: undefined symbol: unixd_config
[root@localhost ~]# tar xf libmcrypt.tar.gz
[root@localhost ~]# cd libmcrypt-2.5.7/
[root@localhost libmcrypt-2.5.7]# mkdir -p /usr/local/libmcrytp
[root@localhost libmcrypt-2.5.7]# ./configure prefix=/usr/local/libmcrytp/ && make && make install
[root@localhost ~]# tar xf php-5.3.29.tar.bz2
[root@localhost ~]# cd php-2.5.7
[root@dragon php-5.5.26]# ./configure --prefix=/usr/local/php-5.5.7 --with-config-file-path=/usr/local/php-5.5.7/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
[root@localhost php-5.3.29]# cp php.ini-production /usr/local/php5/php.ini
装完以后可以看到在apache的module文件下多了libphp5.so,接下来就要配置apache支持php,编辑/usr/local/httpd/conf/httpd.conf,添加libphp5.so的支持。
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module modules/libphp5.so
在<IfModule mime_module>
</IfModule>
之间添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
可能你会遇到这样的错误,这是selinux在作怪,修 改/etc/selinux/conf,设置SELINUX=disabled,需要再重新启动系统配置才能生效,也可以选择临时关掉:setenforce 0.
[root@localhost ~]# service httpd start
httpd: Syntax error on line 150 of /usr/local/httpd/conf/httpd.conf: Cannot load modules/libphp5.so into server: /usr/local/httpd/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
[root@localhost ~]# service httpd start
[root@localhost ~]# vim /usr/local/httpd/htdocs/phpinfo.php
输入:
<?php
phpinfo();
?>
用浏览器浏览phpinfo.php试试,看到一下效果就说明成功啦~~~
本文出自 “龙爱雪琪” 博客,转载请与作者联系!