建立LAMP平台

PHP连接mysql

[[email protected] mysql]# yum install php-mysql

CMS:(开源)

drupal

joomla

编译安装LAMP之httpd

安装顺序:httpd-->mysql-->php

版本:

httpd:2.4.12

mysql:5.6.10

php:5.4.42

apr:Apache Portable Runtime,是HTTPD的虚拟机

apr-util

apr-iconv

编译安装httpd软件:

# yum -y install pcre-devel     #HTTPD的编译环境

# tar xf apr-1.4.6.tar.bz2   #httpd虚拟机apr软件安装
# cd apr-1.4.6
# ./configure --prefix=/usr/local/apr
# make
# make install

# tar xf apr-util-1.4.1.tar.bz2    #apr-util工具包的安装
# cd apr-util-1.4.1
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make
# make install

# tar xf httpd-2.4.4.tar.bz2
# cd httpd-2.4.4
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --enable-deflate --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
# make
# make install

--prefix=/usr/local/apache   #安装路径
--sysconfdir=/etc/httpd    #配置文件路径
--enable-so            #支持共享模块
--enable-rewirte         #支持URL重写
--enable-ssl        #支持ssl
--enable-cgi        #进程方式使用cgi
--enable-cgid    #纯种方式使用cgi
--enable-modules=most
--enable-mods-shared=most    #启用共享模块
--enable-mods-static=MODULE-LIST     #静态库,直接编译进主程序
--enable-mpms-shared=all        #多道处理模块(MPM)的支持
--with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-util     
--enable-authn-dbm     #启用认证,默认是启用的
--enable-deflate      #启用网页传输压缩
--enable-mpms-shared=all        #多道处理模块(MPM)的支持,需注意的是,如果是使用worker,event模式,PHP必须编译安装成ZTS格式,prefork模式不需要单独编译php

配置安装好的httpd服务:

#修改httpd的pid进程文件路径 
[[email protected] apache]# vim /etc/httpd/httpd.conf
PidFile "/var/run/httpd.pid"    #需要停用服务,再去修改配置
[[email protected] apache]# ./bin/apachectl start  #启动服务
[[email protected] apache]# ls /var/run/ | grep httpd
httpd.pid
#配置httpd服务管理脚本:
vim /etc/rc.d/init.d/httpd
#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.  It is used to serve #	       HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc -p ${pidfile} -d 10 $httpd
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
    echo -n $"Reloading $prog: "
    if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
        RETVAL=$?
        echo $"not reloading due to configuration syntax error"
        failure $"not reloading $httpd due to configuration syntax error"
    else
        killproc -p ${pidfile} $httpd -HUP
        RETVAL=$?
    fi
    echo
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
        status -p ${pidfile} $httpd
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  condrestart)
	if [ -f ${pidfile} ] ; then
		stop
		start
	fi
	;;
  reload)
        reload
	;;
  graceful|help|configtest|fullstatus)
	$apachectl [email protected]
	RETVAL=$?
	;;
  *)
	echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
	exit 1
esac

exit $RETVAL

[[email protected] tmp]# chmod +x /etc/rc.d/init.d/httpd  #给服务脚本权限
[[email protected] tmp]# chkconfig --add httpd    #加入服务列表
[[email protected] tmp]# chkconfig --level 2345 httpd on   #加入运行启动级别
[[email protected] tmp]# chkconfig --list | grep httpd
httpd          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
#现在可以使用service httpd start的方式来管理httpd服务

#添加PATH环境变量,以正常的情况执行http相关命令
[[email protected] ~]# cat /etc/profile.d/httpd.sh 
export PATH=$PATH:/usr/local/apache/bin
时间: 2024-08-25 16:57:02

建立LAMP平台的相关文章

LAMP平台的搭建以及基本应用

LAMP平台部署及应用 1:LAMP包括的组件有 linux apache mysql php(python,perl) 优点: 成本低廉,都属于开源软件 易于开发,页面代码简单,与html标记语言结合度非常高 方便应用,方便移植,应用便捷 安全和稳定性非常好 2:PHP的好处 结合了 C, Java,Perl 自创的新语法,拥有更好的网页执行速度,再次我们使用PHP 3:MySQL在上一章已搭建完毕,再次使用搭建完成的MySQL,可以查看本人的MySQL数据库技术文档 Apache也使用之前搭

