1. 下载apache源码
[root@mysql ~]# tar -zxvf httpd-2.4.33.tar.gz
[root@mysql httpd-2.4.33]# ./configure --prefix=/usr/local/apache2/
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... configure: WARNING: APR version 1.4.0 or later is required, found 1.3.9
configure: WARNING: skipped APR at apr-1-config, version not acceptable
no
configure: error: APR not found. Please read the documentation.
2. 安装APR
[root@mysql apr-1.6.3]# ./configure --prefix=/usr/local/apr/
make&make install
3. 安装apr-util
apr_util的安装依赖于apr,所以需要指定apr的路径
[root@mysql apr-util-1.5.1]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
make&make install
4. 安装pcre
[root@mysql pcre-8.35]# ./configure --prefix=/usr/local/pcre/
make&make install
5. 安装apache
[root@mysql httpd-2.4.33]# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make时有报错
libtool: error: cannot find the library '/usr/local/apache2//lib/libapr-1.la' or unhandled argument '/usr/local/apache2//lib/libapr-1.la'
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory `/root/httpd-2.4.33/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/httpd-2.4.33/support'
make: *** [all-recursive] Error 1
在编译前创建好目录并把apr中的相应文件复制到提示的目录/usr/local/apache2/lib
[root@mysql lib]# cp libapr-1.la /usr/local/apache2/lib
[root@mysql lib]# cp libapr-1.so /usr/local/apache2/lib
删除文件夹重新Make&make install即可
启动apache
[root@mysql bin]# apachectl start
[root@mysql bin]# service httpd status
httpd (pid 103174) is running...
[root@mysql bin]# ps -ef|grep httpd
root 103174 1 0 14:06 ? 00:00:00 /usr/sbin/httpd -k start
apache 103176 103174 0 14:06 ? 00:00:00 /usr/sbin/httpd -k start
apache 103177 103174 0 14:06 ? 00:00:00 /usr/sbin/httpd -k start
apache 103178 103174 0 14:06 ? 00:00:00 /usr/sbin/httpd -k start
apache 103179 103174 0 14:06 ? 00:00:00 /usr/sbin/httpd -k start
apache 103180 103174 0 14:06 ? 00:00:00 /usr/sbin/httpd -k start
apache 103181 103174 0 14:06 ? 00:00:00 /usr/sbin/httpd -k start
apache 103182 103174 0 14:06 ? 00:00:00 /usr/sbin/httpd -k start
apache 103183 103174 0 14:06 ? 00:00:00 /usr/sbin/httpd -k start
root 103201 9310 0 14:06 pts/8 00:00:00 grep httpd
浏览器访问
[root@mysql mod_wsgi-4.6.4]# ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/bin/python
make&make install
报错
/usr/local/python-2.7.14/lib/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
.
make: *** [src/server/mod_wsgi.la] Error 1
这是由于安装python2.7时没有加入--enable-shared参数,安装mod_wsgi时就会报如下错误:"recompile with -fPIC"
重新编译安装python2.7即可
./configure --prefix=/usr/local/python-2.7.14 -enable-shared CFLAGS=-fPIC
接着再安装mod_wsgi成功