243eqd 发表于 2015-11-24 09:06:55

Lamp源码安装

实验环境:

系统版本:CentOS6.6x86_64;

httpd源码包:httpd-2.4.4.tar.bz2;

apr源码包:apr-1.4.6.tar.bz2;

apr-util源码包:apr-util-1.4.1.tar.gz

mysql源码包:mysql-5.6.27.tar.gz

Php 源码包: php-5.6.14.tar.gz

实验前提:

关闭防火墙和SELinux;

安装编译环境;
# yum install wget gcc gcc-c++ make cmake ncurses-devellibtool zilib-devel lrzsz libxml2 libxml2-devel pcre-devel openssl-devel -y

实验过程:

一、安装http2.4服务;

apr:

# tar xf apr-1.4.6.tar.bz2
# cd apr-1.4.6
#./configure --prefix=/usr/local/apr
# make && make install

apr-util:      

# tar xf apr-util-1.4.1.tar.gz
# cd apr-util-1.4.1
#./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr/bin/apr-1-config
   --with-apr=/usr/local/apr/    :指明apr安装位置;
# make && make install




httpd:

# tar xf httpd-2.4.4.tar.bz2
# cd httpd-2.4.4
#./configure--prefix=/usr/local/apache--enable-so--enable-ssl --enable-cgi --enable-rewrite --enable-cgid --enable-modules=most--enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/bin
# make && make install
# /usr/local/apache/bin/apachectl start报错
#vim /usr/local/apache/conf/httpd.conf
找到#ServerName www.example.com:80 去掉#号再重新启动
httpd编译参数解释:
#fdisk -l
#fdisk /dev/sdb (n p 1 w)
#mkdir /mydata
#mount /dev/sdb1 /mydata
#vim/etc/fstab
添加一行
/dev/sdb1               /mydata               ext4    defaults      0 0
#reboot
#/etc/init.d/iptables stop
mysql5.6.27服务
tar xf mysql-5.6.27.tar.gz
# cd mysql-5.6.27
# useradd -u 306 -s /sbin/nologin mysql
# mkdir -p /mydata/data
# chown -R mysql.mysql /mydata/data/

预编译
# cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/mydata/data/mysql.sock\
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci\
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1\
-DMYSQL_DATADIR=/mydata/data/\
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306

make && makeinstall
配置 Mysql 服务为系统服务:
# cd /usr/local/mysql/
# cp support-files/my-default.cnf/etc/my.cnf
# cp support-files/mysql.server/etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on
#vim /etc/my.cnf

datadir=/mydata/
socket=/mydata/mysql.sock
user=mysql
# Disabling symbolic-links isrecommended to prevent assorted security risks
symbolic-links=0


log-error=/var/log/mysqld.log
pid-file=/mydata/mysqld.pid
初始化mysql
#scripts/mysql_install_db --user=mysql--basedir=/usr/local/mysql --datadir=/mydata/ --pid-file=/mydata --socket=/mydata/mysql.sock --defaults-file=/mydata/
# /etc/init.d/mysqld restart



二、安装PHP服务# tar xf php-5.6.14.tar.gz
# cd php-5.6.14
#./configure --prefix=/usr/local/php5--with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs--with-mysql=/usr/local/mysql/
# make && make install

四、 源码安装 Apache+PHP 整合
整合 apache+php 环境,修改 httpd.conf 配置文件,然后加入如下语句:
# cd/usr/local/apache/conf/
# vim httpd.conf

LoadModule php5_modulemodules/libphp5.so (默认已存在)
AddTypeapplication/x-httpd-php .php
DirectoryIndexindex.php index.html (把 index.php 加入 index.html 之前)


然后在/usr/local/apache/htdocs 目录下创建index.php 测试页面,执行如下命令:
cat>>/usr/local/apache/htdocs/index.php <<Q
<?php
phpinfo();
?>
Q
重新启动 apache 服务,通过 IP 访问界面如下图,即代表 LAMP 环境搭建成功。

页: [1]
查看完整版本: Lamp源码安装