zoukankan      html  css  js  c++  java
  • linux+Apache开启伪静态配置

    linux+Apache伪静态配置

    一、环境准备:
    CentOS Linux release 7.4.1708 (Core)
    1.配置源
    [root@localhost ~]#yum install -y epel-release
    [root@localhost ~]#rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    2.安装php7
    [root@localhost ~]#yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64 -y

    [root@localhost ~]# rm -rf /etc/httpd/conf.d/welcome.conf
    [root@localhost ~]# echo "<?php phpinfo();?>" > /var/www/html/index.php
    [root@localhost ~]# vi /etc/httpd/conf/httpd.conf

    <IfModule dir_module>
    DirectoryIndex index.html index.php  #添加index.php 使支持.php文件
    </IfModule>

    [root@localhost ~]# systemctl restart httpd
    二、伪静态开启
    访问http://localhost/;在PHP的信息页中的apache2handler字段搜索是否有mod_rewrite字段,如果有进行下一步
    开启重写功能 AllowOverride none 改为 AllowOverride ALL;
    [root@localhost html]# vi /etc/httpd/conf/httpd.conf

    <Directory "/var/www/html">
    ...
    Options Indexes FollowSymLinks
    ...
    AllowOverride ALL
    ...
    Require all granted
    </Directory>

    [root@localhost html]# systemctl restart httpd 

    三、测试是否成功
    [root@localhost html]# touch .htaccess

    [root@localhost html]# cat /var/www/html/.htaccess 
    RewriteEngine on
    RewriteRule index.html index.php

    访问http://127.0.0.1/index.html
    成功证明伪静态开启

  • 相关阅读:
    字符串转换的UnicodeDecodeError—— ‘\xa0’问题
    linux下nginx+uwsgi部署python应用
    字符串转换的UnicodeDecodeError—— ‘\xa0’问题
    python的get和post方式请求详解
    MindManager使用说明
    进入程序员的自由天地
    悦读上品 得乎益友
    C++ 是一门难学易用的语言!
    合上More Exceptional C++的瞬间
    从零开始学ASP.NET
  • 原文地址:https://www.cnblogs.com/gaoyuanzhi/p/8269468.html
Copyright © 2011-2022 走看看