[toc]php
扩展 apache dso https://yq.aliyun.com/articles/6298html
apache apxs http://man.chinaunix.net/newsoft/ApacheMenual_CN_2.2new/programs/apxs.htmlmysql
apache工做模式 http://www.cnblogs.com/fnng/archive/2012/11/20/2779977.htmllinux
[root@xavi ~]# cd /usr/local/src/ [root@xavi src]#wget https://downloads.mariadb.com/MariaDB/mariadb-10.2.6/bintar-linux-glibc_214-x86_64/mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
由于MariaDB的二进制包镜像源在国外地址,因此预先下载了该包到本地物理机,使用lrzsz工具将该包上传至虚拟机/usr/local/src目录进行安装。nginx
[root@xavi src]# yum install -y lrzsz [root@xavi src]# rz
[root@xavi src]# tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz [root@xavi src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
① cd /usr/local/mariadb/sql
② cd $! //上一条指令移动到的位置就是该路径,全部可实现数据库
③ cd ../mariab //当前src的路径和mariab相同因此能实现apache
[root@xavi src]# cd /usr/local/mariadb/ [root@xavi mariadb]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb --datadir=/data/mariadb
[root@xavi mariadb]# echo $? 0
[root@xavi mariadb]# ls /data/mariadb/ aria_log.00000001 ibdata1 mysql aria_log_control ib_logfile0 performance_schema ib_buffer_pool ib_logfile1 test [root@xavi mariadb]# ls /data/mysql/ auto.cnf localhost.localdomain.err xavi.err ibdata1 mysql xavi.pid ib_logfile0 performance_schema ib_logfile1 test
[root@xavi mariadb]# ls bin data include mysql-test share COPYING DESTINATION INSTALL-BINARY README.md sql-bench COPYING.thirdparty docs lib README-wsrep support-files CREDITS EXCEPTIONS-CLIENT man scripts
进入support-files目录,发现其和mysql下的support-files是有区别的vim
[root@xavi mariadb]# ls support-files/ binary-configure my-innodb-heavy-4G.cnf my-small.cnf mysql.server wsrep_notify magic my-large.cnf mysqld_multi.server policy my-huge.cnf my-medium.cnf mysql-log-rotate wsrep.cnf
[root@xavi mariadb]# vim support-files/my-small.cnf
打开后有不少参数 windows
[root@xavi mariadb]# free total used free shared buff/cache available Mem: 1867292 625788 973228 9120 268276 1045700 Swap: 3905532 0 3905532
[root@xavi mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
basedir=/usr/local/mariadb datadir=/data/mariadb
[root@xavi mariadb]# cp support-files/mysql.server /etc/init.d/mariadb [root@xavi mariadb]# vim /etc/init.d/mariadb
[root@xavi mariadb]# ps aux |grep mysql root 1073 0.0 0.0 115392 1668 ? S 20:39 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/xavi.pid mysql 1354 0.2 24.5 1368672 458540 ? Sl 20:39 0:11 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/xavi.err --pid-file=/data/mysql/xavi.pid root 3762 0.0 0.0 112676 976 pts/0 S+ 21:55 0:00 grep --color=auto mysql [root@xavi mariadb]# ps aux |grep mariadb root 3764 0.0 0.0 112676 972 pts/0 S+ 21:55 0:00 grep --color=auto mariadb
[root@xavi mariadb]# /etc/init.d/mariadb start Reloading systemd: [ 肯定 ] Starting mariadb (via systemctl): [ 肯定 ] [root@xavi mariadb]# ps aux |grep mariadb root 3693 0.0 0.0 112676 972 pts/0 S+ 21:50 0:00 grep --color=auto mariadb
[root@xavi mariadb]# ps aux |grep mysql root 1073 0.0 0.0 115392 1668 ? S 20:39 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/xavi.pid mysql 1354 0.2 24.5 1302876 458540 ? Sl 20:39 0:10 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/xavi.err --pid-file=/data/mysql/xavi.pid root 3478 0.0 0.0 112676 976 pts/0 S+ 21:48 0:00 grep --color=auto mysql
[root@xavi mariadb]# service mysqld stop Shutting down MySQL.. SUCCESS! [root@xavi mariadb]# service mariadb start Starting mariadb (via systemctl): [ 肯定 ]
[root@xavi mariadb]# ps aux |grep mariadb root 3990 0.1 0.0 115392 1720 ? S 22:06 0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mariadb --pid-file=/data/mariadb/xavi.pid mysql 4112 1.4 3.1 1585872 58176 ? Sl 22:06 0:00 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/data/mariadb --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mariadb/xavi.err --pid-file=/data/mariadb/xavi.pid --socket=/tmp/mysql.sock --port=3306
[root@xavi mariadb]# netstat -lntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2183/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1045/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1044/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1597/master tcp6 0 0 :::3306 :::* LISTEN 4112/mysqld tcp6 0 0 :::111 :::* LISTEN 1/systemd tcp6 0 0 :::22 :::* LISTEN 1045/sshd tcp6 0 0 ::1:631 :::* LISTEN 1044/cupsd tcp6 0 0 ::1:25 :::* LISTEN 1597/master
这个没法解释,单从3306端口来看mariadb应该是启动了--这里是由于配置过程当中mysql和mariadb的socket配置都是同样,没有改3306变端口.
[root@xavi mariadb]# killall mysqld [root@xavi mariadb]# ps aux |grep mysql root 4566 0.0 0.0 112676 976 pts/0 R+ 22:39 0:00 grep --color=auto mysql [root@xavi mariadb]# service mariadb start Starting mariadb (via systemctl): [ 肯定 ]
老师有个问题:(视频中的问题,在安装php配置是待验证)
若是我指定的数据库是mariadb,php编译时,提示没有libmysqlclient_r.so;确实mariadb安装后其/lib目录下是没有这个模块的 那该怎么办呢 error: Cannot find libmysqlclient_r under /usr/local/mysql. Note that the MySQL client library is not bundled anymore!
解决办法是作个软连接 ln -s /usr/local/mysql/lib/libmariadb.so.3 /usr/local/mysql/lib/libmysqlclient_r.so
[root@localhost ~]# hostnamectl set-hostname xavi [root@localhost ~]# [root@localhost ~]# init 6
重启后,即[root@xavi ~]#
Apache实际上是一个软件基金会组织的名字,早期他们开发的Web Server软件很是流行,当时的名字就叫作Apache,不事后来更名字叫作httpd了。
htppd目前主流版本是2.4,咱们先来2.4入手。2.2和2.4安装不太同样。2.4须要依赖软件apr。apr和apr-util是一个通用的函数库,它让httpd能够不关心底层的操做系统平台,能够很方便地移植(从linux移植到windows)
[root@xavi mariadb]# cd /usr/local/src [root@xavi src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz //2.4源码包 [root@xavi src]# wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz //apr-1.6.3r包 [root@xavi src]# wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz //apr-util-1.6.1包
[root@xavi src]# ls apr-1.6.3 httpd-2.4.29.tar.gz apr-1.6.3.tar.gz mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz apr-util-1.6.1 mysql-5.5.55 apr-util-1.6.1.tar.gz mysql-5.5.55.tar.gz httpd-2.4.29 mysql-5.6.36-linux-glibc2.5-x86_64.tar.g
[root@xavi src]# tar zxvf httpd-2.4.29.tar.gz [root@xavi src]# tar zxvf apr-1.6.3.tar.gz [root@xavi src]# tar zxvf apr-util-1.6.1.tar.gz
apr(包含apr和apr-unit)能够理解成一个通用的函数库,主要为上层应用提供支持,这里,httpd是依赖apr和apr-util的,若是不安装这两个东西,httpd就没法工做
[root@xavi src]# cd /usr/local/src/apr-1.6.3 [root@xavi apr-1.6.3]# ./configure --prefix=/usr/local/apr //执行配置命令 [root@xavi apr-1.6.3]# echo $? 0 //确认有无错误
[root@xavi apr-1.6.3]# make && make install
查看apr下有4个目录
[root@xavi apr-1.6.3]# ls /usr/local/apr bin build-1 include lib
[root@xavi apr-1.6.3]# cd ../apr-util-1.6.1/ [root@xavi apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr [root@xavi apr-util-1.6.1]# make && make install
xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录 #include <expat.h> ^ 编译中断。 make[1]: *** [xml/apr_xml.lo] 错误 1 make[1]: 离开目录“/usr/local/src/apr-util-1.6.1” make: *** [all-recursive] 错误 1
[root@xavi apr-util-1.6.1]# yum install -y expat*
[root@xavi apr-util-1.6.1]# echo $? 0 [root@xavi apr-util-1.6.1]# ls /usr/local/apr-util/ bin include lib
[root@xavi apr-util-1.6.1]# cd .. [root@xavi src]# cd httpd-2.4.29
[root@xavi httpd-2.4.29]# ./configure\ --prefix=/usr/local/apache2.4\ --with-apr=/usr/local/apr\ --with-apr-util=/usr/local/apr-util\ --enable-so --enable-mods-shared=most\
解析:
报错:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[root@xavi httpd-2.4.29]# yum list |grep pcre
[root@xavi httpd-2.4.29]# yum install -y pcre--devel
安装成功
[root@xavi apr-util-1.6.1]# cd /usr/local/src/apr-1.6.3 [root@xavi apr-1.6.3]# make clean [root@xavi apr-1.6.3]# ./configure --prefix=/usr/local/apr [root@xavi apr-1.6.3]# yum install -y expat-devel
用echo$?查看下一句是否错误,然make&make install
[root@xavi apr-1.6.3]# cd /usr/local/src/apr-util-1.6.1 [root@xavi apr-util-1.6.1]# make clean [root@xavi apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
同理从新配置httpd,而后安装
[root@xavi apr-util-1.6.1]# cd /usr/local/src/httpd-2.4.29 [root@xavi httpd-2.4.29]# make clean
报错:
checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.
从新安装成功
[root@xavi httpd-2.4.29]# ls /usr/local/apache2.4 bin build cgi-bin conf error htdocs icons include lib logs man manual modules
[root@xavi httpd-2.4.29]# /usr/local/apache2.4/bin/httpd -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_event_module (static) authn_file_module (shared) authn_core_module (shared) authz_host_module (shared) authz_groupfile_module (shared) authz_user_module (shared) authz_core_module (shared) access_compat_module (shared) auth_basic_module (shared) reqtimeout_module (shared) filter_module (shared) mime_module (shared) log_config_module (shared) env_module (shared) headers_module (shared) setenvif_module (shared) version_module (shared) unixd_module (shared) status_module (shared) autoindex_module (shared) dir_module (shared) alias_module (shared) rewrite_module (shared) php7_module (shared)
分为两种类型①static ②shared
从新分析这个报错:
[root@xavi httpd-2.4.29]# /usr/local/apache2.4/bin/apachectl start (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down AH00015: Unable to open logs
其真正缘由是80端口被占用了
[root@xavi httpd-2.4.29]# lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 1076 root 7u IPv4 21187 0t0 TCP *:http (LISTEN) nginx 1080 nobody 7u IPv4 21187 0t0 TCP *:http (LISTEN) nginx 1082 nobody 7u IPv4 21187 0t0 TCP *:http (LISTEN)
[root@xavi httpd-2.4.29]# /etc/init.d/nginx stop Stopping nginx (via systemctl): [ 肯定 ] [root@xavi httpd-2.4.29]# !net netstat -lnp|grep 80 unix 2 [ ACC ] STREAM LISTENING 22280 1677/master public/flush
[root@xavi httpd-2.4.29]# /usr/local/apache2.4/bin/apachectl start
[root@xavi httpd-2.4.29]# chkconfig --list 注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 若是您想列出 systemd 服务,请执行 'systemctl list-unit-files'。 欲查看对特定 target 启用的服务请执行 'systemctl list-dependencies [target]'。 mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关 netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关 network 0:关 1:关 2:开 3:关 4:关 5:关 6:关 nginx 0:关 1:关 2:开 3:开 4:开 5:开 6:关 php-fpm 0:关 1:关 2:开 3:开 4:开 5:开 6:关