CentOS下搭建Discuz!论坛
时间:2015-08-31 09:24 来源:linux.it.net.cn 作者:IT
[root@tpp ~]# mkdir /data/www
[root@tpp ~]# cd /data/www
[root@tpp www]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip //下载最新版本的Discuz!
[root@tpp www]# unzip Discuz_X3.2_SC_GBK.zip //解压
[root@tpp www]# ls
Discuz_X3.2_SC_GBK.zip readme upload utility
[root@tpp www]# mv upload/* ./
[root@tpp www]# ls
admin.php connect.php favicon.ico install readme template utility
api cp.php forum.php member.php robots.txt uc_client
api.php crossdomain.xml group.php misc.php search.php uc_server
archiver data home.php plugin.php source upload
config Discuz_X3.2_SC_GBK.zip index.php portal.php static userapp.php
[root@tpp www]# rm -rf readme/ utility/ upload/ Discuz_X3.2_SC_GBK.zip
[root@tpp www]# vim /usr/local/apache2/conf/httpd.conf
#Include conf/extra/httpd-vhosts.conf //找到,开放这个虚拟主机配置文件,如下:
Include conf/extra/httpd-vhosts.conf
[root@tpp www]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf //编辑虚拟主机配置文件,在文件最后面有两个模板案例,删除一个再修改另一个为:
<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com //管理员邮箱,我们可以去掉
DocumentRoot "/data/www" //改为之前创建的目录
ServerName www.tpp.com //设置域名
ServerAlias www.ppt.com //可以设置多个域名
# ErrorLog "logs/dummy-host.example.com-error_log" //错误日志
# CustomLog "logs/dummy-host.example.com-access_log" common //访问日志
</VirtualHost>
[root@tpp www]# vim /usr/local/apache2/conf/httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
改为:
<Directory />
Options FollowSymLinks
AllowOverride all
Order deny,allow
Allow from all
</Directory>
[root@tpp www]# /usr/local/apache2/bin/apachectl -t
Syntax OK
[root@tpp www]# /usr/local/apache2/bin/apachectl restart
192.168.0.104 www.tpp.com www.ppt.com www.ppt1.com
[root@tpp www]# ps aux |grep http
daemon 4566 0.0 1.0 30140 11028 ? S 04:42 0:00 /usr/local/apache2/bin/httpd -k start
daemon 4567 0.0 0.9 28724 9480 ? S 04:42 0:00
[root@tpp www]# chown -R daemon config data uc_client/data uc_server/data
[root@tpp www]# /usr/local/mysql/bin/mysql
mysql> create database discuz; //创建一个数据库,数据库名为discuz
mysql> grant all on discuz.* to 'tpp'@'localhost' identified by 'tpplinux';
// all 所有的权限,用户tpp,密码tpplinux
[root@tpp www]# mkdir abc
[root@tpp www]# cd abc
[root@tpp abc]# cp /etc/passwd 123.txt
[root@tpp abc]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
<Directory /data/www/abc>
AllowOverride AuthConfig
AuthName "自定义的"
AuthType Basic
AuthUserFile /data/.htpasswd # 这里的/data/.htpasswd可以随便写一个路径或名字,没有限制(这句中文只做注解,不要加进去,要不然会报错)
require valid-user
</Directory>
[root@tpp abc]# /usr/local/apache2/bin/htpasswd -c /data/.htpasswd tpp
[root@tpp abc]# /usr/local/apache2/bin/apachectl -t
Syntax OK
[root@tpp abc]# /usr/local/apache2/bin/apachectl restart
[root@tpp abc]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf //虚拟主机中增加如下内容
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ppt.com$
RewriteRule ^(.*)$ http://www.tpp.com/$1 [R=301,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ppt.com [OR]
RewriteCond %{HTTP_HOST} ^www.ppt1.com$
RewriteRule ^/(.*)$ http://www.tpp.com/$1 [R=301,L]
</IfModule>
[root@tpp ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
ErrorLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/tpp.com-error_%Y%m%d.log 86400"
SetEnvIf Request_URI ".*\.gif$" image-request
SetEnvIf Request_URI ".*\.jpg$" image-request
SetEnvIf Request_URI ".*\.png$" image-request
SetEnvIf Request_URI ".*\.bmp$" image-request
SetEnvIf Request_URI ".*\.swf$" image-request
SetEnvIf Request_URI ".*\.js$" image-request
SetEnvIf Request_URI ".*\.css$" image-request
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/tpp.com-access_%Y%m%d.log 86400" combined env=!image-request
现在我们的这些txt|doc|mp3|zip|rar|jpg|gif|png文件,不能被其他网站作为网络链接而引用了
(责任编辑:IT)
[root@tpp ~]# mkdir /data/www
[root@tpp ~]# cd /data/www
[root@tpp www]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip //下载最新版本的Discuz!
[root@tpp www]# unzip Discuz_X3.2_SC_GBK.zip //解压
[root@tpp www]# ls
Discuz_X3.2_SC_GBK.zip readme upload utility
[root@tpp www]# mv upload/* ./
[root@tpp www]# ls
admin.php connect.php favicon.ico install readme template utility
api cp.php forum.php member.php robots.txt uc_client
api.php crossdomain.xml group.php misc.php search.php uc_server
archiver data home.php plugin.php source upload
config Discuz_X3.2_SC_GBK.zip index.php portal.php static userapp.php
[root@tpp www]# rm -rf readme/ utility/ upload/ Discuz_X3.2_SC_GBK.zip
[root@tpp www]# vim /usr/local/apache2/conf/httpd.conf
#Include conf/extra/httpd-vhosts.conf //找到,开放这个虚拟主机配置文件,如下:
Include conf/extra/httpd-vhosts.conf
[root@tpp www]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf //编辑虚拟主机配置文件,在文件最后面有两个模板案例,删除一个再修改另一个为:
<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com //管理员邮箱,我们可以去掉
DocumentRoot "/data/www" //改为之前创建的目录
ServerName www.tpp.com //设置域名
ServerAlias www.ppt.com //可以设置多个域名
# ErrorLog "logs/dummy-host.example.com-error_log" //错误日志
# CustomLog "logs/dummy-host.example.com-access_log" common //访问日志
</VirtualHost>
[root@tpp www]# vim /usr/local/apache2/conf/httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
改为:
<Directory />
Options FollowSymLinks
AllowOverride all
Order deny,allow
Allow from all
</Directory>
[root@tpp www]# /usr/local/apache2/bin/apachectl -t
Syntax OK
[root@tpp www]# /usr/local/apache2/bin/apachectl restart
192.168.0.104 www.tpp.com www.ppt.com www.ppt1.com
[root@tpp www]# ps aux |grep http
daemon 4566 0.0 1.0 30140 11028 ? S 04:42 0:00 /usr/local/apache2/bin/httpd -k start
daemon 4567 0.0 0.9 28724 9480 ? S 04:42 0:00
[root@tpp www]# chown -R daemon config data uc_client/data uc_server/data
[root@tpp www]# /usr/local/mysql/bin/mysql
mysql> create database discuz; //创建一个数据库,数据库名为discuz
mysql> grant all on discuz.* to 'tpp'@'localhost' identified by 'tpplinux';
// all 所有的权限,用户tpp,密码tpplinux
[root@tpp www]# mkdir abc
[root@tpp www]# cd abc
[root@tpp abc]# cp /etc/passwd 123.txt
[root@tpp abc]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
<Directory /data/www/abc>
AllowOverride AuthConfig
AuthName "自定义的"
AuthType Basic
AuthUserFile /data/.htpasswd # 这里的/data/.htpasswd可以随便写一个路径或名字,没有限制(这句中文只做注解,不要加进去,要不然会报错)
require valid-user
</Directory>
[root@tpp abc]# /usr/local/apache2/bin/htpasswd -c /data/.htpasswd tpp
[root@tpp abc]# /usr/local/apache2/bin/apachectl -t
Syntax OK
[root@tpp abc]# /usr/local/apache2/bin/apachectl restart
[root@tpp abc]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf //虚拟主机中增加如下内容
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ppt.com$
RewriteRule ^(.*)$ http://www.tpp.com/$1 [R=301,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ppt.com [OR]
RewriteCond %{HTTP_HOST} ^www.ppt1.com$
RewriteRule ^/(.*)$ http://www.tpp.com/$1 [R=301,L]
</IfModule>
[root@tpp ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
ErrorLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/tpp.com-error_%Y%m%d.log 86400"
SetEnvIf Request_URI ".*\.gif$" image-request
SetEnvIf Request_URI ".*\.jpg$" image-request
SetEnvIf Request_URI ".*\.png$" image-request
SetEnvIf Request_URI ".*\.bmp$" image-request
SetEnvIf Request_URI ".*\.swf$" image-request
SetEnvIf Request_URI ".*\.js$" image-request
SetEnvIf Request_URI ".*\.css$" image-request
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/tpp.com-access_%Y%m%d.log 86400" combined env=!image-request
|