linux 源码安装Apache三步曲
安装Apache源码包:
1 解压生成编译配置文件
检查gcc
没有安装gcc:yum -y install gcc*
tar xzf 压缩包
./configure --prefix=/usr/local/apache2/ --sysconfdir=/usr/local/apache2/etc/ --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared
2.进行编译(把c编译成执行程序)
make
3.进行安装
make install
启动服务时候如果报错
httpd: Could not reliably determine the server's fully qualified domain name
解决办法:vim /usr/local/apache2/etc/httpd.conf
重新启动
/usr/local/apache2/bin/apachectl start/restart
一、Apache基本知识
1.Apache安装目录
/usr/local/apache2
2.网站根目录
/usr/local/apache2/htdocs
3.配置文件
/usr/local/apache2/etc/httpd.conf
4.应用程序
/usr/local/apache2/bin/httpd
5.服务脚本(httpd 服务脚本,后面需要添加参数)
/usr/local/apache2/bin/apachectl
6.启动服务
/usr/local/apache2/bin/apachectl start
/usr/local/apache2/bin/apachectl resart
7.关闭服务
/usr/local/apache2/bin/apachectl stop
8.查看进程
pstree | grep httpd
9.查看端口
netstat -tunpl | grep :80
10.开启启动
vi /etc/rc.d/rc.local
/usr/local/bin/apache2/bin/apachectl restart &> /del/null
二、apache 配置文件
1.Apache主目录
ServerRoot "/usr/local/apache2/"
2.监听端口
Listen 80
3.加载动态模块
LoadModule php5_module modules/libphp5.so
4. 决定了Apache的进程执行者( 查看 ps -ef|grep httpd )
User daemon
Group daemon
5.服务器域名
ServerName localhost:80
6.网站根目录
DocumentRoot "/usr/local/apache2//htdocs"
7.设置系统、目录的访问权限
1)服务权限
Indexes 先查看默认首页,如果不存在就以文件列表显示
FollowSymLinks 网站目录下允许存在快捷方式(ln -s /media media)
allow :允许访问
deny:拒绝访问
2)系统权限
文件rwx 权限
8.设置目录默认首页
DirectoryIndex index.html index.php 优先级左往右依次降低
9.错误日志
ErrorLog "logs/error_log"
10.访问日志
CustomLog "Logs/access_log" common