apache

最后更新于:2022-04-02 02:34:31

[TOC] ## 安装依赖 ``` // ubuntu 安装依赖 sudo apt install autoconf libtool // centos 安装依赖 yum -y install gcc gcc-c++ openldap-devel libtool ``` ## 安装 apache ### 编译 apache
编译apache ``` wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.46.tar.gz \ && wget https://archive.apache.org/dist/apr/apr-1.7.0.tar.gz \ && wget https://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz \ && wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz tar -zxvf apr-1.7.0.tar.gz \ && cd apr-1.7.0 \ && ./buildconf \ && ./configure --prefix=/usr/local/apr \ && make && make install //安装 apr-util tar -zxvf apr-util-1.5.4.tar.gz \ && cd apr-util-1.5.4 \ && ./buildconf --with-apr=../apr-1.7.0 \ && ./configure --prefix=/usr/local/apr-util \ --with-apr=/usr/local/apr/ \ --with-ldap=ldap \ && make && make install //安装 pcre tar -zxvf pcre-8.43.tar.gz \ && cd pcre-8.43 \ && ./configure --prefix=/usr/local/pcre \ && make && make install //安装 apache tar -zxvf httpd-2.4.46.tar.gz \ && cd httpd-2.4.46 ./configure --prefix=/usr/local/apache/ \ --enable-so \ --enable-rewrite \ --with-mpm=event \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util/ \ --with-pcre=/usr/local/pcre/ \ && make -j3 && make install // 修改权限 chown -R web apache/ vi apache/conf/httpd.conf /* User web Group web */ ```

### 修改配置 ``` ServerRoot "./"; # 正确的路径,若错误先错误则改为绝对路径 DirectoryIndex index.php index.html # 添加 index.php LoadModule php5_module modules/libphp5.so AddType application/x-httpd-php .php Include conf/vhost/*.conf ``` 添加站点
vhost/im_site.conf ``` # 声明一个端口 Listen 8010 Define SITE_NAME www DocumentRoot ../${SITE_NAME} ServerName default:8010 ErrorLog logs/${SITE_NAME}-error_log Options FollowSymLinks AllowOverride All Require all granted ```

### 启动 apache / 开启启动 ``` // 启动 > /usr/local/apache/bin/apachectl -k restart // 开启启动 > echo "/usr/local/apache/bin/apachectl -k start >> /dev/null" /etc/rc.d/rc.local ``` ## 问题 ### rm: cannot remove 'libtoolT': No such file or directory ``` vim configure 删除这行 $RM "$cfgfile" ```
';