LAMP环境编译
一、安装
1、安装apr-1.5.1
tar -zxvf apr-1.5.1.tar.gz
cd apr-1.5.1
./configure --prefix=/usr/local/apr-1.5.1/
make
make install
ln -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.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util-1.5.4 --with-apr=/usr/local/apr-1.5.1/
make
make install
ln -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.gz
cd httpd-2.4.10
./configure --prefix=/usr/local/httpd-2.4.10 --enable-so --enable-module=so
make
make install
二、配置启动脚本
1、启动脚本,软链
ln -s /usr/local/httpd-2.4.10/bin/apachectl /usr/local/bin/
三、配置文件目录,软链
1、先把设置好软链,复制到到/etc/httpd下
mkdir /etc/httpd
ln -s /usr/local/httpd-2.4.10/conf/ /etc/httpd
2、修改httpd.conf配置文件
vim /usr/local/httpd-2.4.10/conf/httpd.conf
1) 设置运行用户和组
User evans
Group evans
2)设置根目录权限
<Directory />
#Options(目录参数)、Indexes FollowSymLinks(Options的参数)
Options Indexes FollowSymLinks
#AllowOverride(允许覆盖参数功能->.htaccess文件),None(不允许),Indexex(允许index方面的覆盖),ALL(全部权限覆盖)
AllowOverride All
</Directory>
3)把跟目录注释掉 (后续配置虚拟空间,需要这步,否则跳过)
#DocumentRoot
4)设置默认文件
DirectoryIndex index.php index.html
5)添加php支持 (全文搜素AddType,在后续追加)
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
4)引入自定义的配置文件,全文搜素(Include)
mkdir /usr/local/httpd-2.4.10/conf/conf.d
touch /usr/local/httpd-2.4.10/conf/conf.d/jason.conf
Include conf/conf.d/*.conf
5)开启虚拟机-这步过滤掉,走conf.d里的文件 (如果需要开启虚拟机,需要这步,否则跳过)
#Include conf/extra/httpd-vhosts.conf
6)开启模块(支持URL重写、CGI等)
proxy_module
proxy_fcgi_module
rewrite_module
mod_rewrite
7) ServerName (如果是8080,设置为80)
ServerName 0.0.0.0:8080
8)监听端口 (如果是80,设置为80)
Listen 8080
3、虚拟主机配置,修改http-vhosts.conf
#配置网站根目录
<VirtualHost 192.168.215.130:8080>
ServerAdmin linus.php@gmail.com
DocumentRoot /web/www
ServerName 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 FollowSymLinks
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
四、命令
1、测试配置文件(出现Syntax OK 表示正确)
./apachectl configtest
2、其他命令
启动
./apachectl start
重启
./apachectl restart
关闭
./apachectl stop