第一步:下载Apache、MySQL、PHP
wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz
wget http://mirrors.sohu.com/php/php-5.3.27.tar.gz
wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz
第二步:先安装MySQL
解压缩mysql安装包
tar -zxvf mysql-5.1.73-linux-x86_64-glibc23.tar.gz
移动解压出来的数据包到/usr/local/mysql
mv mysql-5.1.73-linux-x86_64-glibc23 /usr/local/mysql
创建mysql账号
mkdir -p /data/mysql ;
useradd -s /sbin/nologin mysql
chown -R mysql:mysql /data/mysql
初始化数据库(mysql 5.6)
cd /usr/local/mysql/;
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
拷贝配置文件
cp support-files/my-large.cnf /etc/my.cnf(无my-large.cnf文件时候可以是使用my-default.cnf代替 )
拷贝启动脚本并且修改内容
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
修改内容# datadir=/data/mysql baseddir=/usr/local/mysql
修改启动脚本权限
chmod 755 /etc/init.d/mysqld
把启动脚本加入系统服务项,并设定开机启动,启动mysql
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
使用绝对路径启动#/usr/local/mysql/bin/mysql
创建一个数据库的变量文件(可以直接使用mysql命令)
查询mysql是否加入系统变量#which mysql
vim /etc/profile.d/path.sh
添加内容:
#!/bin/bash
export PATH=$PATH:/usr/local/mysql/bin
应用执行path.sh文件#source /etc/profile.d/path.sh
然后进入数据库
mysql
mysql> create database discuz; #创建数据库
mysql> grant all on discuz.* to 'yanghao'@'localhost' identified by 'www123com'; #创建数据库账号及密码
#grant all on discuz.*to'admin'@'localhost' identified by '123456';
使用#; 执行mysql命令
使用#exit 退出mysql
重启Apache即可安装discuz
/usr/local/apache2/bin/apachectl restart
卸载自带的mysql数据库
查看安装包名称 rpm -qf /usr/bin/mysql
卸载自带数据库yum remove mysql
第三步:安装Apache
解压缩安装包
tar -zxvf httpd-2.2.31.tar.gz
进入安装包并且编译环境
cd httpd-2.2.31
yum -y install gcc gcc-c++
yum install -y libxml2-devel
wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.2.tar.gz
tar zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure -–prefix=/usr/local=apr
wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.5.4.tar.gz
tar zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --with-apr=/usr/local=apr
cd httpd-2.2.31
编译make
安装make install
检测是否成功:
查看配置文件是否有语法错误:/usr/local/apache2/bin/apachectl -t
查看加载的动态模块:/usr/local/apache2/bin/apachectl -M
配置文件路径:/usr/local/apache2/conf /httpd.conf
修改虚拟主机配置文件
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
只留一个虚拟机配置,并且修改为:
<VirtualHost *:80>
DocumentRoot "/data/www" (创建的目录)
ServerName www.yang.com (域名)
ServerAlias www.li.com (多个域名)
# ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
检测下配置文件是否错误命令:/usr/local/apache2/bin/apachectl -t
第四步:安装PHP
解压缩安装包:
tar -zxvf php-5.3.27.tar.gz
查找安装源命令:
yum list |grep -i mcrypt epel扩展源安装
安装扩展源
rpm -ivh "http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
安装php编译环境
yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel libjpeg-devel
切换到安装包目录并且编译环境
cd php-5.3.27
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
编译make
安装make install
拷贝配置文件
cp php.ini-production /usr/local/php/etc/php.ini
配置Apache主配置文件启动虚拟主机
配置文件路径:/usr/local/apache2/conf /httpd.conf
vim /usr/local/apache2/conf/httpd.conf
找到
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
修改为
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
(去掉注释)
找到
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
修改为
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
第五步:Apache结合PHP
vim /usr/local/apache2/conf/httpd.conf(主配置文件)
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加:
AddType application/x-httpd-php .php
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
将该行改为:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
找到:
#ServerName www.example.com:80
修改为:
ServerName localhost:80
第六步:测试LAMP是否成功
检查Apache配置文件是否有错误
/usr/local/apache2/bin/apachectl -t
启动Apache
/usr/local/apache2/bin/apachectl start
查看Apache端口
netstat -lnp |grep httpd
测试首页
curl localhost
新建php配置文件
vim /usr/local/apache2/htdocs/info.php
输入:
<?php
phpinfo();
?>
重启Apache #/usr/local/apache2/bin/apachectl restart
然后浏览器访问查看是否正常~!
第七步: 防火墙设置
1,清除防火墙规则
iptables -F #只是临时清除规则重启系统或者重启iptables后还会加载规则所以需要保存下规则。
service iptables restart #重启iptables命令。
/etc/init.d/iptables save #保存规则命令。
service iptables save #保存规则命令
cat /etc/sysconfig/iptables #查看规则,防火墙规则保存在这个文件下。
2,设置防火墙规则
iptables -I INPUT -m iprange --src-range 192.168.137.0-192.168.137.254 -j ACCEPT#添加一个网段
第八步 discuz安装包
创建目录
mkdir /data/www
进入目录并且下载discuz安装包
cd /data/www/
wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
解压缩安装包:
unzip Discuz_X3.2_SC_GBK.zip
移动目录文件到/data/www下
mv upload/* ./ (空格)
删除不需要的文件
rm -rf Discuz_X3.2_SC_GBK.zip readme upload utility
http://域名/upload 安装discuz
修改discuz配置文件的权限(把daemon用户加入到config,uc_client/data uc_server/data 的属主):
chown -R daemon config data uc_client/data uc_server/data
第九步 disuz访问设置
1,修改window ,hosts 添加域名 + ip
C:\Windows\System32\drivers\etc #hosts路径
把hosts复制到桌面,在文件最下行添加 域名+ip,然后复制回原来路径覆盖。
2,填上mysql数据库名称,数据库账号和数据库密码
3,解决登录discuz管理后台提示的错误。
cd /data/www/install
rm -rf install/index.php(解决访问后台是提示delete install/index.php 问题)
编辑回复