#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
二:编译安装mariadb-5.5.46
mariadb-5.5.46-linux-x86_64.tar.gz 指定平台的是二进制包
mariadb-5.5.46.tar.gz 没有指定平台的是源码包
(1)准备数据存放的文件系统
新建一个逻辑卷,并将其挂载至特定目录即可。而后将逻辑卷挂载到目录/mydata/data
(2)新建用户以安全方式运行进程
~]# groupadd -r mysql
~]# useradd -g -r -s /sbin/nologin -M -d /mydata/data mysql <--创建一个系统用户mysql,属于mysql组,默认shell为。。不创建家目录,并指定家目录为/mydata/data~]# chown -R mysql:mysql /mydata/data
(3)安装并初始化mysql
~]# tar xf mariadb-5.5.46.tar.gz -C /usr/local~]# cd /usr/local
~]# ln -sv mariadb-5.5.46 mysql
~]# cd mysql~]# chown -R mysql:mysql .
~]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
~]# chown -R root . 将属主改回root
(4)为mysql提供配置文件
~]# cd /usr/local/mysql
~]# cp support-files/my-large.cnf /etc/my.cnf
~]# vim /etc/my.cnf
~]# thread_concurrency = 2 此值为你cpu个数乘以2
~]# datadir = /mydata/data
~]# innodb_file_per_table = ON 使用独立表空间
~]# skip_name_ resolve = ON 禁止IP反向解析为主机名
(5)为mysql提供sysv服务脚本
~]# cd /usr/local/mysql
~]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
~]# chmod +x /etc/rc.d/init.d/mysqld
~]# chkconfig --add mysqld~]# chkconfig --level 2345 mysqld on
(6)输出mysql的man手册至man命令的查询路径
~]# vim /etc/man.config 添加如下行即可 MANPATH /usr/local/mysql/man
~]# vim /etc/profile.d/mysql.sh
~]# PATH=/usr/local/mysql/bin:$PATH <--可以直接使用mysql命令
(10) 为phpadmin提供用户密码
~]> select user,passwd,host from mysql.user;
~]> create user 'root'@'172.18.%.%';
~]> grant all on *.* to 'root'@'172.18.%.%' identified by '123456'
~]> grant all on wordpress.* to wordpress@'172.18.%.%' identified by '123456'
~]> flush privileges;~]# mysql_secure_installation 为mysql自己添加密码