Rootop 服务器运维与web架构

2011-11-16
发表者 Venus
暂无评论

Could not load file or assembly ‘Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. 系统找不到指定的文件

Server Error in ‘/’ Application.
——————————————————————————–

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly ‘Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. 系统找不到指定的文件。

Source Error:
Line 25:             以标识传入的用户。
Line 26:         –>
Line 27:     <add assembly=”Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C”/>
Line 28:     <add assembly=”Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C”/>
Line 29:     <add assembly=”office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C”/>
 

Source File: D:\wz\soft\web\web.config    Line: 27

Assembly Load Trace: The following information can be helpful to determine why the assembly ‘Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
——————————————————————————–
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

解决方法:

安装office2007 (推荐专业版,安装的时候尽量选择“立即安装”不要选择“自定义”)

网站需要加载office2007的excel组件,服务器上没有,所以报错!

2011-11-16
发表者 Venus
暂无评论

配置mysql数据库双向同步

       mysql数据库的双向同步其实就是将主从的配置关系,在单向基础上颠倒过来配置一遍。
比如数据库s1和s2,s1的角色变成了主+从,s2的角色变成了从+主
配置方法如下:
S1配置:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

#A TO B
log-bin=mysql-bin
server-id=1
binlog-do-db=NQ

#B TO A
server-id=1
master-host=192.168.1.3
master-user=root
master-password=root
master-port=3306
master-connect-retry=60
replicate-do-db=NQ

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

S2配置:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

#A TO B
server-id=2
master-host=192.168.1.2
master-user=root
master-password=root
master-port=3306
master-connect-retry=60
replicate-do-db=NQ

#B TO A

log-bin=mysql-bin
binlog-do-db=NQ

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
大家可以参考/usr/share/mysql/my-huge.cnf的配置文件,并且其中有相关的注释,可以明白各参数作用。
在此就不讲双向同步的配置代码含义了。
在s1和s2中通过phpmyadmin进行测试,双向都能同步成功即可。

2011-11-14
发表者 Venus
暂无评论

redhat下php环境搭建(linux apache mysql php)

在开始之前简单阐述下lamp架构:

Linux+Apache+Mysql+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。

从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案.想深入了解可自行Google之~

开始:

我个人比较喜欢redhat系统,像ubuntu企业版、debian、BSD之类的没怎么用。建议大家只研究好一种版本的系统即可,否则学的多了学不精!其次我喜欢yum安装软件,比起繁琐的源代码编译过程简单过了,可以略过复杂的依赖关系,源代码方式大家可自行Google研究之~

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

为测试时不出现必要的麻烦,先暂时关闭防火墙及Selinux,等熟悉后大家再开启。
[root@localhost ~]# service iptables stop         //关闭iptables防火墙
[root@localhost ~]# setenforce 0                      //临时关闭selinux

安装php环境:
[root@localhost ~]# yum install -y httpd php php-mysql mysql-server

httpd //apache服务器  php//php主程序  php-mysql//连接mysql数据库组件  mysql-server//mysql数据库主服务

重启apache、mysql服务,初始化mysql数据库、并且将其加为开机自启动:

[root@localhost ~]# service httpd restart && chkconfig httpd on && service mysqld restart && chkconfig mysqld on
停止 httpd:                                               [失败]
启动 httpd:                                               [确定]
停止 MySQL:                                               [失败]
初始化 MySQL 数据库: Installing MySQL system tables…
OK
Filling help tables…
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password ‘new-password’
/usr/bin/mysqladmin -u root -h localhost.localdomain password ‘new-password’

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[确定]
启动 MySQL:                                               [确定]
[root@localhost ~]#

我们可以看到启动httpd  mysql服务成功,现在测试php环境是否成功:

[root@localhost ~]# cd /var/www/html/        //apache网站根目录
[root@localhost html]# vi phpinfo.php     //创建php环境测试页
代码:

<? phpinfo(); ?>

保存退出,访问测试:


看到上面信息表示php环境可以运行了。

下面修改下mysql的密码,默认mysql的用户名为root密码为空,这样是不安全的,修改root密码:

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

