[TOC] ## apache ``` wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.41.tar.gz \ && wget https://archive.apache.org/dist/apr/apr-1.6.5.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 //安装gcc 等 yum -y install gcc gcc-c++ perl perl-devel openldap-devel //安装 apr tar -zxvf apr-1.6.5.tar.gz \ && cd apr-1.6.5 \ && ./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 \ && ./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.41.tar.gz \ && cd httpd-2.4.41 ./configure --prefix=/usr/local/apache2 \ --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 && make install ``` ## 问题 ### rm: cannot remove 'libtoolT': No such file or directory ``` vim configure 删除这行 $RM "$cfgfile" ``` ### 修改所有权限 ``` chown -R web apache2/ vi apache2/conf/httpd.conf /* User web Group web */ ``` ### 启动 apache `/usr/local/apache2/bin/apachectl -k restart ` ### 开启启动 `vi /etc/rc.d/rc.local` 输入一下内容 ``` /usr/local/apache2/bin/apachectl -k start >> /dev/null ``` ## php 安装 gd 库需要的库 ``` yum -y install libpng libpng-devel libjpeg libjpeg-devel ``` 编译php 需要的库 ``` yum -y install libxml2 libxml2-devel autoconf freetype freetype-devle zlib zlib-devel glibc glibc-devel glib2 glib2-devel libxml2-devel libcurl-devel freetype-devel openssl openssl-devel libmcrypt php-mcrypt libmcrypt-devel ``` ``` wget https://www.php.net/distributions/php-5.6.40.tar.gz \ && tar -zxvf php-5.6.40.tar.gz \ && cd php-5.6.40 ./configure --prefix=/usr/local/php \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-openssl \ --with-mysqli \ --with-pdo-mysql \ --enable-mbstring \ --with-zlib \ --enable-sockets \ --with-curl \ --with-pcre-regex \ --with-mcrypt=/usr/local/libmcrypt \ --with-gd \ --with-png-dir \ --with-freetype-dir \ --enable-gd-native-ttf \ --enable-opcache \ [--with-jpeg \] [--with-jpeg-dir=/usr/lib64/ \] make && make install ``` > `with-jpeg-dir=/usr/lib64/` 查看`find / -name libjpeg*` ## apache配置文件 `/usr/local/apache2/conf/httpd.conf ` ``` LoadModule php5_module modules/libphp5.so <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> ``` ### 复制php配置文件, 并编辑保存 ``` cd /usr/local/src/ cp php.ini-development /usr/local/php/lib/php.ini ``` <details> <summary>描述</summary> </details>