[TOC] ## apache ``` wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.41.tar.gz wget http://mirror.bit.edu.cn/apache/apr/apr-1.7.0.tar.gz wget http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz yum -y install gcc gcc-c++ perl perl-devel //安装 apr tar -zxvf apr-1.7.0.tar.gz cd apr-1.7.0 ./configure --prefix=/usr/local/apr make && make install //安装 apr-util tar -zxvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ 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 --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/ make && make install ``` ### 修改所有权限 ``` 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 ``` ``` cd /usr/local/src/ wget https://www.php.net/distributions/php-5.6.39.tar.gz tar -zxvf php-5.6.39.tar.gz cd php-5.6.39 ./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 make && make install ``` ## 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 ```