php 和 apache 源码编译安装

groupadd www
useradd -g www www

groupadd mysql
useradd -g mysql mysql

安装apache2

  • 下载httpd-2.4.27.tar.gz
    curl -O -L https://github.com/apache/httpd/archive/2.4.27.tar.gz
    curl -O -L https://github.com/apache/apr/archive/1.5.2.tar.gz
    curl -O -L https://github.com/apache/apr-util/archive/1.5.4.tar.gz

cp -r apr-1.5.2 httpd-2.4.27/srclib/apr
cp -r apr-util-1.5.4 httpd-2.4.27/srclib/apr-util

yum -y install gcc gcc-c++ pcre gd-devel* zlib-devel pcre-devel apr apr-util autoconf

yum -y install libtool libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel

yum -y install libmcrypt-devel mhash-devel libxslt-devel
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel
krb5 krb5-devel libidn libidn-devel openssl openssl-devel

cd httpd-2.4.27
./buildconf
./configure --enable-ssl --enable-so --with-mpm=event --with-included-apr --prefix=/usr/local/apache2
make

https://blacksaildivision.com/how-to-install-apache-on-centos
Add Apache httpd to $PATH
sudo vi /etc/profile.d/httpd.sh
pathmunge /usr/local/apache2/bin

./configure
--prefix=/usr/local/php7
--with-config-file-path=/usr/local/php7/etc
--with-config-file-scan-dir=/usr/local/php7/etc/php.d
--with-apxs2=/usr/sbin/apxs
--with-mcrypt=/usr/include
--enable-mysqlnd
--with-mysqli
--with-pdo-mysql
--enable-fpm
--with-gd
--with-iconv=/usr/local/libiconv
--with-zlib
--enable-xml
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--enable-mbregex
--enable-exif
--enable-mbstring
--enable-ftp
--enable-gd-native-ttf
--enable-pcntl
--enable-sockets
--with-xmlrpc
--enable-zip
--enable-soap
--without-pear
--with-gettext
--enable-session
--with-curl
--with-jpeg-dir
--with-freetype-dir
--enable-opcache
--enable-openssl \

一直提示 dial tcp i/o timeout
阿里云后台还有 “安全组配置规则”

Forbidden
You don't have permission to access /index.php on this server.

修改appche User Group 为www

安装pear
wget http://pear.php.net/go-pear.phar
mv go-pear.phar /usr/bin//pear
php pear
ln -s /usr/local/php7/bin/pear -s /usr/bin/pear
ln -s /usr/local/php7/bin/pecl /usr/bin/pecl

Below is a suggested file layout for your new PEAR installation. To
change individual locations, type the number in front of the
directory. Type 'all' to change all of them or simply press Enter to
accept these locations.

  1. Installation base ($prefix) : /usr/local/php7
  2. Temporary directory for processing : /tmp/pear/install
  3. Temporary directory for downloads : /tmp/pear/install
  4. Binaries directory : /usr/local/php7/bin
  5. PHP code directory ($php_dir) : /usr/local/php7/share/pear
  6. Documentation directory : /usr/local/php7/docs
  7. Data directory : /usr/local/php7/data
  8. User-modifiable configuration files directory : /usr/local/php7/cfg
  9. Public Web Files directory : /usr/local/php7/www
  10. System manual pages directory : /usr/local/php7/man
  11. Tests directory : /usr/local/php7/tests
  12. Name of configuration file : /usr/local/php7/etc/pear.conf

手动安装fileinfo扩展
cd /tmp/tars/php-7.1.8/ext/fileinfo/
/usr/local/php7/bin/phpize # 生成configure文件
./configure --with-php-config=/usr/local/php7/bin/php-config
make && make install

php.ini 文件
extension=fileinfo.so
/usr/local/apache2/bin/httpd -k restart

Please reinstall the iconv library

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xvzf libiconv-1.14.tar.gz
./configure --prefix=/usr/local/libiconv
make && make install

报错 error: ‘gets’ undeclared here (not in a function)
vi ./srclib/stdio.in.h
  
注释掉698这一行
/*_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");*/
  
原处添加下面3行
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
  
!注意下面还是有一个#endif

报错  undefined reference to `libiconv_open'
./configure 时指定 iconv的路径

你可能感兴趣的:(php 和 apache 源码编译安装)