- 近期玩 Apache mysql redis 等,so把遇到的坑给总结了下,一步步的安装如果还遇到问题,文章下面留言就好,一起交流。。。不多说了了,开始浪。。。。。。
- 安装好centos 7系统后需要配置下ip等信息,
- vi /etc/sysconfig/network-scripts/ifcfg-eth0
- BOOTPROTO=static
- 网卡获得ip地址的方式,Static(静态 ip地址)dhcp(通过dhcp协议获取ip)
- HWADDR=00:50:56:8E:47:EE 网卡物理地址
- IPADDR=10.0.0.193 网卡IP地址
- IPV6INIT=no 是否启用IPV6
- IPV6_AUTOCONF=no
- NETMASK=255.255.255.0 网卡对应网络掩码
- NETWORK=192.168.1.0 网卡对应的网络地址
- ONBOOT=yes 系统启动时是否设置此网络接口,设置为yes时,系统启动时激活此设备。默认设置为yes
- service network restart 重启服务或者 /etc/init.d/network restart
- 你需要改的就是 IPADDR DNS1 GATEWAY DEVICE ,安装自己的机子修改就好
- 修改完后,service network restart 然后ping 下百度,看能ping通不,如果能ping通就代表你能上网了,
- 下一步关闭防火墙,centos7的墙 是firewall
- systemctl stop firewalld.service #停止firewall
- systemctl disable firewalld.service #禁止firewall开机启动
- firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
- 下一步上传apache 依赖包 首先 cd 到根目录 然后新建tools文件夹 ,mkdir tools ,将依赖包以及apache文件上传到tools 下面apr-1.6.3.tar.gz 、apr-util-1.6.1.tar.gz、pcre-8.41.zip、openssl-1.0.2n.tar.gz、httpd-2.4.29.tar.gz。
- 开始解压:
- tar -xzvf apr-1.6.3.tar.gz
- tar -xzvf apr-util-1.6.1.tar.gz
- 需要先安装uzip yum install -y unzip zip
- unzip pcre-8.41.zip
- 安装apr-1.6.3
- 进入安装目录
- cd /tools/apr-1.6.3/
- 安装及编译
- 先安装 gcc yum -y install gcc
- ./configure --prefix=/usr/local/apr
- 会出现rm: cannot remove 'libtoolT': No such file or director
- cd apr-1.6.3
- 修改
- vi configure
- 9365 #RM=$ac_cv_prog_RM
- 9355 #ac_cv_prog_RM="rm"
- make && make install 就不会报错了。
- 进入安装目录
- cd /tools/apr-util-1.6.1/
- yum install -y libxml2-devel
- ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/bin/apr-1-config
- 在CentOS7最小安装版下,编译安装apr-util时报错:
- fatal error: expat.h: No such file or director
- 解决办法:yum install expat-devel
- make && make install
- 进入安装目录
- cd /tools/pcre-8.41/
- 安装及编译
- yum -y install gcc+ gcc-c++
- ./configure --prefix=/usr/local/pcre
- make && make install
- 进入安装目录
- tar -xvf openssl-1.0.2n.tar.gz
- cd openssl-1.0.2n
- 需要先安装yum install perl*
- ./config -fPIC --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
- make && make install
- 在线安装gcc
- #yum install gcc*
- cd /tools 将安装包httpd-2.4.29.tar.gz拷至/tools目录下
- #tar zxvf httpd-2.4.29.tar.gz
- #cd /tools/httpd-2.4.29
- yum install zlib-devel
- ./configure --prefix=/opt/apache/apache-2.4.29 --enable-deflate --enable-expires --enable-headers --enable-ssl --enable-cgi --with-zlib --with-mpm=worker --enable-so --enable-rewrite --enable-module=shared --enable-mods-shared=most ap_cv_void_ptr_lt_long=no --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-ssl=/usr/local/openssl --enable-unique --enable-unique_id
- make && make install but后报错
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler'
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate'
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler'
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserFree'
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetUserData'
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_StopParser'
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_Parse'
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ErrorString'
- /usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
- collect2: error: ld returned 1 exit status
- make[2]: *** [htpasswd] Error 1
- make[2]: Leaving directory `/usr/local/httpd-2.4.26/support'
- make[1]: *** [all-recursive] Error 1
- make[1]: Leaving directory `/usr/local/httpd-2.4.26/support'
- make: *** [all-recursive] Error 1
- ①安装libxml2-devel
- 1 [root@test_01 ~]# yum install -y libxml2-devel
- ②删除apr-util目录并且重新编译安装
- 1
- 2
- 3
- 4
- 5
- [root@test_01 ~]#rm -rf /usr/local/apr-util
- [root@test_01 ~]# cd /tools/apr-util-1.6.1/
- [root@test_01 apr-util-1.6.1]# make clean
- [root@test_01 apr-util-1.6.1]#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
- [root@test_01 apr-util-1.6.1]#make && make install
- 重新编译下apache 然后安装就ok 了
- 进入安装后目录:
- # cd /opt/apache/apache-2.4.29/bin
- 检查进程模式:
- # ./apachectl -l
- Compiled in modules:
- core.c
- worker.c
- http_core.c
- mod_so.c
- 启动Apache Web Server:
- #./apachectl start
- ServerName localhost:80
- 然后浏览器打开地址就会出现 it works 了
- 下面开启做apache 开机启动
- 停止Apache Web Server:
- #./apachectl stop
- 1.将apachectl文件copy到/etc/init.d中,然后再/etc/rc.d/rc5.d中加入链接。
- 命令如下:
- cp /opt/apache/apache-2.4.29/bin/apachectl /etc/init.d/httpd
- ln -s /etc/init.d/httpd /etc/rc.d/rc5.d/S85httpd
- 2.运行chkconfig --list 发现列表中没有httpd,通过chkconfig --add httpd来添加,可能会提示httpd服务不支持chkconfig,需要编辑/etc/rc.d/init.d/httpd
- 添加以下注释信息:
- # chkconfig: 345 85 15
- # description: Activates/Deactivates Apache Web Server
- 345代表哪些linux级别需要启动httpd, 启动序号是85, 关闭序号是15
- 3.运行chkconfig --list,httpd 就存在了,可以使用service httpd start 和 service httpd stop来启动和停止服务
- 开机启动
- chkconfig --level 2345 httpd on
- 教程写完了,有遇到apache的问题可以,留言相互交流。。。
文章评论