Centos 6.5手动编译安装LAMP

查看系统版本

[root@B mysql-5.1.72]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@B mysql-5.1.72]# uname -a
Linux B 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
本文是以httpd-2.4.28 + mysql-5.1.72 + php-5.3.27 的软件搭建LAMP架构


1.安装apache及前期准备工作,请参考http://blog.csdn.net/qq_30256711/article/details/78567271


2.安装Mysql

yum remove mysql-server

yum install ncurses ncurses-devel

wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72.tar.gz

tar zxvf mysql-5.1.72

cd mysql-5.1.72

groupadd mysql

useradd mysql -g mysql -M -s /sbin/nologin

./configure \
--prefix=/usr/local/mysql-5.1.72 \
--with-unix-socket-path=/usr/local/mysql-5.1.72/tmp/mysql.sock \
--localstatedir=/usr/local/mysql-5.1.72/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-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

make && make install

安装完成

基础配置

\cp mysql-5.1.72/support-files/my-small.cnf /etc/my.cnf  #设置配置文件

chown mysql.mysql /usr/local/mysql-5.1.72 -R  #安装目录属主更改为mysql,为mysql用户授权

scripts/mysql_install_db --basedir=/usr/local/mysql-5.1.72/ --datadir=/usr/local/mysql-5.1.72/data --user=mysql #初始化数据库

cp mysql.server /etc/init.d/mysqld #配置启动脚本

chmod +x /etc/init.d/mysqld

/usr/local/mysql-5.1.72/bin/mysqladmin -uroot password "haha123" #设置root密码


3.安装php

安装准备
yum install zlib libxml libjpeg freetype libpng gd  curl libiconv  zlib-devel libxml2-devel libjpeg-devel \

freetype-devel libpng-devel gd-devel curl-devel openssl openssl-devel libxslt libxslt-devel -y

tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure
make && make install
cd ../


开始安装

 tar zxvf php-5.3.27.tar.gz
./configure --prefix=/usr/local/php-5.3.27 --with-apxs2=/usr/local/httpd-2.4.28/bin/apxs --with-mysql=/usr/local/mysql-5.1.72/ --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd --with-jpeg-dir --with-png=dir --with-iconv=/usr/local/libiconv-1.14/ --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

ls /usr/local/httpd-2.4.28/modules/libphp5.so
/usr/local/httpd-2.4.28/modules/libphp5.so
grep php /usr/local/httpd-2.4.28/conf/httpd.conf
LoadModule php5_module        modules/libphp5.so

这样php就装好了

配置apache支持解析php程序



搜索AddType,添加以下两行

AddType application/x-httpd-php .php  
AddType application/x-httpd-php-source .php5   
然后搜索DirectoryIndex

添加 index.php


测试php程序

phpinfo();
?>
测试php连接mysql

        //$link_id=mysql_connect('主机名','用户','密码');
        $link_id=mysql_connect('localhost','root','haha123') or mysql_error();

        if($link_id){
                echo "mysql successful by oldboy !";
        }else{
                echo mysql_error();
        }
?>

[root@B php-5.3.27]# curl 192.168.200.129
mysql successful by oldboy !
搭建完成

故障排除;

如果报错:configure: error: Cannot find libmysqlclient_r under /usr/.

这个错误时因为在64位的linux系统中,libmysqlclient 默认安装到了 /usr/lib64/mysql/ 目录下,但是php编译时,要去/usr/lib目录下查找
解决办法:在/usr/lib目录下创建一个软连接

ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib/libmysqlclient.so

或者

cp /usr/lib64/mysql/* /usr/lib/mysql/
然后进行./configure即可,如果服务器没有/usr/lib/mysql/ 目录,则在/usr/lib/目录下创建mysql目录即可



你可能感兴趣的:(Linux服务及故障排除,web安全)