如何在Ubuntu 16.04上使用源代码中的apache2.4.28 complile时安装PHP5.6?
我尝试从源代码编译Apache 2.4.28,我无法使用命令
apt-get install apache2
因为此命令仅安装Apache 2.4.18。
这是我的安装步骤:
-
安装依赖
apt-get install build-essential apt-get install libexpat1-dev apt-get install libpcre3-dev libssl-dev
-
下载apache2.4.28
cd /usr/local/src wget http://mirrors.viethosting.com/apache//apr/apr-1.6.2.tar.gz wget http://mirrors.viethosting.com/apache//apr/apr-util-1.6.0.tar.gz wget http://archive.apache.org/dist/httpd/httpd-2.4.28.tar.gz
-
编译apache 2.4.28
tar xzvf apr-1.6.2.tar.gz tar xzvf apr-util-1.6.0.tar.gz tar xzvf httpd-2.4.28.tar.gz mv apr-1.6.2/ httpd-2.4.28/srclib/apr mv apr-util-1.6.0/ httpd-2.4.28/srclib/apr-util ./configure --prefix=/etc/apache2 --enable-mods-shared="reallyall" --enable-mpms-shared="all"
make && make install
ln -s /etc/apache2/bin/apachectl /etc/init.d/apache update-rc.d apache defaults----> It has this warning "insserv: warning: script 'apache' missing LSB tags and overrides" service apache start
执行上述步骤后,Apache 2.4.28已运行。 但我在使用的时候
apache2 -v ----> it's not show the version of apache2
然后我像这样安装PHP5.6:
apt-get install software-properties-common add-apt-repository ppa:ondrej/php apt-get update apt-get install php5.6
当我使用这个命令时,它不仅安装php5.6,还安装apache2.4.18,当我测试PHP时:
echo "hello world"; ----> it not show any thing.
和
root@ubuntu:~# ps -aux | grep httpd root 991 0.0 0.1 75268 3848 ? Ss 02:47 0:00 /usr/local/apache2/bin/httpd -k start
@Edit:作为我改变的评论:
./configure --prefix=/etc/apache2 --enable-mods-shared="reallyall" --enable-mpms-shared="all"
至
./configure --prefix=/usr/local/apache2 --enable-mods-shared="reallyall" --enable-mpms-shared="all"
请帮帮我,谢谢。
我相信你做错了几件事。 首先这一行:
./configure --prefix=/etc/apache2 --enable-mods-shared="reallyall" --enable-mpms-shared="all"
本来应该:
./configure --prefix=/usr/local/apache2" --enable-mods-shared="reallyall" --enable-mpms-shared="all"
编译期间的--prefix
选项是错误的。 我建议你删除它并修复--prefix
选项
如何编译:
-
下载所需版本的源文件
-
安装构建要求:
sudo apt-get install build-essential
-
使用以下步骤安装
Zlib
以进行压缩:cd /usr/local/src wget http://www.zlib.net/zlib-1.2.8.tar.gz tar xvfz zlib-1.2.8.tar.gz cd zlib-1.2.8/ ./configure --prefix=/usr/local make
-
使用以下步骤编译apache:
-
将下载的
apache
源文件移动到/usr/local/src
,然后cd /usr/local/src tar xvfz httpd-2.4.10.tar.gz cd httpd-2.4.10/ sudo ./configure
-
如果您收到
APR
错误:sudo apt install libapr1-dev libaprutil1-dev
-
-
如果成功运行:
sudo make sudo make install
-
-
检查它是否有效:
sudo /usr/local/apache2/bin/apachectl start
- 把
http://localhost
或你的机器ip地址放在一起,你会看到一条消息“它有效!”
- 把
-
启用
boot startup
:sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apache2 sudo chmod +x /etc/init.d/apache2
-
添加到默认
runlevels
:sudo /usr/sbin/update-rc.d -f apache2 defaults
资源:
http://www.linuxpathfinder.com/install-apache-from-source-on-ubuntu
哎呀…构建Apache + PHP可以完成+构建过程可能很长+容易出错。
以下是我使用最新的稳定PPA安装最新的Apache +和PHP的方法,当它稳定运行时,可以很容易地在5.6或7.0或7.1 +之间切换7.2。
我在LXD容器中执行此操作,因此机器(主机级别)仅包含默认代码+ LXD +无LAMP堆栈代码。
这是我如何安装最新稳定的LXD + Apache + MariaDB + PHP(5.6)+ OpenSSL + HTTP2 + FPM(现在运行HTTP2所需)+ Dovecot。
我用来设置客户端托管LXD容器LAMP堆栈的步骤……
# Setup repositories, some of which require a bit of trickery add-apt-repository ppa:ubuntu-lxc/lxd-stable < /dev/null LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php /etc/apt/sources.list.d/mariadb-$(lsb_release -sc).list apt-get update # Install PHP-5.6 based LAMP apt-get install mariadb-server mariadb-client libmysqlclient-dev apt-get install php5.6-fpm php5.6-cli php5.6-mbstring php5.6-zip \ php5.6-mysql php5.6-curl php5.6-xml php5.6-xmlrpc \ php5.6-gd php5.6-soap php5.6-gmp php5.6-pspell \ php5.6-sqlite3 php5.6-tidy php5.6-xsl php5.6-bz2 \ php5.6-tidy php5.6-bcmath php5.6-bz2 php5.6-dba a2enmod mpm_event proxy_fcgi setenvif alias cgid ssl http2 \ expires headers include rewrite a2enconf php5.6-fpm # update PHP CLI, when multiple versions installed update-alternatives --set php /usr/bin/php5.6 # tune FPM pool + php.ini + opcache.ini + xdebug.ini + cold restart FPM service service php5.6-fpm
采用这种方法将为您提供最新的稳定的Apache + PHP + OpenSSL +作为打包代码(无需手动编译)。
当发现错误时,您还将获得上游错误修复。
如果您自己动手,您将不得不经常检查许多差异邮件列表,以了解何时重建+如何应用补丁…这是另一个大规模耗时的努力。
BTW,Apache-2.4.28刚刚在上周发布,因此这个Apache版本将在打包和代码测试后立即出现在ondrej PPA中。
可能在本周或下周某个时候,所以你最终会安装Apache-2.4.27。