Ubuntu源码安装Ubuntu。
编译安装软件前第一步,安装GCC。
dell@Ubuntu1601:~$ sudo apt install gcc
下载Apache、APR和APR-util源代码。
下载Apache、APR和APR-util。
#下载Apache dell@Ubuntu1601:wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.25.tar.gz #下载APR dell@Ubuntu1601:wget http://apache.fayea.com//apr/apr-1.5.2.tar.gz #下载APR-util dell@Ubuntu1601:http://apache.fayea.com//apr/apr-util-1.5.4.tar.gz
dell@Ubuntu1601:~$ tar -zxvf apr-1.5.2.tar.gz dell@Ubuntu1601:~$ cd apr-1.5.2/ dell@Ubuntu1601:~/apr-1.5.2$ ./configure --prefix=/usr/local/apr/ dell@Ubuntu1601:~/apr-1.5.2$ make dell@Ubuntu1601:~/apr-1.5.2$ sudo make install
解压安装APR-util。
dell@Ubuntu1601:~$ tar -zxvf apr-util-1.5.4.tar.gz dell@Ubuntu1601:~$ cd apr-util-1.5.4/ dell@Ubuntu1601:~/apr-util-1.5.4$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ dell@Ubuntu1601:~/apr-util-1.5.4$ make dell@Ubuntu1601:~/apr-util-1.5.4$ sudo make install
下载安装PCRE,注意不是PCRE2。
#下载地址 https://sourceforge.net/projects/pcre/ http://pcre.org/ #下载源代码文件 dell@Ubuntu1601:~$ wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.zip dell@Ubuntu1601:~$ unzip pcre-8.40.zip dell@Ubuntu1601:~$ cd pcre-8.40/ dell@Ubuntu1601:~/pcre-8.40$ ./configure --prefix=/usr/local/pcre dell@Ubuntu1601:~/pcre-8.40$ make dell@Ubuntu1601:~/pcre-8.40$ sudo make install
下面开始安装Apache2。
dell@Ubuntu1601:~$ tar -zxvf httpd-2.4.25.tar.gz dell@Ubuntu1601:~$ cd httpd-2.4.25/ dell@Ubuntu1601:~/httpd-2.4.25$ pwd /home/dell/httpd-2.4.25 #建议根据版本号设置目录。例如 dell@Ubuntu1601:~/httpd-2.4.25$ ./configure --prefix=/usr/local/apache2 --with-apr-util=/usr/local/apr-util/ --with-apr=/usr/local/apr/ --with-pcre=/usr/local/pcre/ dell@Ubuntu1601:~/httpd-2.4.25$ make dell@Ubuntu1601:~/httpd-2.4.25$ sudo make install
#主要Apache2配置项 #--sysconfdir=/etc/httpd24 指定配置文件安装路径 #--enable-so 启动模块动态装卸载 #--enable-ssl 编译ssl模块 #--enable-cgi 支持cgi #--enable-rewrite 支持url重写 #--with-zlib 支持数据包压缩 #--with-pcre 支持正则表达式 #--with-apr=/usr/local/apr apr目录 #--with-apr-util=/usr/local/apr-util/ apr-util目录 #--prefix=/usr/local/pcre PCRE目录 #--enable-mpms-shared=all #--with-mpm=prefork 指明httpd工作方式是prefork #配置示例 # ./configure \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --prefix=/usr/local/apache \ --sysconfdir=/etc/httpd24 \ --enable-so \ --enable-ssl \ --enable-cgi \ --enable-rewrite \ --with-zlib \ --with-pcre \ --with-mpm=prefork \ --enable-modules=most \ --enable-mpms-shared=all
至此Apache2安装完毕。开始配置Apache。 Apache启动文件是/usr/local/apache2/bin/apachectl。
dell@Ubuntu1601:/etc/init.d$ sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/ dell@Ubuntu1601:/etc/init.d$ ls acpid cron lvm2 plymouth-log skeleton alsa-utils cups lvm2-lvMetad pppd-dns speech-dispatcher anacron cups-browsed lvm2-lvmpolld procps ssh apachectl dbus mountall-bootclean.sh rc thermald apparmor grub-common mountall.sh rc.local udev apport halt mountdevsubfs.sh rcS ufw avahi-daemon hostname.sh mountkernfs.sh README umountfs bluetooth hwclock.sh mountnfs-bootclean.sh reboot umountnfs.sh bootmisc.sh irqbalance mountnfs.sh resolvconf umountroot brltty kerneloops networking rsync unattended-upgrades checkfs.sh keyboard-setup.dpkg-bak network-manager rsyslog urandom checkroot-bootclean.sh killprocs ondemand saned uuidd checkroot.sh kmod openvpn sendsigs whoopsie console-setup lightdm plymouth single x11-common dell@Ubuntu1601:/etc/init.d$
启动服务报错。
dell@Ubuntu1601:/etc/init.d$ /etc/init.d/apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name,using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message (13)Permission denied: AH00072: make_sock: could not bind to address [::]:80 (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available,shutting down AH00015: Unable to open logs dell@Ubuntu1601:/etc/init.d$ sudo /etc/init.d/apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name,using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message dell@Ubuntu1601:/etc/init.d$ #解决方法 #进入Apache安装目录。本文安装目录是 /usr/local/apache2/,修改文件注意备份文件 dell@Ubuntu1601:~$ cd /usr/local/apache2/conf/ dell@Ubuntu1601:/usr/local/apache2/conf$ sudo cp httpd.conf httpd.conf.bak dell@Ubuntu1601:/usr/local/apache2/conf$ sudo vim httpd.conf #编辑httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80 dell@Ubuntu1601:~$ sudo /etc/init.d/apachectl start httpd (pid 7753) already running dell@Ubuntu1601:~$
浏览器输入Apache服务器IP地址,看到It works!,说明安装成功。
至此Apache全部安装完成。
原文链接:https://www.f2er.com/ubuntu/353890.html