lamp+discuz伪静态+404页面+301页面重定向

准备

1.配置防火墙,开启80端口、3306端口

vim /etc/sysconfig/iptables

-A INPUT -m state –state NEW -m tcp –dport 80 j ACCEPT #允许80端口通过防火墙

-A INPUT -m state –state NEW -m tcp –dport 3306 -j ACCEPT #允许3306端口通过防火墙

重启防火墙使配置生效:service iptables restart

2.关闭SELINUX

vim /etc/selinux/config

#SELINUX=enforcing #注释掉

#SELINUXTYPE=targeted #注释掉

SELINUX=disabled #增加

:wq #保存退出

init 6 #重启系统

安装

yum install httpd -y #安装httpd

yum install mysql mysql-server -y #yum 安装mysql 直到完成

yum install php php-fpm -y #安装php直至完成

yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt #安装PHP组件,使PHP5支持MYSQL

service httpd start  #起服务

service mysqld start

service php-fpm start

chkconfig httpd on #设置开机自启

chkconfig php-fpm on

chkconfig mysqld on

mysql_secure_installation     #回车,根据提示输入Y ,输入2次密码,回车,最后出现Thabjs for using  Mysql!

mysql -u root -p      #以root用户登录 mysql 输入密码

create database zql;      #创建名为zql的数据库

use zql; #按回车键出现Database changed 时说明操作成功!

exit #退出mysql

service mysqld restart        #Mysql 密码设置完成,重新启动 MySQL:

配置

一、Apache配置

vi /etc/httpd/conf/httpd.conf #编辑文件

ServerTokens OS  #在44行 修改为:ServerTokens Prod (在出现错误页的时候不显示服务器操作系统的名称)

ServerSignature On  #在536行 修改为:ServerSignature Off (在错误页中不显示Apache的版本)

Options Indexes FollowSymLinks  #在331行 修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)

#AddHandler cgi-script .cgi #在796行 修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)

AllowOverride None  #在338行 修改为:AllowOverride All (允许.htaccess)

  Options Indexes MultiViews FollowSymLinks #在554行 修改为 Options MultiViews FollowSymLinks(不在浏览器上显示树状目录结构)

DirectoryIndex index.html index.html.var #在402行 修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var (设置默认首页文件,增加index.php)

KeepAlive Off #在76行 修改为:KeepAlive On (允许程序性联机)

MaxKeepAliveRequests 100 #在83行 修改为:MaxKeepAliveRequests 1000 (增加同时连接数)

:wq! #保存退出

/etc/init.d/httpd restart#重启

二.PHP 配置

vim /etc/php.ini #编辑

date.timezone = PRC #在878行左右 把前面的分号去掉,改为date.timezone = PRC

expose_php = off #在375行左右禁止显示PHP版本信息

short_open_tag = ON #在211行支持PHP短标签

:wq #保存退出

Discuz

一.下载Discuz并解压

wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip

unzip Discuz_X3.2_SC_UTF8.zip

二.把文件放到网站跟目录

cp -r ./upload/* /var/www/html -R

三.根据自动安装提示安装


四.设置伪静态


五.编辑服务端伪静态

配置Apache支持Rewrite功能

/etc/httpd/conf/httpd.conf *304行改成All

apache 伪静态的配置文件自己在

/var/www/html

创建.htaccess

六.编辑服务端404页面

apache 在.htaccess

添加:RewriteEngine On

ErrorDocument 404 /Error.html

并在/var/www/html下创建Error.html

七.404页面简单代码

<!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>SEO十万个为什么-您的访问出错了</title>

<style type="text/css">

<!--

.STYLE1 {font-weight: bold}

.STYLE2 {font-weight: bold}

-->

</style>

</head>

<body>

<p class="STYLE1">很抱歉,您要访问的页面不存在。</p>

<h2 class="STYLE2">1、请检查您输入的地址是否正确。 </h2>

<p class="STYLE2">2、通过<a  href="seo/">http://www.seowhy.com">SEO十万个为什么首页</a>进行浏览。</p>

<p class="STYLE2">3、感谢您使用本站,如有疑问请<a  href="http://www.seowhy.com/contact.html">联系我们</a>。</p>

<style type="text/css">

<!--

.STYLE1{

color:#0000FF;

font-weight:bold;

font-size:25px}

.STYLE2{font-size:15px; line-height:25px}

body{

margin-top:88px;

margin-left:455px}

-->

</style>

</body>

</html>

八.301页面重定向

修改.htaccess文件保存就可以了:

RewriteCond %{HTTP_HOST} ^xxxx.com [NC]

RewriteRule ^(.*)$ http://www.xxxx.com/$1 [L,R=301]

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容