1.禁止显示 index of目录编辑http.conf文件找到： Options indexes FollowSymLinks 改为： Options FollowSymLinks2.Apache添加多端口编辑http.conf文件在Listen 80处另起一行输入Listen 8080 （监听8080端口）在httpd.conf文件最后一行添加：注：默认的80路径为/var/www/html/，我这是在这个下面的文件夹下添加test文件夹为测试NameVirtualHost *:8080 ServerName localhost:8080 DocumentRoot "/var/www/html/test/″ Options FollowSymLinks IncludesNOEXEC AllowOverride All Order Deny,Allow Allow from all 3、重启Apache4、把8080（监听的端口）开放防火墙
1.进入Apache编辑httpd.conf文件2.找到#LoadModule rewrite_module modules/mod_rewrite.so改为LoadModule rewrite_module modules/mod_rewrite.so3.找到 # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None 改为 AllowOverride All重启Apachecd /usr/local/apache/bin/ ./apachectl restart
1.进入Apache编辑httpd.conf文件1、增加下面内容AddType application/x-httpd-php .php .phtml #以php结尾的，交给php处理 AddType application/x-httpd-php-source .phps 找到DirectoryIndex index.html #添加index.phpDirectoryIndex index.html index.php重启Apachecd /usr/local/apache/bin/ ./apachectl restart
Linux搭建Apache1.安装APR，APR-util，PCRE，expat，gcc，gcc-c++的依赖ARP和APR-util在http://apr.apache.org/download.cgi 这里下载PCRE在https://pcre.org 这里下载expat使用yum安装yum install -y expat-devel*gcc和gcc-c++使用yum安装yum install gcc gcc-c++2.下载apache安装包apache在http://httpd.apache.org/download.cgi 这里下载开始安装Apache1.下载完上面的安装包和依赖包，上传到服务器（新建一个文件夹用来存放）2.进入安装包目录解压 安装apr安装目录是/usr/local/aprtar -zxf apr-1.7.0.tar cd apr-1.7.0 ./configure --prefix=/usr/local/apr make && make install安装apr-util安装目录是/usr/local/apr-utiltar -xf apr-util-1.6.1.tar cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config make && make install安装pcretar -zxvf pcre-8.43.tar cd pcre-8.43 ./configure --prefix=/usr/local/pcre make && make install安装apache安装目录是/usr/local/apache tar -zxvf httpd-2.4.41.tar cd httpd-2.4.41 ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-module=so --enable-mods-shared=all --enable-module=rewirte --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --disable-cgid --disable-cgi make && make install修改httpd.confcd /usr/local/apache/conf/ vi httpd.conf将ServerName前的“#”去掉，将www.example.com改成 本机IP:80（如192.168.1.1:80）启动apachecd /usr/local/apache/bin/ ./apachectl start通过本机浏览器输入地址