zoukankan      html  css  js  c++  java
  • apache--安装

    Centos7默认已经安装httpd服务,只是没有启动。

    如果你需要全新安装apache,可以yum install -y httpd

    启动服务:systemctl start httpd.service

    重启Apache服务了

    查看状态

    httpd

    [root@iZj6c6r59dfzz11wmsqiinZ ~]# systemctl stop httpd

    [root@iZj6c6r59dfzz11wmsqiinZ ~]# systemctl start httpd

    [root@iZj6c6r59dfzz11wmsqiinZ ~]# systemctl restart httpd

    systemctl status xxx.service  // 查看xxx服务启动状态

    ps -ef|grep httpd

    服务查看:chkconfig --list

    设置开机自动启动:systemctl enable httpd.service

    端口查看: netstat -ntlp

    测试Apache

    安装完成Apache后,我们可以使用http://你的服务器ip/测试访问Apache,如果能显示如下图,则说明Apache已经安装成功。

    测试:http://47.52.21.163/

    安装路径

    服务目录 /etc/httpd
    主配置文件 /etc/httpd/conf/httpd.conf
    网站数据目录 /var/www/html
    访问日志 /var/log/httpd/access_log
    错误日志 /var/log/httpd/error_log

    主配置文件: vim /etc/httpd/conf/httpd.conf

    在httpd服务程序主配置文件中最为常用的参数包括有:

    ServerRoot 服务目录
    ServerAdmin 管理员邮箱
    User 运行服务的用户
    Group 运行服务的用户组
    ServerName 网站服务器的域名
    DocumentRoot 网站数据目录
    Listen 监听的IP地址与端口号
    DirectoryIndex 默认的索引页页面
    ErrorLog 错误日志文件
    CustomLog 访问日志文件
    Timeout 网页超时时间,默认为300秒.
    Include 需要加载的其他文件

    修改Apache默认网站路径

    Apache安装好后,默认的网站路径是/var/www/html,也就是说以后我们想部署网站的话,必须把文件放到这个目录下,例如我们下面测试一下。

    echo "你好,测试Apache 首页 By Drmeng 2017.7.25" > /var/www/html/index.html

    Include conf/extra/httpd-vhosts.conf

    Require all granted

    访问文件夹没有权限问题

    Forbidden

    You don't have permission to access /ThinkPHP/ on this server.

    Apache/2.4.6

    AddDefaultCharset UTF-8  修改为:AddDefaultCharset GB2312 #添加GB2312为默认编码

    都改成All
    AllowOverride All
     目录不能生成比如HOME   得手动创建

    1. ServerSignature On => ServerSignature Off  // 配置错误页不显示Apache版本
    2. Options Indexes FollowSymLinks => Options FollowSymLinks  // 配置Apache不能通过目录层级进行文件访问
    3. AllowOverride None => AllowOverride All  // 配置允许.htaccess
    4. DirectoryIndex index.html => DirectoryIndex index.html index.php  // 配置Apache支持.php文件解析

              更改目录权限

              chmod -R 777 /opt/soft/phpwork/www/puhui

             没啥用----------------------------

             //chmod -R 755 /opt/soft/phpwork/www/ThinkPHP

     

    1. chmod -755 /var/www/html/Fancy  // 修改Fancy目录的操作权限
    2. cut -: -1 /etc/passwd  // 查看当前系统中所有用户,找到Apache对应的用户名,可能是apache或www
    3. chown -R apache /var/www/html/Fancy  // 修改apache用户可操作Fancy目录
    4. --------------------------------------

    配置
    PHP的配置文件是php.ini, 通过yum安装的PHP会自动保存在/etc/php.ini下,同样通过cp进行备份后,通过vi进行编辑
    配置项:

      1. ;date.timezone => date.timezone = PRC // 配置时区,把前面的分号去掉
      2. short_open_tag = OFF => short_open_tag = ON // 配置支持短标签, TP和部分php组件需要使用到

    若缺少以上的操作,则配置完访问网站时会出现Permission denied的错误提醒。

    apache  允许局域网其他机器访问

    httpd-vhosts.conf

    <VirtualHost *:80>
        ServerName localhost
        DocumentRoot D:/soft/php/wamp64/www
        <Directory  "D:/soft/php/wamp64/www/">
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>

    卸载

    https://blog.csdn.net/weixin_35110758/article/details/113710989?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase

  • 相关阅读:
    C3P0连接池详解及配置
    解决a different object with the same identifier value was already associated with the session错误
    sudo su 提示没有配置JDK environment
    MySQL 5.6 双机热备
    如何用myeclispe远程调试tomcat
    Incorrect string value: '\xF0\xA1\xA1\x92' for column 'herst' at row 1
    Mysql 慢查询设置
    Mysql的主从数据库没有同步的解决办法
    新的启程
    ASP.NET程序中常用的三十三种代码
  • 原文地址:https://www.cnblogs.com/jentary/p/14479946.html
Copyright © 2011-2022 走看看