LAMP环境编译
一、安装
1、安装apr-1.5.1
tar -zxvf apr-1.5.1.tar.gzcd apr-1.5.1./configure --prefix=/usr/local/apr-1.5.1/makemake installln -s /usr/local/apr-1.5.1/bin/apr-1-config /usr/bin/
2、安装apr-util-1.5.4
tar -zxvf apr-util-1.5.4.tar.gzcd apr-util-1.5.4./configure --prefix=/usr/local/apr-util-1.5.4 --with-apr=/usr/local/apr-1.5.1/makemake installln -s /usr/local/apr-util-1.5.4/bin/apu-1-config /usr/bin/
3、httpd-2.4.10
tar -zxvf httpd-2.4.10.tar.gzcd httpd-2.4.10./configure --prefix=/usr/local/httpd-2.4.10 --enable-so --enable-module=somakemake install
二、配置启动脚本
1、启动脚本,软链
ln -s /usr/local/httpd-2.4.10/bin/apachectl /usr/local/bin/
三、配置文件目录,软链
1、先把设置好软链,复制到到/etc/httpd下
mkdir /etc/httpdln -s /usr/local/httpd-2.4.10/conf/ /etc/httpd
2、修改httpd.conf配置文件
vim /usr/local/httpd-2.4.10/conf/httpd.conf1) 设置运行用户和组User evansGroup evans2)设置根目录权限<Directory />#Options(目录参数)、Indexes FollowSymLinks(Options的参数)Options Indexes FollowSymLinks#AllowOverride(允许覆盖参数功能->.htaccess文件),None(不允许),Indexex(允许index方面的覆盖),ALL(全部权限覆盖)AllowOverride All</Directory>3)把跟目录注释掉 (后续配置虚拟空间,需要这步,否则跳过)#DocumentRoot4)设置默认文件DirectoryIndex index.php index.html5)添加php支持 (全文搜素AddType,在后续追加)AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps4)引入自定义的配置文件,全文搜素(Include)mkdir /usr/local/httpd-2.4.10/conf/conf.dtouch /usr/local/httpd-2.4.10/conf/conf.d/jason.confInclude conf/conf.d/*.conf5)开启虚拟机-这步过滤掉,走conf.d里的文件 (如果需要开启虚拟机,需要这步,否则跳过)#Include conf/extra/httpd-vhosts.conf6)开启模块(支持URL重写、CGI等)proxy_moduleproxy_fcgi_modulerewrite_modulemod_rewrite7) ServerName (如果是8080,设置为80)ServerName 0.0.0.0:80808)监听端口 (如果是80,设置为80)Listen 8080
3、虚拟主机配置,修改http-vhosts.conf
#配置网站根目录<VirtualHost 192.168.215.130:8080>ServerAdmin linus.php@gmail.comDocumentRoot /web/wwwServerName 192.168.215.130#ErrorLog logs/dummy-host.example.com-error_log#CustomLog logs/dummy-host.example.com-access_log common</VirtualHost>#配置一个虚拟主机<VirtualHost phpmyadmin.box.cn:8080>DocumentRoot "/web/www/phpmyadmin"ServerName phpmyadmin.box.cn#ErrorLog "logs/phpMyAdmin.com-error_log"#CustomLog "logs/phpMyAdmin.com-access_log" common# 关闭正向代理#ProxyRequests Off# 把以.php结尾的文件请求发送到php-fpm进程,php-fpm至少需要知道运行的目录和URI#ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/web/www/phpmyadmin/$1<Directory "/web/www/phpmyadmin">Options Indexes FollowSymLinksAllowOverride ALLOrder allow,denyAllow from all</Directory></VirtualHost>
四、命令
1、测试配置文件(出现Syntax OK 表示正确)
./apachectl configtest
2、其他命令
启动./apachectl start重启./apachectl restart关闭./apachectl stop
