5、初始化配置Apache
[root@localhost httpd-2.4.16]# /bin/cp /usr/local/apache2/bin/apachectl /etc/init.d/apache2
[root@localhost httpd-2.4.16]# groupadd apache #添加apache用户组及用户
[root@localhost httpd-2.4.16]# useradd -g apache -s /usr/sbin/nologin apache
[root@localhost httpd-2.4.16]# chown -R apache:apache /usr/local/apache2
[root@localhost httpd-2.4.16]# chmod +x /etc/init.d/apache2
[root@localhost httpd-2.4.16]# chkconfig --add apache2 #增加执行权限
[root@localhost httpd-2.4.16]# chkconfig --level 2345 apache2 on #设置开机启动
[root@localhost httpd-2.4.16]# chkconfig --list apache2 #查看是否设置成功
httpd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
6、修改init命令文件
主要是修改文件中pidfile参数的值(进程文件指向)
[root@localhost ~]# vim /etc/init.d/httpd
#!/bin/sh
# chkconfig: 2345 64 36
#这个是启动级别的服务,2345是指那些级别启动,64是开启顺序,应该在network服务的后面,36是关闭顺序,应该在network的前面,这里并不是注释
#默认network的是:2345 10 90
# description: Apache2.4.16 start script #描述字段,有了这两个字段,就可以用chkconfig命令控制
pidfile=${PIDFILE-/var/run/${prog}.pid}
修改为
pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}
[root@localhost httpd-2.4.16]# hostname mageedu.com
[root@localhost httpd-2.4.16]# echo "172.16.13.162 mageedu.com" >> /etc/hosts //启动不会报错
[root@localhost httpd-2.4.16]# /etc/init.d/apache2 start
三、编译安装 MySQL
所需源码包:
cmake-2.8.8.tar.gz
mysql-5.6.26.tar.gz
安装cmake
MySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具。
因此,我们首先要在系统中源码编译安装cmake工具。
[root@localhost ~]# cd /usr/local/src/cmake-2.8.8
[root@localhost cmake-2.8.8]# ./configure
[root@localhost cmake-2.8.8]# make && make install
编译安装配置MySQL
1、切换至 MySQL源码 解压目录
[root@localhost ~]# cd /usr/local/src/
2、创建所需data目录
[root@localhost src]# mkdir -pv /data/mysql
3、创建mysql用户和mysql组
[root@localhost src]# groupadd -r mysql
[root@localhost src]# useradd -g mysql -r -s /sbin/nologin mysql
4、cmake编译安装
[root@localhost src]# tar xf mysql-5.6.26.tar.gz
[root@localhost src]# cd mysql-5.6.26
[root@localhost mysql-5.6.26]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL-USER=mysql
[root@localhost src]# make && make install
5、初始化MySQL配置
[root@localhost src]# ln -s /usr/local/mysql/bin/* /bin/
[root@localhost src]# chmod +x /usr/local/mysql/scripts/mysql_install_db
[root@localhost src]# /usr/local/mysql/scripts/mysql_install_db \
--defaults-file=/etc/my.cnf \
--basedir=/usr/local/mysql/ \
--datadir=/data/mysql \
--user=mysql
配置开机自动启动
[root@localhost src]# /bin/cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost src]# chmod +x /etc/init.d/mysqld
[root@localhost src]# chkconfig --add mysqld
[root@localhost src]# chkconfig --level 2345 mysqld on
[root@localhost src]# chkconfig --list mysqld #查看是否已应用上
修改配置文件
[root@localhost src]# /bin/cp support-files/my-default.cnf /etc/my.cnf
[root@localhost src]# vim /etc/my.cnf
在[mysqld]节点中添加:
datadir = /data/mysql
log-error = /data/mysql/error.log
pid-file = /data/mysql/mysql.pid
user = mysql
tmpdir = /tmp
启动MySQL
[root@localhost src]# service mysqld start # 或 /etc/init.d/mysqld start
[root@localhost src]# /usr/local/mysql/bin/mysqladmin -u root -p password "123456"
四、编译安装 PHP
安装PHP依赖库
yum install -y libxml2 libxml2-devel bzip2-devel
1、安装 libmcrypt