#LAMP
#httpd-2.2.32
#mysql-5.7.17-linux-glibc2.5-x86_64 二进制压缩版
#php5.3.27
sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/selinux/config
getenforce 0
/etc/init.d/iptables stop
cat /etc/redhat-release
CentOS release 6.7 (Final)
uname -r
2.6.32-431.el6.x86_64
uname -m
x86_64
2、安装配置apache
http://httpd.apache.org/download.cgi #apache官网#新建apache运行用户useradd -s /sbin/nologin -M www
mkdir tools
cd tools
#下载http代码包
http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.20.tar.gz
wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.25.tar.gz
http://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gz
http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz
#附上aliyun下载地址
wget -c http://mirrors.aliyun.com/apache/apr/apr-1.5.2.tar.gz
wget -c http://mirrors.aliyun.com/apache/apr/apr-util-1.5.4.tar.gz
wget -c http://mirrors.aliyun.com/apache/httpd/httpd-2.4.25.tar.gz
#安装插件apr和apr-util
#编译安装apr
tar xf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr-1.5.2
make && make install
echo $?
ln -s /usr/local/apr-1.5.2/ /usr/local/apr
cd ..
#编译安装apr-util
tar xf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util-1.5.4 --with-apr=/usr/local/apr-1.5.2/
echo $?
make && make install
echo $?
ln -s /usr/local/apr-util-1.5.4/ /usr/local/apr-util
cd ..
#安装功能包
yum install pcre-devel zlib-devel openssl-devel -y
#安装apache
tar zxvf httpd-2.4.25.tar.gz
cd httpd-2.4.25
./configure --prefix=/usr/local/httpd-2.4.25 \
> --with-apr=/usr/local/apr-1.5.2 \
> --with-apr-util=/usr/local/apr-util-1.5.4 \
> --enable-so --enable-deflate --enable-expires \
> --enable-headers --enable-ssl --enable-rewrite \
> --enable-mpms-shared=all --with-mpm=prefork \
> --enable-mods-shared=most
echo $?
#--prefix= apache安装目录。默认情况下,安装目录设置为 /usr/local/apache2。
#--sysconfdir= 指定配置文件安装路径
#--with-apr= 如果要使用已安装的APR,则必须告诉脚本configure的apr的安装路径
#--with-apr-util 指定已安装的apr-util的安装路径
#--enable-so 允许运行时加载DSO模块
#--enable-cgi 启用cgi协议
#--with-zlib 启用zlib库文件
#--with-pcre 指定pcre的安装路径
#--enable-modules=most 启用大多数共享模块
#--enable-deflate 压缩传输编码支持
#--enable-expires Expires头控制
#--enable-headers HTTP头控制
#--enable-ssl 启动ssl加密功能,SSL/TLS支持(mod_ssl)
#--enable-rewrite 基于规则的URL操作,启用URL重写功能
#--enable-mpms-shared=all 空间分隔的MPM模块列表启用,动态加载
#--with-mpm=prefork 指定使用的MPM的类型, 选择Apache使用的进程模型(event|worker|prefork|winnt)
#--enable-mods-shared=most 启用MPM大多数参数, 定义要启用并构建为动态共享模块的模块列表,默认设置为most(all|most|few|reallyall)
make
make install
ln -s /usr/local/httpd-2.4.25/ /usr/local/httpd
#配置http环境变量
echo "export PATH=/usr/local/httpd/bin:$PATH" >>/etc/profile
. /etc/profile
#查看http模块
ls /usr/local/httpd/modules
#查看安装的模块
apachectl -t -D DUMP_MODULES
#修改http配置文件
sed -i 's/#ServerName www.example.com:80/ServerName localhost:80/g' /usr/local/httpd/conf/httpd.conf
#启动apache服务
apachectl start
#查看http服务
netstat -lntup|grep httpd
tcp 0 0 :::80 :::* LISTEN 56389/httpd
#配置启动脚本
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
chmod +x /etc/init.d/httpd
/etc/init.d/httpd stop
netstat -lntup|grep httpd
/etc/init.d/httpd start
netstat -lntup|grep httpd
vim /etc/init.d/httpd
#在开始位置添加:
# chkconfig: 345 85 15
# description: this my apache is httpd server
#加入系统启动服务,开机自启动
chkconfig --add httpd
chkconfig httpd on
chkconfig --list httpd
#测试访问正常!到此apache安装完成!
#借鉴的别人的启动脚本
cat >>/etc/init.d/httpd<<EOF #!/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 $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1 esac exit $RETVAL EOF