LAMP平台搭建详解

准备工作 安装编译工具 # yum -y install gcc # yum -y install gcc-c++ 如果系统之前已经安装有rpm包的mysql和apache,那么可以: #service httpd stop #service mysqld stop 确定rpm包安装的httpd和mysqld不能开机启动 #chkconfig –level 2345 mysqld/httpd stop 关闭SELINUX和防火墙,或者允许防火墙开放相关端口,apache 80端口,mysql 3

RedHat下构建LAMP平台+Discuz!论坛

LAMP的简介: lAMP平台的构成组件: Linux:作为LAMP架构的基础,提供用于支撑web站点的操作系统,能够与其他三个组件提供更好地稳定性.兼容性. Apache:作为LAMP架构前端,是一款功能强大.稳定性好的web服务器程序,该服务器直接面向用户提供网站访问,发送网页.图片等内容. Mysql:作为LAMP架构后端,是一款流行的开源关系数据库系统. PHP:作为三种开发动态网页的编程语言,负责解释动态网页文件,并提供web应用程序的开发和运行环境. LAMP平台的应用优势: 1. 

运维必会LAMP平台源码安装

web服务作为互联网的支柱及应用,在各种场合应用广泛.官方提供的rpm包由于要面对的是所有用户,把有些我们不需要的功能编译进去了,某些需要的功能又没编译进去.且官方提供的rpm版本通常都比较老旧,在实际应用中大多数情况都要使用源码来安装lamp平台. 环境: 操作系统:CentOs6.4 软件安装包: APR:apr-1.5.2.tar.gz.apr-util-1.5.4.tar.gz Apache:httpd-2.4.12.tar.gz Mysql:mysql-5.6.24.tar.gz PH

LAMP平台

mysql> use mysql; mysql> select User,Host,Password from user; +----------+-----------------------+-------------------------------------------+ | User     | Host                  | Password                                  | +----------+-------------

部署LAMP平台和搭建Discue论坛

部署LAMP平台和搭建Discue论坛 1.          实验需求: 1)     搭建Apache环境 2) 构建PHP运行环境 3) 搭建MySQL 数据库 4) 搭建Discue 论坛 2.          实验环境: Linux服务器系统版本:Red Hat Enterprise Linux 6.5  IP:192.168.10.20 WIN7系统客户机: IP: 192.168.10.1 3.      实验步骤: 基本安装操作: 上一章我们已经搭建了Apache软件和MySQ

LAMP平台的搭建和网站的防盗链

部署LAMP平台和网站的防盗链 定制LAMP平台 一:安装.运行MySQL5.6服务器 LAMP构成:Linux.Apache.MySQL.PHP/Perl/Python 1. 清理冲突程序 [[email protected] ~]# yum -y remove httpdmysql-server mysql php .. .. [[email protected] ~]# rm -rf /etc/my.cnf/var/lib/mysql                 //清理干扰文档 2.

hph-fpm的LAMP平台

建立php-fpm的服务群 上图是php-fpm的工作原理 一.编译安装php-5.4.26 php的源代码文件请自行下载,这里以安装php2.4为例 1.解决依赖关系: 请配置好yum源(可以是本地系统光盘)后执行如下命令: # yum -y groupinstall "X Software Development" 如果想让编译的php支持mcrypt扩展,还需要安装下面两个程序:libmcrypt-devel :mhash-devel 2.编译安装php-5.4.26 # tar

基于Centos 6.5 配置分离式LAMP平台环境的一次扩展实现多PHP Apache和自建DNS来提升LAMP的负载

要达到的目的双Apache+PHP能正常的被DNS轮询解析到Apache 1 2 服务器能正常访问NFS上的静态资源PHP 1 2 服务器能正常访问NFS上的PHP资源Apache 1 2 和PHP 1 2服务器都能和MariaDB数据库服务器通信最终实现低价格提高网站负载的方案 由于这里使用了7台服务器所以下文区别服务器的方法请看命令行的[[email protected] ~]这个字段 服务器编号 服务器IP 服务器安装的服务 服务器系统 LookBack163 172.16.41.163