九週五次課html
11.6MariaDB安裝mysql
11.7/11.8/11.9Apache安裝linux
11.6MariaDB安裝web
1.首先切換到/usr/local/src目錄下正則表達式
[root@tianqi-01 mysql]# cd /usr/local/src/
[root@tianqi-01 src]# sql
2.而後在官網下載10.2.6版本(官網下載很慢,由於地址在美國),本身百度雲有提早下載好的,只須要下載到windows,而後 rz 命令從windows上傳到linux中shell
文件比較大而上傳出錯的話,採用參數 -e;
若是用不帶參數的rz命令上傳大文件時,經常上傳一半就斷掉了,極可能是rz覺得上傳的流中包含某些特殊控制字符,形成rz提早退出。數據庫
[root@tianqi-01 src]# rz -e
z waiting to receive.** B0100000063f694
[root@tianqi-01 src]# ls
? d? httpd-2.2.34 httpd-2.2.34.tar.gz mariadb-10.2.6-linux-x86_64.tar.gz mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
[root@tianqi-01 src]# express
3.再去使用 tar命令 進行解壓apache
[root@tianqi-01 src]# tar zxvf mariadb-10.2.6-linux-x86_64.tar.gz
4.解壓完,去查看下文件
[root@tianqi-01 src]# ls
httpd-2.2.34 mariadb-10.2.6-linux-x86_64 mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
httpd-2.2.34.tar.gz mariadb-10.2.6-linux-x86_64.tar.gz
[root@tianqi-01 src]#
5.並將解壓的包移動到/usr/local下,並更名叫mariadb——>這裏的更名,是爲了以前安裝mysql的名字有所區分
[root@tianqi-01 src]# mv mariadb-10.2.6-linux-x86_64 /usr/local/mariadb
[root@tianqi-01 src]#
6.而後進入到/usr/local/mariadb 目錄下去
[root@tianqi-01 src]# cd !$
cd /usr/local/mariadb
[root@tianqi-01 mariadb]#
7.建立mysql用戶,建立data——>這裏由於以前安裝mysql的時候,已經建立過了因此不須要建立useradd mysql
[root@tianqi-01 mariadb]# useradd mysql
[root@tianqi-01 mariadb]# mkdir /data/
[root@tianqi-01 mariadb]#
8.初始化,./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
[root@tianqi-01 mariadb]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb --datadir=/data/mariadb
Installing MariaDB/MySQL system tables in '/data/mariadb' ...
OK
9.查看是否初始化成功,看 echo $? 執行結果是否爲0,如果 0 ,則表示初始化成功
[root@tianqi-01 mariadb]# echo $?
0
[root@tianqi-01 mariadb]#
或者查看/data/mariadb/目錄下,是否生成了一些目錄——>和/data/mysql/ 相似
[root@tianqi-01 mariadb]# ls /data/mariadb/
aria_log.00000001 aria_log_control ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema test
[root@tianqi-01 mariadb]#
10.拷貝配置文件,定義啓動腳本
[root@tianqi-01 mariadb]# cd /usr/local/mariadb/
[root@tianqi-01 mariadb]# ls support-files/
binary-configure my-huge.cnf my-large.cnf my-small.cnf mysql-log-rotate policy wsrep_notify
magic my-innodb-heavy-4G.cnf my-medium.cnf mysqld_multi.server mysql.server wsrep.cnf
[root@tianqi-01 mariadb]#
11.打開support-files/my-small.cnf 文件
[root@tianqi-01 mariadb]# vim support-files/my-small.cnf
其中下面的配置文件
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 240K
12.由於咱們作實驗,內存原本就不大,可使用最小的一個my-small.cnf ,拷貝過去
13.拷貝文件到/usr/local/mariadb/my.cnf
[root@tianqi-01 mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
[root@tianqi-01 mariadb]#
14.編輯配置文件 /usr/local/mariadb/my.cnf——>這裏面配置不用修改
[root@tianqi-01 mariadb]# vim !$
vim /usr/local/mariadb/my.cnf
配置參數在[mysqld]這一塊
server-id = 1 //這是作主從複製的
15.拷貝啓動腳本到 /etc/init.d/mariadb
[root@tianqi-01 mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
[root@tianqi-01 mariadb]#
16.編輯啓動腳本
[root@ip-172-31-21-107 mariadb]# vim /etc/init.d/mariadb
定義 basedir=/usr/local/mariadb
定義 datadir=/data/mariadb
自定義參數 conf=$basedir/my.cnf
在定義conf後,還須要在 啓動命令下面指定下——>在通常模式下,搜索 /start 啓動命令
在 $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" & 中,增長
--defaults-file="$conf",最後爲 $bindir/mysqld_safe --defaults-file="$conf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &
並保存退出
17.在啓動前,先查看是否有mysql服務在啓動
[root@tianqi-01 mariadb]# ps aux |grep mysql
root 1231 0.0 0.0 112660 984 pts/0 S+ 17:57 0:00 grep --color=auto mysql
[root@tianqi-01 mariadb]#
18.啓動mariadb服務,並去查看是否啓動
[root@tianqi-01 mariadb]# /etc/init.d/mariadb start
Starting MySQL.180227 18:01:59 mysqld_safe Logging to '/data/mysql/tianqi-01.err'.
180227 18:01:59 mysqld_safe Starting mysqld daemon with databases from /data/mysql
..... [ OK ]
[root@tianqi-01 mariadb]# ps aux |grep mariadb
root 1253 0.1 0.1 113264 1648 pts/0 S 18:01 0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mysql --pid-file=/data/mysql/tianqi-01.pid
mysql 1369 13.7 5.4 1122944 54820 pts/0 Sl 18:01 0:03 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/data/mysql --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mysql/tianqi-01.err --pid-file=/data/mysql/tianqi-01.pid --socket=/tmp/mysql.sock --port=3306
root 1425 0.0 0.0 112660 980 pts/0 S+ 18:02 0:00 grep --color=auto mariadb
[root@tianqi-01 mariadb]#
[root@tianqi-01 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:22 0.0.0.0:* LISTEN 778/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1009/master
tcp6 0 0 :::22 :::* LISTEN 778/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1009/master
tcp6 0 0 :::3306 :::* LISTEN 1369/mysqld
[root@tianqi-01 mariadb]#
19.如果在服務器上只安裝了mariadb,沒有mysql,那徹底能夠把my.cnf放在/etc目錄下,那啓動腳本就不須要conf變量了
[root@tianqi-01 mariadb]# ps aux |grep mysql
root 1253 0.0 0.1 113264 1648 pts/0 S 18:01 0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mysql --pid-file=/data/mysql/tianqi-01.pid
mysql 1369 1.2 6.2 1122944 62448 pts/0 Sl 18:01 0:03 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/data/mysql --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mysql/tianqi-01.err --pid-file=/data/mysql/tianqi-01.pid --socket=/tmp/mysql.sock --port=3306
root 1429 0.0 0.0 112660 980 pts/0 S+ 18:07 0:00 grep --color=auto mysql
[root@tianqi-01 mariadb]#
11.7/11.8/11.9Apache安裝
1.首先切換到/usr/local/src目錄下
[root@tianqi-01 mariadb]# cd /usr/local/src/
[root@tianqi-01 src]#
2.下載Apache 2.4源碼包、apr、apr-util這三個包
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2
3.在下載完成後,查看下下載的包
[root@tianqi-01 src]# ls
apr-util-1.6.1.tar.bz2 httpd-2.2.34 httpd-2.4.29.tar.gz mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz apr-1.6.3.tar.gz httpd-2.2.34.tar.gz mariadb-10.2.6-linux-x86_64.tar.gz
[root@tianqi-01 src]#
4.解壓下載的包,並查看
[root@tianqi-01 src]# tar zxvf httpd-2.4.29.tar.gz
[root@tianqi-01 src]# tar zxvf apr-1.6.3.tar.gz
[root@tianqi-01 src]# tar xjvf apr-util-1.6.1.tar.bz2
[root@tianqi-01 src]# ls
apr-1.6.3.tar.gz apr-util-1.6.1.tar.bz2 httpd-2.2.34 httpd-2.4.29 mariadb-10.2.6-linux-x86_64.tar.gz apr-1.6.3 apr-util-1.6.1 httpd-2.2.34.tar.gz httpd-2.4.29.tar.gz mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
[root@tianqi-01 src]#
在解壓完成後,首先安裝apr
5.切換到/usr/local/src/apr-1.6.3,並安裝apr
[root@tianqi-01 src]# cd apr-1.6.3
[root@tianqi-01 apr-1.6.3]# ./configure --prefix=/usr/local/apr
在安裝的時候,有時會出現如下狀況
configure: error: in `/usr/local/src/apr-1.6.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@tianqi-01 apr-1.6.3]# yum install -y gcc
6.在安裝完成後,能夠用 echo $? 檢查是否安裝成功
[root@tianqi-01 apr-1.6.3]# echo $?
0
[root@tianqi-01 apr-1.6.3]#
7.執行make && make install 命令
[root@tianqi-01 apr-1.6.3]# make && make install
8.查看下apr,會看到有四個目錄
[root@tianqi-01 apr-1.6.3]# ls /usr/local/apr/
bin build-1 include lib
[root@tianqi-01 apr-1.6.3]#
9.安裝apr-util-1.6.1,首先切換到/usr/local/src/apr-util-1.6.1目錄下
[root@tianqi-01 apr-1.6.3]# cd /usr/local/src/apr-util-1.6.1
[root@tianqi-01 apr-util-1.6.1]#
10.安裝apr-util
[root@tianqi-01 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
11.而後使用echo $?檢查是否安裝成功
[root@tianqi-01 apr-util-1.6.1]# echo $?
0
[root@tianqi-01 apr-util-1.6.1]#
12.而後make && make install
[root@tianqi-01 apr-util-1.6.1]# make && make install
問題
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
#include <expat.h>
^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/usr/local/src/apr-util-1.6.1'
make: *** [all-recursive] Error 1
解決方法
[root@tianqi-01 apr-util-1.6.1]# yum -y install expat-devel
13.--enable-so \ 表示支持動態擴展模塊,Apache和PHP它們都會支持以一個模塊的形式存在
14.查看/usr/local/apr-util/目錄下,會看到生成三個子目錄
[root@tianqi-01 apr-util-1.6.1]# ls /usr/local/apr-util
bin include lib
[root@tianqi-01 apr-util-1.6.1]#
15.安裝httpd-2.4.29,首先切換到httpd-2.4.29/
[root@tianqi-01 apr-util-1.6.1]# cd /usr/local/src/httpd-2.4.29/
[root@tianqi-01 httpd-2.4.29]#
16.安裝httpd-2.4.29
[root@tianqi-01 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@tianqi-01 httpd-2.4.29]# yum list |grep pcre
pcre.x86_64 8.32-17.el7 @anaconda
pcre.i686 8.32-17.el7 base
pcre-devel.i686 8.32-17.el7 base
pcre-devel.x86_64 8.32-17.el7 base
pcre-static.i686 8.32-17.el7 base
pcre-static.x86_64 8.32-17.el7 base
pcre-tools.x86_64 8.32-17.el7 base
pcre2.i686 10.23-2.el7 base
pcre2.x86_64 10.23-2.el7 base
pcre2-devel.i686 10.23-2.el7 base
pcre2-devel.x86_64 10.23-2.el7 base
pcre2-static.i686 10.23-2.el7 base
pcre2-static.x86_64 10.23-2.el7 base
pcre2-tools.x86_64 10.23-2.el7 base
pcre2-utf16.i686 10.23-2.el7 base
pcre2-utf16.x86_64 10.23-2.el7 base
pcre2-utf32.i686 10.23-2.el7 base
pcre2-utf32.x86_64 10.23-2.el7 base
[root@tianqi-01 httpd-2.4.29]#
[root@tianqi-01 httpd-2.4.29]# yum install -y pcre-devel
17.再次安裝,使用echo $?檢查是否安裝成功,這裏會看到成功安裝
[root@tianqi-01 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
[root@tianqi-01 httpd-2.4.29]# echo $?
0
[root@tianqi-01 httpd-2.4.29]#
18.執行make && make install
[root@tianqi-01 httpd-2.4.29]# make && make install
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory `/usr/local/src/httpd-2.4.29/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.29/support'
make: *** [all-recursive] Error 1
解決方法:
重作以後,仍然出現問題。
解決辦法:在後面添加 --with-included-apr
[root@tianqi-01 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 --with-included-apr
但是加上--with-included-apr編譯以後,出現瞭如下問題:
configure: Configuring Apache Portable Runtime library...
configure:
configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.
解決辦法:
[root@tianqi-01 httpd-2.4.29]# cd /usr/local/src
[root@tianqi-01 src]# cp -r apr-1.6.3 /usr/local/src/httpd-2.4.29/srclib/apr
[root@tianqi-01 src]# cp -r apr-util-1.6.1 /usr/local/src/httpd-2.4.29/srclib/apr-util
[root@tianqi-01 src]#
而後再次編譯,則不會出現問題,並且make時也不會出現問題。
[root@tianqi-01 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 --with-included-apr
[root@tianqi-01 httpd-2.4.29]# echo $?
0
[root@tianqi-01 httpd-2.4.29]# make && make install
[root@tianqi-01 httpd-2.4.29]# echo $?
0
19.接下來便會完成安裝Apache
1.在安裝完成後,進入到/usr/local/apache2.4/目錄下,並 ls 查看有哪些目錄
[root@tianqi-01 httpd-2.4.29]# cd /usr/local/apache2.4
[root@tianqi-01 apache2.4]# ls
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
[root@tianqi-01 apache2.4]#
2.在之後會接觸到的目錄就是 bin目錄,conf目錄,htdocs目錄
[root@tianqi-01 apache2.4]# ls bin/httpd
bin/httpd
[root@tianqi-01 apache2.4]# ls -l bin/httpd
-rwxr-xr-x 1 root root 2334360 Feb 27 19:38 bin/httpd
[root@tianqi-01 apache2.4]# du -sh !$
du -sh bin/httpd
2.3M bin/httpd
[root@tianqi-01 apache2.4]#
[root@tianqi-01 apache2.4]# ls conf/
extra httpd.conf magic mime.types original
[root@tianqi-01 apache2.4]#
[root@tianqi-01 apache2.4]# ls htdocs/
index.html
[root@tianqi-01 apache2.4]#
[root@tianqi-01 apache2.4]# ls man
man1 man8
[root@tianqi-01 apache2.4]#
[root@tianqi-01 apache2.4]# ls modules
httpd.exp mod_authz_groupfile.so mod_ext_filter.so mod_proxy_balancer.so mod_session_cookie.so
mod_access_compat.so mod_authz_host.so mod_file_cache.so mod_proxy_connect.so mod_session_dbd.so
mod_actions.so mod_authz_owner.so mod_filter.so mod_proxy_express.so mod_session.so
mod_alias.so mod_authz_user.so mod_headers.so mod_proxy_fcgi.so mod_setenvif.so
mod_allowmethods.so mod_autoindex.so mod_include.so mod_proxy_fdpass.so mod_slotmem_shm.so
mod_auth_basic.so mod_buffer.so mod_info.so mod_proxy_ftp.so mod_socache_dbm.so
mod_auth_digest.so mod_cache_disk.so mod_lbmethod_bybusyness.so mod_proxy_hcheck.so mod_socache_memcache.so
mod_auth_form.so mod_cache.so mod_lbmethod_byrequests.so mod_proxy_http.so mod_socache_shmcb.so
mod_authn_anon.so mod_cache_socache.so mod_lbmethod_bytraffic.so mod_proxy_scgi.so mod_speling.so
mod_authn_core.so mod_cgid.so mod_lbmethod_heartbeat.so mod_proxy.so mod_status.so
mod_authn_dbd.so mod_dav_fs.so mod_log_config.so mod_proxy_wstunnel.so mod_substitute.so
mod_authn_dbm.so mod_dav.so mod_log_debug.so mod_ratelimit.so mod_unique_id.so
mod_authn_file.so mod_dbd.so mod_logio.so mod_remoteip.so mod_unixd.so
mod_authn_socache.so mod_dir.so mod_macro.so mod_reqtimeout.so mod_userdir.so
mod_authz_core.so mod_dumpio.so mod_mime.so mod_request.so mod_version.so
mod_authz_dbd.so mod_env.so mod_negotiation.so mod_rewrite.so mod_vhost_alias.so
mod_authz_dbm.so mod_expires.so mod_proxy_ajp.so mod_sed.so mod_watchdog.so
[root@tianqi-01 apache2.4]#
[root@tianqi-01 apache2.4]# du -sh modules/
6.3M modules/
[root@tianqi-01 apache2.4]#
3.查看Apache加載了哪些模塊
[root@tianqi-01 apache2.4]# /usr/local/apache2.4/bin/httpd -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::1eb9:8f9e:264a:7159. Set the 'ServerName' directive globally to suppress this message
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)
[root@tianqi-01 apache2.4]#
[root@tianqi-01 apache2.4]# /usr/local/apache2.4/bin/apachectl -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::1eb9:8f9e:264a:7159. Set the 'ServerName' directive globally to suppress this message
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)
[root@tianqi-01 apache2.4]#
1.在安裝完成Apache2.4後,Apache啓動不須要定義啓動腳本,也不須要放到/etc/init.d下去,直接使用命令行啓動就行
[root@tianqi-01 apache2.4]# /usr/local/apache2.4/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::1eb9:8f9e:264a:7159. Set the 'ServerName' directive globally to suppress this message
[root@tianqi-01 apache2.4]#
2.查看Apache是否啓動,看httpd進程是否存在
[root@tianqi-01 apache2.4]# ps aux |grep httpd
root 53549 0.0 0.2 95528 2532 ? Ss 19:52 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 53550 0.0 0.4 382356 4432 ? Sl 19:52 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 53551 0.0 0.4 382356 4432 ? Sl 19:52 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 53552 0.0 0.4 382356 4432 ? Sl 19:52 0:00 /usr/local/apache2.4/bin/httpd -k start
root 53635 0.0 0.0 112660 984 pts/0 R+ 19:53 0:00 grep --color=auto httpd
3.查看端口號——>httpd默認監聽端口爲80,mysqld默認監聽端口爲3306,25端口是發郵件的,22端口是遠程登陸的
[root@tianqi-01 apache2.4]# 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:22 0.0.0.0:* LISTEN 778/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1009/master
tcp6 0 0 :::80 :::* LISTEN 53549/httpd
tcp6 0 0 :::22 :::* LISTEN 778/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1009/master
tcp6 0 0 :::3306 :::* LISTEN 2164/mysqld
[root@tianqi-01 apache2.4]#
友情連接:阿銘Linux