因为服务器不能连接外网,所以在安装之前,我已经将所有相关的安装包上传至服务器,文件列表如下:
apr-1.5.2.tar.gz
apr-util-1.5.4.tar.gz
httpd-2.4.9.tar.gz
libxml2-2.7.8.tar.gz
pcre-8.10.tar.gz
php-7.1.0.tar.gz
如果能连接外网,也可直接下载。
安装Apache之前需要安装Perl-Compatible Regular Expressions Library (PCRE), 否则会发生类似下面的错误:
apache/bin/httpd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
1) 解压pcre
$ tar -zxvf pcre-8.10.tar.gz
2) 安装pcre
$ cd pcre-8.10
$ ./configure --prefix=/usr/local/pcre
$ make
$ sudo make install
安装PHP之前,需要先安装libxml2,否则可能会发生类似下面的错误:
configure error xml2-config not found. please check your libxml2 installation
1) 解压
$ tar -zxvf libxml2-2.7.8.tar.gz
2) 安装libxml2
$ cd libxml2-2.7.8
$ ./configure --prefix=/usr/local/libxml2
$ make
$ sudo make install
安装Apache,需要安装APR and APR-Util。否则安装Apache时会报下面的错误:
configure: error: APR not found. Please read the documentation.
1) 解压
$ tar -zxvf apr-1.5.2.tar.gz
$ tar -zxvf apr-util-1.5.4.tar.gz
$ tar -zxvf httpd-2.4.9.tar.gz
2) 将解压后的apr and apr-util包复制到Apache的安装目录的srclib目录下
$ cp ./apr-1.5.2 ./httpd-2.4.9/srclib/apr -r
$ cp ./apr-util-1.5.4 ./httpd-2.4.9/srclib/apr-util -r
3) 安装Apache
$ cd httpd-2.4.9
$ ./configure --prefix=/usr/local/apache --with-included-apr --with-pcre=/usr/local/pcre/
$ make
$ sudo make install
GD安装可以直接使用YUM进行安装
1) 检查系统是否有GD
$ rpm -qa | grep -i gd
如果没有则需要安装
2) 安装
$ sudo yum install gd-devel
如果需要还需要FreeType支持,则还需要安装FreeType
$ sudo yum install freetype*
3) 检查
安装完成之后,可以使用以下命令检查
$ rpm -qa | grep -i gd
同样的,可以使用YUM安装Mysql
1) 检查
$ rpm -qa | grep -i mysql
mysql-server和mysql都需要,还有mysql-devel开发包也需要,不然PHP无法使用MYSQL。
2) 安装
安装系统中不存在的包
$ sudo yum install mysql
$ sudo yum install mysql-devel
$ yum install mysql-server
3) 启动
$ sudo /etc/init.d/mysqld start
# 设置密码
$ mysqladmin -u root -p password 123456;
1) 解压
$ tar -zxvf php-7.1.0.tar.gz
2) 安装
通过Apache的模块来安装,
apxs: APache eXtenSion tool, 为编译和安装Apache模块的工具,以下为比较基础的安装
$ cd php-7.1.0
$ ./configure --prefix=/usr/local/php7 --with-libxml-dir=/usr/local/libxml2 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql
$ make
$ sudo make install
$ cp ~/php-7.1.0/php.ini-development /usr/local/php7/lib/php.ini
如果是需要使用GD + FreeType,则按照下面的编译安装(推荐)
$ ./configure --prefix=/usr/local/php7 --with-libxml-dir=/usr/local/libxml2 --enable-mbstring --with-apxs2=/usr/local/apache/bin/apxs --with-gd --with-mysql --with-mysqli --with-pdo-mysql --with-zlib --with-freetype-dir=/usr/include/freetype2/freetype/
$ make
$ sudo make install
$ cp ~/php-7.1.0/php.ini-development /usr/local/php7/lib/php.ini
在LoadModule处添加
LoadModule php7_module modules/libphp7.so
末尾添加
SetHandler application/x-httpd-php
sudo /usr/local/apache/bin/apachectl start
或者
sudo /usr/local/apache/bin/apachectl -f /usr/local/apache/conf/httpd.conf
1) no acceptable C compiler found in $PATH
...
configure: error: in `/home/buyabs.corp/kt94/pcre-8.10':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
解决方法:安装开发软件包组以及gcc
$ yum groupinstall "Development Tools"
$ sudo yum install gcc
2) g++: command not found
./libtool: line 990: g++: command not found
make[1]: *** [pcrecpp.lo] Error 1
解决方法:安装g++
$ sudo yum install gcc-c++
http://blog.csdn.net/yonggang7/article/details/22607721
http://blog.csdn.net/jungsagacity/article/details/7620839
http://jingyan.baidu.com/article/7082dc1ca83a2ee40a89bd9b.html
http://www.178linux.com/61405
http://stackoverflow.com/questions/19816275/no-acceptable-c-compiler-found-in-path-when-installing-python
http://stackoverflow.com/questions/36609291/installing-packages-on-centos-6-5
http://stackoverflow.com/questions/19816275/no-acceptable-c-compiler-found-in-path-when-installing-python
http://sharadchhetri.com/2013/06/19/make-command-not-found-in-linux-centos-red-hat-ubuntu-debian/
http://yhqlzz.blog.51cto.com/2557314/1058977