Apache 安装步骤:
说明:操作系统CentOS release 6.5 (Final)内核版本:2.6.32-431.el6.x86_64
一,准备的软件:apr-1.5.2.tar.gz、apr-util-1.5.4.tar.gz、httpd-2.4.18.tar.gz、mysql-5.5.32.tar.gz、pcre-8.38.tar.gz、php-5.6.20.tar.gz
[root@glpi /]#yum -y install gcc gcc-c++ make ncurses ncurses-devel libaio-devel cmake libxml2-devel
二,安装APACHE步骤:
2.1.1)新建文件安装目录/application所有的安装程序都安装该文件夹下;新建/data下面存放安装源文件
[root@glpi /]#mkdir /application [root@glpi /]#mkdir /data
2.1.2)安装apr-1.5.2
[root@glpi /]#tar xf apr-1.5.2.tar.gz [root@glpi data]# cd apr-1.5.2 [root@glpi apr-1.5.2]# ./configure --prefix=/application/apr-1.5.2/ [root@glpi apr-1.5.2]# make && make install
2.1.3)安装apr-util-1.5.4
[root@glpi data]# tar xf apr-util-1.5.4.tar.gz [root@glpi data]# cd apr-util-1.5.4 [root@glpi apr-util-1.5.4]# ./configure --prefix=/application/apr-util-1.5.4 -with-apr=/application/apr-1.5.2/ [root@glpi apr-util-1.5.4]# make && make install
2.1.4)安装PCRE
[root@glpi data]# tar xf pcre-8.38.tar.gz [root@glpi data]# cd pcre-8.38 [root@glpi pcre-8.38]# ./configure --prefix=/application/pcre-8.38 [root@glpi pcre-8.38]# make && make install
2.1.5)安装APACHE软件
[root@glpi data]# tar xf httpd-2.4.18.tar.gz [root@glpi data]# cd httpd-2.4.18 [root@glpi httpd-2.4.18]# ./configure --prefix=/application/apache2 -with-apr=/application/apr-1.5.2 -with-apr-util=/application/apr-util-1.5.4 -with-pcre=/application/pcre-8.38 -enable-so -enable-rewrite [root@glpi httpd-2.4.18]# make && make install [root@glpi httpd-2.4.18]# echo $?
2.1.6)将httpd加入到系统服务,并自动启动
[root@glpi httpd-2.4.18]# cp /application/apache2/bin/apachectl /etc/init.d/httpd
2.1.7)把配置文件中加入# chkconfig: 2345 50 90
[root@glpi httpd-2.4.18]# vi /etc/init.d/httpd #!/bin/sh # chkconfig: 2345 50 90 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License a
2.1.8)设置开启自启动
[root@glpi httpd-2.4.18]# chkconfig --add httpd [root@glpi httpd-2.4.18]# chkconfig --level 35 httpd on
2.1.9)启动Apache
[root@glpi httpd-2.4.18]# /etc/init.d/httpd start
2.1.10)检查启动的进程
[root@glpi httpd-2.4.18]# netstat -lntup |grep httpd
2.1.11)登录网页输入IP检查;如果成功出现It works!证明设置成功
2.1.12)如果Apache报错;提示ip和ServerName错误,只要修改vi /application/apache2/conf/httpd.conf中对应的IP和ServeName即可。
[root@glpi httpd-2.4.18]# vi /application/apache2/conf/httpd.conf
三,编译安装mysql-5.5.32
3.1.1)先添加mysql用户和组
[root@glpi /]# groupadd mysql [root@glpi /]# useradd mysql -s/sbin/nologin -M -g mysql
3.1.2解压mysql
[root@glpi data]# tar xf mysql-5.5.32.tar.gz [root@glpi data]# cd mysql-5.5.32
3.1.3)mysql的编译安装路径、数据存储路径、和相关参数
[root@glpi mysql-5.5.32]#cmake .-DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \ -DMYSQL_DATADIR=/data/mysql \ -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \ -DENABLED_LOCAL_INFILE=ON \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \ -DWITH_FAST_MUTEXES=1 \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DWITH_DEBUG=0
3.1.4)编译安装MySQL5.5.32
[root@glpi mysql-5.5.32]# make [root@glpi mysql-5.5.32]# make install
3.1.5)创建一个软链接
[root@glpi mysql-5.5.32]#ln -s /application/mysql5.5.32/ /application/mysql
3.1.6)给数据库文件夹授权
[root@glpi application]# chown -R mysql.mysql /application/mysql
3.1.7)查看授权
[root@glpi application]# ll /application/
3.1.8)拷贝启动文件/etc/init.d/mysqld
[root@glpi mysql-5.5.32]#cp support-files/mysql.server /etc/init.d/mysqld [root@glpi mysql-5.5.32]#ls /application/mysql/bin/mysql
3.1.9)给启动文件授权
[root@glpi mysql-5.5.32]#chmod 700 /etc/init.d/mysqld
3.1.10)设置环境变量
[root@glpi mysql-5.5.32]#echo ' export PATH=/application/mysql/bin:$PATH '>>/etc/profile [root@glpi mysql-5.5.32]#source /etc/profile [root@glpi mysql-5.5.32]#tail -n 1 /etc/profile [root@glpi mysql-5.5.32]#echo $PATH
3.1.11)配置配置文件,从support拷贝一份
[root@glpi mysql-5.5.32]#ll support-files/*.cnf [root@glpi mysql-5.5.32]#cp /etc/my.cnf /etc/my.cnf.bak [root@glpi mysql-5.5.32]#cp support-files/my-small.cnf /etc/my.cnf [root@glpi mysql-5.5.32]#vim /etc/my.cnf [mysqld] port = 3306 socket = /application/mysql-5.5.32/tmp/mysql.sock datadir =/data/mysql user =mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-bin=mysql-bin server-id = 1 auto_increment_offset=1 auto_increment_increment=2 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
3.1.12)初始化数据库
[root@glpi mysql-5.5.32]#/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/data/mysql --user=mysql
3.1.13)启动数据库
[root@glpi mysql-5.5.32]#/etc/init.d/mysqld start [root@glpi mysql-5.5.32]#netstat -lntup
3.1.14)设置开机自启动
[root@glpi mysql-5.5.32]#chkconfig --add mysqld [root@glpi mysql-5.5.32]#chkconfig --list mysqld
3.1.15)修改数据库密码
[root@glpi mysql-5.5.32]#mysqladmin -uroot password 'hwg123'
3.1.16)登录数据库删除一些初始数据库
mysql> delete from mysql.user where user=''; mysql> delete from mysql.user where host='::1'; mysql> delete from mysql.user where host='glpi; mysql> select user,host from mysql.user;
四,编译安装php
4.1.1)安装php
[root@glpi data]# tar xf php-5.6.20.tar.gz [root@glpi data]# cd php-5.6.20 [root@glpi php-5.6.20]# ./configure --prefix=/application/php5 --with-config-file-path=/application/php/etc --with-apxs2=/application/apache2/bin/apxs --with-mysql=/application/mysql [root@glpi php-5.6.20]# make [root@glpi php-5.6.20]# make install
4.1.2)将php和apache整合
[root@glpi php-5.6.20]# cp php.ini-development /application/php5/lib/php.ini [root@glpi php-5.6.20]# vim /application/apache2/conf/httpd.conf 148 LoadModule php5_module modules/libphp5.so #此行如果没有就需要手工加上 248 DirectoryIndex index.php index.html #此行加上index.php 375 AddType application/x-compress .Z 376 AddType application/x-gzip .gz .tgz 377 AddType application/x-httpd-php .php .phtml #添加此行php
4.1.3)测试PHP
[root@glpi php-5.6.20]# vim /application/apache2/htdocs/index.php #加入此行保存退出 [root@glpi php-5.6.20]# /etc/init.d/httpd restart
4.1.4)打开浏览器输入http://ip/php.index
4.1.5)测试php-mysql
[root@glpi php-5.6.20]# vim /application/apache2/htdocs/php_mysql.php
4.1.6)打开浏览器输入http://ip/php_mysql.php
connected! #显示connected证明配置正确
4.1.7)上传Discuz安装Discuz并且授权
[root@glpi data]#unzip Discuz_X3.1_SC_UTF8.zip -d /application/apache2/htdocs/ [root@glpi data]#cd /application/apache2/htdocs/ [root@glpi htdocs]# mv upload/* . [root@glpi htdocs]# chmod 777 -R uc_server data config uc_client
4.1.8)打开浏览器输入http://192.168.0.152/install/
4.1.9)然后继续下一步,
4.1.10)当前状态是可写就继续下一步
4.1.11)选择全新安装,下一步
4.1.12)填写你的数据库服务器,数据库名称discuz ,数据库用户名及密码,继续下一步
4.1.13)直到安装完成,会弹出如下对话框
4.1.14)至此Discuz安装完成;打开浏览器输入http://www.mydiscuz.com/forum.php
4.1.15)最后需要在本地hosts文件写入对应的IP和域名以便访问测试!!!
4.1.16)修正上面4.1.14)条打开浏览器输入http://www.mydiscuz.com即可访问网站:修改/application/apache2/conf/httpd.conf中的 248 条 DirectoryIndex forum.php index.php index.html #加入forum.php就可以直接访问网站了。