rhel6+apache2.4+mysql5.5+php5.4部署LAMP架构

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~准备阶段~~~~~~~~~~~~~~~~~~~~~~~~~~~~

一、安装前准备

1.1)新建一个目录用于存放安装的源码

#mkdir -pv /usr/local/src/lamp

#cd /usr/local/src/lamp

1.2)关闭防火墙

关闭selinux

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~安装阶段~~~~~~~~~~~~~~~~~~~~~~~~~~~~

二、Apache安装1)下载源码

源码获得

#wget http://apache.etoak.com/httpd/httpd-2.4.3.tar.gz

#wget http://apache.dataguru.cn/apr/apr-1.4.6.tar.bz2

#wget http://labs.mop.com/apache-mirror/apr/apr-util-1.5.1.tar.bz2

 

2)Apache portable Run-time librariesAPR Apache可移植运行库的目的如其名称一样,主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库。

2.1) APR

#tar fvxj apr-1.4.6.tar.bz2;cd apr-1.4.6

#./configure --prefix=/usr/local/apr

#make

#make install

2.2)apr-util 工具包

#tar fvxj apr-util-1.5.1.tar.bz2;apr-util-1.5.1

#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/

#make

#make install

2.3) apr-iconv 转码工具包

#tar xf apr-iconv-1.2.1.tar.bz2

#cd apr-iconv-1.2.1

# ./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr/

#make

# make install

2.4)安装Apache

#tar fvxz httpd-2.4.3.tar.gz;cd httpd-2.4.3

#yum install zlib-devel gcc gcc-c++ openssl-devel pcre-devel -y

#./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-module=so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-ab --disable-userdir --with-mpm=prefork --enable-nonportable-atomics --disable-ipv6 --with-sendfile

#make

#make install

2.5)启动apache并验证

#/usr/local/apache2/bin/apachectl -k start

2.6)#lsof -i :80 查看是否是httpd进程占用了80端口

# lsof -i:80

COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

httpd     54409   root    4u  IPv6  73636      0t0  TCP *:http (LISTEN)

httpd     54410 daemon    4u  IPv6  73636      0t0  TCP *:http (LISTEN)

httpd     54411 daemon    4u  IPv6  73636      0t0  TCP *:http (LISTEN)

httpd     54412 daemon    4u  IPv6  73636      0t0  TCP *:http (LISTEN)

httpd     54413 daemon    4u  IPv6  73636      0t0  TCP *:http (LISTEN)

httpd     54414 daemon    4u  IPv6  73636      0t0  TCP *:http (LISTEN)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#useradd -s /sbin/nologin -r mysql

#yum remove mysql-server mysql mysql-devel -y

#yum install gcc gcc-c++ ncurses-devel libtool openssl-devel cmake -y

#mkdir -pv /usr/local/mysql/data

#tar xf mysql-5.5.X.tar.gz;cd mysql-5.5.X

#cmake . \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data/ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \

-DWITH_INNODBBASE_STORAGE_ENGINE=1 \

-DENABLE_LOCAL_INFILE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DMYSQL_USER=mysql \

-DWITH_DEBUG=0 \

-DWITH_EMBEDED_SERVER=0

#make

#make install

安装后设置

#cp support-files/my-innodb-heavy-4G.cnf /etc/my.cnf      从源码中拷贝一份配置文件

#cp support-files/mysql.server /etc/init.d/mysql   从源码中将启动脚本放到/etc/init.d/下并给予执行权限

#chmod 755 /etc/init.d/mysql

#chown mysql.mysql /usr/local/mysql/ -R   由于MySQL程序是由mysql用户管理的,所以修改所有者和所属组为mysql
初始化数据库

#sh scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

将安装目录中的命令 库文件 man手册链接到常用目录

#ln -s /usr/local/mysql/bin/* /usr/bin/

#ln -s /usr/local/mysql/lib/* /usr/lib/

#ln -s /usr/local/mysql/libexec/* /usr/local/libexec

#ln -s /usr/local/mysql/share/man/man1/* /usr/share/man/man1

#ln -s /usr/local/mysql/share/man/man8/* /usr/share/man/man8

启动MySQL#service mysql start

验证启动 lsof -i :3306

# lsof -i :3306

COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

mysqld  98409 mysql   20u  IPv6 248953      0t0  TCP *:mysql (LISTEN)

注意:/usr/local/mysql/data/localhost.localdomain.err   ##error log 位置 如果起不来 看该日志方便查错使用

mysql  (注意如果你的mysql版本是5.5以上的  那么机器内存必须大于2G)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

四、php安装

#yum install libxml2-devel bzip2-devel net-snmp-devel curl-devel libpng-devel freetype-devel libjpeg-devel zlib-devel -y

下载字符编码转换工具并安装

#wget http://lnamp-web-server.googlecode.com/files/libiconv-1.14.tar.gz

#tar fvxz libiconv-1.14.tar.gz

#cd libiconv-1.14

#./configure --prefix=/usr/local/ --with-apr=/usr/local/apr

#make

#make install

下载php加密工具并安装   两种加密工具 libmcrypt and  mhash

#wget http://lcmp.googlecode.com/files/libmcrypt-2.5.8.tar.gz

#wget http://lcmp.googlecode.com/files/mhash-0.9.9.9.tar.gz

#wget http://lcmp.googlecode.com/files/mcrypt-2.6.8.tar.gz

 

libmcrypt

#tar fvxz libmcrypt-2.5.8.tar.gz;cd libmcrypt-2.5.8

#yum -y install gcc-c++

#./configure && make && make install && /sbin/ldconfig

#cd libltdl/

#./configure --enable-ltdl-install && make && make install

#tar fvxz mcrypt-2.6.8.tar.gz;cd mcrypt-2.6.8

#./configure && make && make install

 

mhash

#tar fvxz mhash-0.9.9.9.tar.gz;cd mhash-0.9.9.9

#./configure && make && make install

#ln -s /usr/local/lib/* /usr/lib/

#ln -s /usr/local/bin/libmcrypt-config /usr/bin/

 

#wget http://cn2.php.net/get/php-5.4.11.tar.bz2/from/this/mirror

#tar fvxj php-5.4.11.tar.bz2;cd php-5.4.11

#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-iconv-dir=/usr/local/ --enable-fpm --with-fpm-user=apache --with-fpm-group=apache --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --disable-phar --with-curl --enable-dba --with-libxml-dir --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash --enable-mbstring --with-mcrypt --enable-pcntl --enable-xml --disable-rpath --enable-shmop --enable-sockets --enable-zip --enable-bcmath --with-snmp --disable-ipv6 --disable-rpath --disable-debug --with-apxs2=/usr/local/apache2/bin/apxs

#make ZEND_EXTRA_LIBS='-liconv'

#make install

#cp php.ini-production /usr/local/php/etc/php.ini

 

修改Apache主配置文件 找到libphp5.so那个模块 在后面添加下面这行,目的是让Apache接受以.php结尾的请求

#vim /usr/local/apache2/conf/httpd.conf

AddType application/x-httpd-php .php

重启Apache

#killall httpd

#/usr/local/apache2/bin/httpd

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~测试阶段~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#echo "<?php phpinfo() ?>" >  /usr/local/apache2/htdocs/phpinfo.php

#firefox http://localhost/phpinfo.php

阅读更多 登录后自动展开
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页