小编给大家分享一下LAMP环境及Discuz论坛系统如何安装,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
第一步:下载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账号
useradd -s /sbin/nologin mysql
初始化数据库
cd /usr/local/mysql/;
mkdir -p /data/mysql ; chown -R mysql:mysql /data/mysql
./scripts/mysql_install_db –user=mysql –datadir=/data/mysql
拷贝配置文件
cp support-files/my-large.cnf /etc/my.cnf
拷贝启动脚本并且修改内容
cp support-files/mysql.server /etc/init.d/mysqld
修改内容datadir=/usr/mysql baseddir=/usr/local/mysql
修改启动脚本权限
chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld
把启动脚本加入系统服务项,并设定开机启动,启动mysql
chkconfig –add mysqld
chkconfig mysqld on
service mysqld start
第三步:安装Apache
解压缩安装包
tar -zxvf httpd-2.2.31.tar.gz
安装所需插件
yum install -y zlib-devel pcre pcre-devel apr apr-devel
进入安装包并且编译环境
cd httpd-2.2.31
./configure –prefix=/usr/local/apache2 –with-included-apr –enable-so –enable-deflate=shared –enable-expires=shared –enable-rewrite=shared –with-pcre
编译make
安装make install
第四步:安装PHP
解压缩安装包:
tar -zxvf php-5.3.27.tar.gz
安装扩展源
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结合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();
?>
编辑防火墙文件开放80端口(或者关闭防火墙)
vim /etc/sysconfig/iptables
service iptables restart
重启Apache
/usr/local/apache2/bin/apachectl restart
然后浏览器访问查看是否正常~!
第七步:安装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
配置Apache配置文件启动虚拟主机
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>
修改虚拟主机配置文件
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>
修改discuz配置文件的权限:
chown -R daemon config data uc_client/data uc_server/data
卸载自带的mysql数据库
查询安装目录which mysql
查看安装包名称rpm -qf /usr/bin/mysql
卸载自带数据库yum remove 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';创建数据库账号及密码
重启Apache即可安装discuz
/usr/local/apache2/bin/apachectl restart
看完了这篇文章,相信你对“LAMP环境及Discuz论坛系统如何安装”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/202397.html