安装
yum install httpd #根据提示,输入Y安装即可成功安装
service httpd start #启动Apache
备注:Apache启动之后会提示错误:
正在启动 httpd:httpd: Could not reliably determine the server's fully qualif domain name, using ::1 for ServerName
解决办法:
vi /etc/httpd/conf/httpd.conf #编辑
找到 #ServerName www.example.com:80
修改为 ServerName www.yujiawei.com:80 #这里设置为你自己的域名,如果没有域名,可以设置为localhost
:wq! #保存退出
chkconfig httpd on #设为开机启动
url指定目录
NameVirtualHost *:80//去掉注释
<VirtualHost *:8090>
DocumentRoot /var/www/html/Life/public/
ServerName life.y-jw.cn
</VirtualHost>
配置Apache的HTTPS服务
# yum install mod_ssl openssl
一些配置
vi /etc/httpd/conf/httpd.conf #编辑文件
ServerTokens OS #在44行 修改为:ServerTokens Prod (在出现错误页的时候不显示服务器操作系统的名称)
ServerSignature On #在536行 修改为:ServerSignature Off (在错误页中不显示Apache的版本)
Options Indexes FollowSymLinks #在331行 修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)
#AddHandler cgi-script .cgi #在796行 修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)
AllowOverride None #在338行 修改为:AllowOverride All (允许.htaccess)
Options Indexes MultiViews FollowSymLinks #在554行 修改为 Options MultiViews FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html index.html.var #在402行 修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var (设置默认首页文件,增加index.php)
KeepAlive Off #在76行 修改为:KeepAlive On (允许程序性联机)
MaxKeepAliveRequests 100 #在83行 修改为:MaxKeepAliveRequests 1000 (增加同时连接数)
:wq! #保存退出
Options指令详解
参考链接:http://www.365mini.com/page/apache-options-directive.htm