1.系统初始化配置
1.1 同步系统时间和网络时间
[root@localhost ~]# ntpdate time.nuri.net
2. 安装MySQL数据库
2.1 到MySQL官方网站下载MySQL
[root@localhost ~]# wget http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz
2.2 解压文件并且复制到安装目录/usr/local/mysql下
[root@localhost ~]# tar zxf mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz
[root@localhost ~]# mkdir /usr/local/mysql
[root@localhost ~]# mv mysql-5.6.32-linux-glibc2.5-x86_64/* /usr/local/mysql
[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# ll
total 68
drwxr-xr-x 2 root root 4096 Nov 22 07:07 bin
-rw-r--r-- 1 7161 wheel 17987 Jul 11 17:19 COPYING
drwxr-xr-x 3 root root 4096 Nov 22 07:06 data
drwxr-xr-x 2 root root 4096 Nov 22 07:07 docs
drwxr-xr-x 3 root root 4096 Nov 22 07:07 include
drwxr-xr-x 3 root root 4096 Nov 22 07:06 lib
drwxr-xr-x 4 root root 4096 Nov 22 07:07 man
drwxr-xr-x 10 root root 4096 Nov 22 07:07 mysql-test
-rw-r--r-- 1 7161 wheel 2496 Jul 11 17:19 README
drwxr-xr-x 2 root root 4096 Nov 22 07:06 scripts
drwxr-xr-x 28 root root 4096 Nov 22 07:06 share
drwxr-xr-x 4 root root 4096 Nov 22 07:07 sql-bench
drwxr-xr-x 2 root root 4096 Nov 22 07:06 support-files
2.3 修改MySQL数据库配置文件
[root@localhost mysql]# vim support-files/my-default.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql #安装目录
datadir = /usr/local/mysql/data #数据库存放目录
port = 3306
server_id = 130
socket = /tmp/mysql.sock #socket通信文件
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
2.4 初始化安装MySQL数据库
[root@localhost mysql]# useradd mysql -s /sbin/nologin -M
[root@localhost mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
2.5 修改数据库目录权限为mysql用户
[root@localhost mysql]# chown -R mysql:mysql data/
2.6 启动MySQL数据库
[root@localhost mysql]# /usr/local/mysql/bin/mysqld_safe &
[1] 1514
[root@localhost mysql]# 161122 07:17:50 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
161122 07:17:50 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2.7 检查是否完全启动MySQL
[root@localhost ~]# ps -ef | grep mysql
root 1514 1 0 07:17 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe
mysql 1730 1514 2 07:17 ? 00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/localhost.localdomain.err --pid-file=/usr/local/mysql/data/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306
root 1770 1754 0 07:18 pts/1 00:00:00 grep mysql
[root@localhost ~]# netstat -lntup | grep mysql
tcp 0 0 :::3306 :::* LISTEN 1730/mysqld
2.8 初始化登陆与设置管理员用户和密码
[root@localhost mysql]# cp bin/* /usr/bin/
[root@localhost mysql]# mysqladmin -uroot password
New password:
Confirm new password:
[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.32 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.05 sec)
3. 安装Apache服务
3.1 在Apache官网下载httpd文件
[root@localhost mysql]# wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.2.31.tar.gz
3.2 解压并且编译安装
[root@localhost ~]# tar jxvf httpd-2.2.31.tar.bz2
[root@localhost ~]# cd httpd-2.2.31
[root@localhost httpd-2.2.31]# ./configure --prefix=/usr/local/httpd --enable-rewrite--with-included-apr
[root@localhost httpd-2.2.31]# make && make install
[root@localhost httpd-2.2.31]# cd /usr/local/httpd/
3.3 启动httpd服务
[root@localhost httpd]# /usr/local/httpd/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[root@localhost httpd]# ps -ef | grep httpd
root 49902 1 0 07:30 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 49903 49902 0 07:30 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 49904 49902 0 07:30 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 49905 49902 0 07:30 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 49906 49902 0 07:30 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 49907 49902 0 07:30 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
root 49909 1754 0 07:31 pts/1 00:00:00 grep httpd
[root@localhost httpd]# netstat -lntup | grep 80
tcp 0 0 :::80 :::* LISTEN 49902/httpd
3.4 浏览器测试
4. 安装php服务
4.1 下载PHP安装程序
[root@localhost httpd]# wget http://cn2.php.net/distributions/php-5.6.28.tar.gz
4.2 解压并且编译安装
[root@localhost ~]# tar zxvf php-5.6.28.tar.gz
[root@localhost php-5.6.28]# yum install libxml* -y
[root@localhost php-5.6.28]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql/
[root@localhost php-5.6.28]# make && make install
4.3 修改httpd.conf文件以支持解析php文件,增加下面几行
[root@localhost httpd]# vim conf/httpd.conf
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php
4.4 复制php.ini配置文件
[root@localhost php-5.6.28]# cp php.ini-production /usr/local/php/etc/php.ini
4.5 测试
[root@localhost httpd]# vim htdocs/index.html
[root@localhost htdocs]# cp index.html index.php
[root@localhost htdocs]# rm -rf index.html
[root@localhost httpd]# /usr/local/httpd/bin/apachectl graceful
5. 安装Discuz
5.1 下载Discuz安装包
wget http://101.44.1.3/files/112000000589504D/123.138.60.34/files/A120000000C21706/download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
5.2 解压上传文件到htdoc目录下
[root@localhost upload]# cp -R * /usr/local/httpd/htdocs/discuz/
5.3 网页访问:http://192.168.42.130/discuz/install/
[root@localhost discuz]# ps -ef | grep httpd
root 49902 1 0 07:30 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 119266 49902 0 07:55 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 119267 49902 0 07:55 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 119268 49902 0 07:55 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 119269 49902 0 07:55 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 119270 49902 0 07:55 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 119271 49902 0 07:55 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 119312 49902 0 08:01 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
daemon 119313 49902 0 08:01 ? 00:00:00 /usr/local/httpd/bin/httpd -k start
[root@localhost htdocs]# chown -R daemon:daemon discuz/