mysql> use mysql;        //切换数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=PASSWORD(‘123′) where user=’root’;   //更改root密码为123
Query OK, 3 rows affected (0.07 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql>

下面用个实例看一下,安装discuz论坛:

将discuz安装程序目录upload放到/var/www/html/下
修改upload目录中相关目录权限:
Discuz需要以下这些目录及文件需要可读写权限
./config.inc.php
./templates
./attachments
./forumdata
./forumdata/cache
./forumdata/templates
./forumdata/threadcaches
./forumdata/logs
./uc_client/data/cache/

在浏览器中输入:http://172.17.1.11/upload/install/根据提示进行安装,在此就不再截图了,注意下配置mysql数据库的时候注意填写刚才修改的密码。其他根据情况填写直至安装完成后跳转到论坛首页。

下面看下apache的住配置文件httpd.conf:

[root@localhost ~]# vi /etc/httpd/conf/httpd.conf

简单的说下配置含义

ServerRoot “/etc/httpd”          //apache程序主目录
PidFile run/httpd.pid                 //pid文件路径

Timeout 120       //超时

KeepAlive Off   //保持一直连接

MaxKeepAliveRequests 100

KeepAliveTimeout 15

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

以上都是性能优化,可以参考下apache文档:

https://www.rootop.org/ApacheManual/Apache2.2_zh_CN/

Listen 80        //监听端口  web服务器都是工作在80端口

Include conf.d/*.conf            //加载conf.d下的所有.conf配置文件

DocumentRoot “/var/www/html”       //网站的根目录

#NameVirtualHost *:80          //以下是虚拟主机的配置。我们大部分用的是基于域名的虚拟主机
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

大家可自行搜索本博客下的虚拟主机配置文章。

php的配置文件位于/etc/php.ini

大部分配置都有相关的解释:

extension_dir = “/usr/lib64/php/modules”     //php模块路径

display_errors = Off     //打开错误调试,开发比较实用
; Whether to allow HTTP file uploads.
file_uploads = On           //允许上传

#extension=msql.so       //注意下这个部分,在我们编译进php需要的模块时候,需要在此加载,比如比较常用的json.so模块。

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M          //上传大小

简单说这些,大家可Google之~

mysql的住配置文件:

[root@localhost ~]# vi /etc/my.cnf           //主配置文件

默认的配置文件比较简单

[mysqld]
datadir=/var/lib/mysql             //mysql程序目录
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

在mysq安装好后会有几个根据数据库运行大小有几个不同的配置文件,主要是性能方面配置的不同:

[root@localhost ~]# cd /usr/share/mysql/
[root@localhost mysql]# ll

-rw-r–r– 1 root root   4972 2010-01-30 my-huge.cnf
-rw-r–r– 1 root root  20970 2010-01-30 my-innodb-heavy-4G.cnf
-rw-r–r– 1 root root   4948 2010-01-30 my-large.cnf
-rw-r–r– 1 root root   4955 2010-01-30 my-medium.cnf
-rw-r–r– 1 root root   2526 2010-01-30 my-small.cnf

先简单写到这儿,等想到了再补充。

2011-11-09
发表者 Venus
暂无评论

更改php上传限制(phpmyadmin Import上传限制)

当对sql脚本通过phpmyadmin导入时,会有个提示,不能上传大于2M的文件,要不会报错。更改此限制方法:

编辑php.ini配置文件

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
; http://www.php.net/manual/en/ini.core.php#ini.file-uploads
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://www.php.net/manual/en/ini.core.php#ini.upload-tmp-dir
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
; http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize

upload_max_filesize = 5M
memory_limit =   10M  //要大于upload_max_filesize
post_max_size =   10M   //要大于upload_max_filesize

phpmyadmin帮助文档:
The first things to check (or ask your host provider to check) are the values of upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file. All of these three settings limit the maximum size of data that can be submitted and handled by PHP. One user also said that post_max_size and memory_limit need to be larger than upload_max_filesize.

重启apache生效!