wkhtmltopdf 中文乱码可以在liunx下跑么

  在Linux下似乎没有什么写简历的好工具,于是学习了一下网络上大牛的做法,总结一下:
hg clone -r 8.6.8 /hg/ asciidoc-8.6.8
$ autoconf
$ ./configure
$ sudo make install
安装wkhtmltopdf(对于内含URL的html转化会失效,带有Qt补丁的版本转化出来的PDF字体太大)
sudo apt-get install wkhtmltopdf
vi res.txt
asciidoc 转化为html
asciidoc res.txt
wkhtmltopdf 将html转化为pdf
wkhtmltopdf res.html&res.pdf
本来将html转化为pdf有多种方式,可是经过我的对比,使用wkhtmltopdf的转化效果最佳。
这里附上一个我自己的简历模板:
== Yue Qiao
Programming skills
- Familiar with X86 Assembly- Proficient with C- Proficient with C++- Proficient with Python- Proficient with Linux Programming
Programming tools
- Source code management: Git- Editor/IDE:vim,Emacs, Visual Studio- OS:Linux(Ubuntu),Windows 7
== Experience
Transplant of xxx 2011
- Transplant
Implementation of xxx 2012
- Implementation - Decrease
== Education[horizontal][black]#CS,University#:: 2008 - 2012
[black]#MES,University#:: 2012 - 2014
阅读(...) 评论()Qt Webkit HTML Converter - Install wkhtmltopdf
This page documents installation of
on Gentoo Linux using the patched Qt4 libraries from the wkhtmltopdf project.
Notice that portage provides , but some features will be missing as the binaries are linked against the standard Qt libraries. See the
for further information.
The destination directory will be /usr/local/wkhtmltopd, with the patched Qt 4 installed in the sub directory qt4.
Prepare source code
Download the latest
for wkhtmltopdf:
bash$> mkdir wkhtmltopdf && cd wkhtmltopdf
bash$> wget /files/wkhtmltopdf-0.11.0_rc1.tar.bz2
bash$> tar xfvj wkhtmltopdf-0.11.0_rc1.tar.bz2
bash$> ln -s wkhtmltopdf-0.11.0_rc1 wkhtmltopdf
Install patched Qt 4
Use git to clone the Qt repository.
bash$> git clone git://gitorious.org/~antialize/qt/antializes-qt.git wkhtmltopdf-qt
bash$> cd wkhtmltopdf-qt
bash$> git checkout 4.8.4
bash$> QTDIR=. ./bin/syncqt
Configure, build and install Qt. Pass --help to configure to see all available options.
bash$> cd wkhtmltopdf-qt
bash$> ./configure -nomake tools,examples,demos,docs,translations -opensource -prefix /usr/local/wkhtmltopdf/qt4
bash$> make -j6 && make install
Install wkhtmltopdf
With Qt installed, its time to install wkhtmltopdf.
bash$> cd wkhtmltopdf
Update QtGui.prl path in common.pri:
bash$> sed -i s%'QtGui.framework/QtGui.prl'%'libQtGui.prl'%g common.pri
Generate makefiles, build and install using QMAKE from the patched Qt installation:
bash$> /usr/local/wkhtmltopdf/qt4/bin/qmake
bash$> make
bash$> make install INSTALL_ROOT=/usr/local/wkhtmltopdf
For convenience, create symbolic links in /usr/local/bin and /usr/local/lib:
bash$> ( cd /usr/local/bin && ln -s ../wkhtmltopdf/bin/* . )
bash$> ( cd /usr/local/lib && ln -s ../wkhtmltopdf/lib/* . )
Update library resolve cache:
bash$> ldconfig
Try out the installation with some simple example. If installed correct, there shouldn't be any complains about missing X11. If so, it's an indication that the wrong Qt libraries being used.
bash$> wkhtmltopdf toc http://www.uu.se uu.pdf
Loading pages (1/6)
Counting pages (2/6)
Loading TOC (3/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
The generated PDF-file should contain the front page and a table of content (TOC).
Troubleshoot
Compilation errors
Compilation fails with this error:
/usr/include/unicode/umachine.h:298:17: error: conflicting declaration 'typedef int32_t UChar32'
../JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h:71:18: error: 'UChar32' has a previous declaration as 'typedef uint32_t UChar32'
Try reinstall libxml2 without icu or enable icu support.:
bash$> cd wkhtmltopdf-qt
bash$> sed -i -e '/CONFIG\s*+=\s*text_breaking_with_icu/ s:^#\s*::' \
src/3rdparty/webkit/Source/JavaScriptCore/JavaScriptCore.pri
bash$> make
Tested on Gentoo Linux with g++ 4.6.3. Go to
for more information.
Dynamic linking
Check that dynamic linking is picking the corrent Qt 4 and wkhtmltopdf libraries:
bash$> ldd /usr/local/bin/wkhtmltopdf
linux-vdso.so.1 (0x00007fffc1bff000)
libwkhtmltox.so.0 => /usr/local/lib64/libwkhtmltox.so.0 (0xf06000)
libQtWebKit.so.4 => /usr/local/wkhtmltopdf/qt4/lib/libQtWebKit.so.4 (0x4000)
libQtSvg.so.4 => /usr/local/wkhtmltopdf/qt4/lib/libQtSvg.so.4 (0xfef1000)
libQtXmlPatterns.so.4 => /usr/local/wkhtmltopdf/qt4/lib/libQtXmlPatterns.so.4 (0xe000)
libQtGui.so.4 => /usr/local/wkhtmltopdf/qt4/lib/libQtGui.so.4 (0xea69000)
libQtNetwork.so.4 => /usr/local/wkhtmltopdf/qt4/lib/libQtNetwork.so.4 (0xee000)
libQtCore.so.4 => /usr/local/wkhtmltopdf/qt4/lib/libQtCore.so.4 (0xb9000)
Installed files
Check that all wkhtmltopdf binaries, libraries and header files is correct installed in /usr/local/wkhtmltopdf:
bash$> find /usr/local/wkhtmltopdf | grep -v qt4 | xargs ls -ld
drwxr-xr-x 6 root root
4096 Apr 16 10:27 /usr/local/wkhtmltopdf
drwxr-xr-x 2 root root
4096 Apr 16 11:43 /usr/local/wkhtmltopdf/bin
-rwxr-xr-x 1 root root 145544 Apr 16 11:43 /usr/local/wkhtmltopdf/bin/wkhtmltoimage
-rwxr-xr-x 1 root root 235736 Apr 16 11:43 /usr/local/wkhtmltopdf/bin/wkhtmltopdf
drwxr-xr-x 3 root root
4096 Apr 16 00:36 /usr/local/wkhtmltopdf/include
drwxr-xr-x 2 root root
4096 Apr 16 11:43 /usr/local/wkhtmltopdf/include/wkhtmltox
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/converter.hh
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/dllbegin.inc
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/dllend.inc
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/image.h
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/imageconverter.hh
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/imagesettings.hh
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/loadsettings.hh
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/multipageloader.hh
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/pdf.h
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/pdfconverter.hh
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/pdfsettings.hh
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/settings.hh
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/utilities.hh
-rw-r--r-- 1 root root
2011 /usr/local/wkhtmltopdf/include/wkhtmltox/websettings.hh
drwxr-xr-x 2 root root
4096 Apr 16 11:43 /usr/local/wkhtmltopdf/lib
lrwxrwxrwx 1 root root
22 Apr 16 11:43 /usr/local/wkhtmltopdf/lib/libwkhtmltox.so -> libwkhtmltox.so.0.10.0
lrwxrwxrwx 1 root root
22 Apr 16 11:43 /usr/local/wkhtmltopdf/lib/libwkhtmltox.so.0 -> libwkhtmltox.so.0.10.0
lrwxrwxrwx 1 root root
22 Apr 16 11:43 /usr/local/wkhtmltopdf/lib/libwkhtmltox.so.0.10 -> libwkhtmltox.so.0.10.0
-rwxr-xr-x 1 root root 428088 Apr 16 11:43 /usr/local/wkhtmltopdf/lib/libwkhtmltox.so.0.10.0vi /etc/haproxy/haproxy.cfg
127.0.0.1 local2
/var/lib/haproxy
/var/run/haproxy.pid
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
log global
dontlognull
timeout connect 1000
timeout client 150000
timeout server 150000
listen smtp
bind *:465
server s1 :465
listen pop
bind *:995
log global
server s2 :995
listen imap
bind *:993
log global
server s3 :993
然后在host里将 指向haproxy所在的服务器IP即可正常使用
在美国VPS上搭建shadowsocks服务,阿里云服务器上搭建haproxy服务
使用原理: PC-&阿里云frontend-&阿里云backend-&美国 VPS
安装haproxy: yum install haproxy
===========================================
7.13 注: 如果yum找不到haproxy的话, 需要下载执行一下:
#CentOS 5 – 32-bit
rpm -Uvh .au/pub/epel/5/i386/epel-release-5-4.noarch.rpm
#CentOS 5 – 64-bit
rpm -Uvh .au/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
#CentOS 6 – 32-bit
rpm -Uvh .au/pub/epel/6/i386/epel-release-6-8.noarch.rpm
#CentOS 6 – 64-bit
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
============================================
SERVER_IP就是要转发到的服务器IP
vim /etc/haproxy/haproxy.cfg
log global
dontlognull
timeout connect 1000
timeout client 150000
timeout server 150000
frontend ss-in
bind *:8388
default_backend ss-out
backend ss-out
server server1 SERVER_IP:PORT maxconn 20480
参考 /shadowsocks/shadowsocks/wiki/Setup-a-Shadowsocks-relay
启动haproxy: haproxy -f /etc/haproxy/haproxy.cfg
查找了不少资料, 并且刚刚尝试成功后考虑写下心得, 避免下次安装又需要重新索引资料
将一体机USB连接到服务器后.
1. 打印机支持cups, 先安装cups
yum –y install cups
2.配置cups
默认web配置只对localhost开放,需要编辑配置文件来打开,修改cupsd.conf如下:
vim /etc/cups/cupsd.conf
# "$Id: cupsd.conf.in -08 00:16:30Z mike $"
Sample configuration file for the Common UNIX Printing System (CUPS)
scheduler.
See "man cupsd.conf" for a complete description of this
# Log general information in error_log - change "info" to "debug" for
# troubleshooting...
LogLevel info
# Administrator user group...
SystemGroup sys root
# Only listen for connections from the local machine.
#Listen localhost:631
Listen *:631
Listen /var/run/cups/cups.sock
# Show shared printers on the local network.
Browsing On
#BrowseOrder allow,deny
BrowseOrder deny,allow
# (Change '@LOCAL' to 'ALL' if using directed broadcasts from another subnet.)
BrowseAllow @LOCAL
#BrowseAddress @LOCAL
#Allow @LOCA
# Default authentication type, when authentication is required...
DefaultAuthType Basic
DefaultEncryption IfRequested
# Restrict access to the server...
&Location /&
#Order allow,deny
Order deny,allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.*
Allow @LOCAL
&/Location&
# Restrict access to the admin pages...
&Location /admin&
#Encryption Required
#Order allow,deny
Encryption Never
Order deny,allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.*
Allow @LOCAL
&/Location&
# Restrict access to configuration files...
&Location /admin/conf&
#AuthType Default
#Require user @SYSTEM
#Order allow,deny
Encryption Never
AuthType Default
Require user @SYSTEM
Order deny,allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.*
Allow @LOCAL
&/Location&
# Set the default printer/job policies...
&Policy default&
# Job-related operations must be done by the owner or an administrator...
&Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job&
Require user @OWNER @SYSTEM
Order deny,allow
# All administration operations require an administrator to authenticate...
&Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default&
AuthType Default
Require user @SYSTEM
Order deny,allow
# All printer operations require a printer operator to authenticate...
&Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs&
AuthType Default
Require user @SYSTEM
Order deny,allow
# Only the owner or an administrator can cancel or authenticate a job...
&Limit Cancel-Job CUPS-Authenticate-Job&
Require user @OWNER @SYSTEM
Order deny,allow
&Limit All&
Order deny,allow
MaxLogSize
# End of "$Id: cupsd.conf.in -08 00:16:30Z mike $".
3. 安装官网提供的linux驱动
下载 Driver Install Tool 到 /root/soft
gunzip linux-brprinter-installer-*.*.*-*.gz
bash linux-brprinter-installer-*.*.*-* MFC-7360
而后一堆选项一路回车即可
最后cups网页端看看有没有7360打印机, 没有的话啊add printer
http://服务器ip: 631/
保留重启命令
# service cups restart
# service smb restart
===================================
7.22 修正 另外的连接打印机的方法
确信自己已经安装了打印机的驱动,例如我的是Brother_MFC-7360,就先安装Brother_MFC-7360 for windows 7 的驱动
然后 控制面板—》查看设备和打印机==》添加打印机
一:添加网络打印机
二:选择 【我需要的打印机不在列表】中
三:选择 【按名称选择共享打印机】 , 填写你的打印机地址,我的是http://192.168.1.8:631/printers/MFC-7360 就填写这个。
四:驱动选择 MFC-7360,点击 确定,结束。
需求: 将网页转为pdf或者图片,并提供下载。
wkhtmltox项目主页:http://wkhtmltopdf.org/:http://wkhtmltopdf.org/   支持html转pdf、image
php扩展php-wkhtmltox项目主页: /mreiferson/php-wkhtmltox:/mreiferson/php-wkhtmltox
1、下载安装wkhtmltox系统环境
http://wkhtmltopdf.org/downloads.html:http://wkhtmltopdf.org/downloads.html 根据系统类型选择下载wkhtmltox:
这里我的系统环境是CentOS 6-64bit  所以选择:Linux CentOS 6 – 64bit
下载下来后是一个rpm包 [wkhtmltox-0.12.2_linux-centos6-amd64.rpm]。
安装wkhtmltox:
& rpm -ivh wkhtmltox-0.12.2_linux-centos6-amd64.rpm
error: Failed dependencies:
     xorg-x11-fonts-75dpi is needed by wkhtmltox-1:0.12.2-1.x86_64
# 提示需要安装75dpi 
& yum search 75dpi
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.:http://centos.
* extras: centos.:http://centos.
* updates: centos.:http://centos.
============================================================ N/S Matched: 75dpi ============================================================
xorg-x11-fonts-75dpi.noarch : A set of 75dpi resolution fonts for the X Window System.
xorg-x11-fonts-ISOdpi.noarch : A set of 75dpi ISO-8859-1 fonts for X.
xorg-x11-fonts-ISOdpi.noarch : ISOdpi fonts
xorg-x11-fonts-ISOdpi.noarch : ISOdpi fonts
xorg-x11-fonts-ISOdpi.noarch : A set of 75dpi Central European language fonts for X.
xorg-x11-fonts-ISOdpi.noarch : ISOdpi fonts
  Name and summary matches only, use &search all& for everything.
& yum install xorg-x11-fonts-75dpi.noarch
安装完成后,再执行:
& rpm -ivh wkhtmltox-0.12.2_linux-centos6-amd64.rpm
如果无法安装xorg-x11-fonts-75dpi.noarch
直接使用如下方法解压rpm包内已经编译好的包:
& rpm2cpio wkhtmltox-0.12.2_linux-centos6-amd64.rpm | cpio -div
完成后在当前目录会生成一个 usr 的目录,里面包含 local/bin,local/include,local/share,local/lib四个文件夹
将对应文件夹的内容拷贝至/usr/local即可!
& cp -Rv ./usr/local/* /usr/local/
wkhtmltox系统环境安装完成!
2、安装php-wkhtmltox扩展
下载github上的源码包 [php-wkhtmltox_master.zip]
& unzip php-wkhtmltox_master.zip
& cd phpwkhtmltox
& ./configure –with-php-config=/usr/local/php/bin/php-config #此处按照各自系统php安装路径不同而定
& make && make install
& ldconfig #重新加载系统动态链接库
# 检查扩展是否成功  如果能看到phpwkhtmltox  说明扩展成功
php-wkhtmltox扩展安装完成。
3、修改php.ini文件开启扩展
& vi /usr/local/php/etc/php.ini
extension=phpwkhtmltox.so
& /etc/init.d/php-fpm restart
本文参考: http://www.phpboy.net/linux/575.html:http://www.phpboy.net/linux/575.html
安装部分可使用本文介绍的安装部分,有些可能需要中文字体支持,可参考上文中得中文字体库安装部分进行扩展。
让linux CentOS支持微软雅黑字体
下载或者从本地windows拷贝微软雅黑(注意从windows系统里面拷贝出来应该是有2个文件),并上传到linux服务器
让Linux CentOS支持Consolas字体(技术类博客可能会发布一个示例代码,大部分wordpress技术博客都会安装SyntaxHighlighter插件,而该插件代码显示字体首选的是Consolas字体,所以为了html转换成图片时示例代码显示得好看,我们也需要让linux支持Consolas字体)
下载或者从本地windows拷贝Consolas(注意从windows系统里面拷贝出来应该是有4个文件),并上传到linux服务器
把字体文件拷贝到/usr/share/fonts/xxx,其中xxx为新增字体文件夹,如msyh
#cd /usr/share/fonts/
#mkdir msyh
建立字体缓存
#mkfontscale
#mkfontdir
#fc-cache -fv
cd /etc/yum.repos.d/
yum install wkhtmltopdf
查看大于500M的命令:
find / -size +500M -exec ls -lh {} \;
清空日志脚本
cat /dev/null & /var/log/syslog
cat /dev/null & /var/adm/sylog
cat /dev/null & /var/log/wtmp
cat /dev/null & /var/log/maillog
cat /dev/null & /var/log/messages
cat /dev/null & /var/log/openwebmail.log
cat /dev/null & /var/log/maillog
cat /dev/null & /var/log/secure
cat /dev/null & /var/log/httpd/error_log
cat /dev/null & /var/log/httpd/ssl_error_log
cat /dev/null & /var/log/httpd/ssl_request_log
cat /dev/null & /var/log/httpd/ssl_access_log
crashplan是个好东西, 但是在我的服务器centos6中选择目录的时候出现了乱码, 因此选择后无法进行正常备份.
纠结了好久, 想重新选择dropbox, 在国外论坛混了两天, 终于找到了适合自己的方案
先看系统的编码
vim /etc/sysconfig/i18n
当前系统为 zh_CN.GB18030 编码
编辑crashplan的run.conf文件
vim /usr/local/crashplan/bin/run.conf
在最前面加入
export LC_ALL=zh_CN.GB18030
/usr/local/crashplan/bin/CrashPlanEngine restart
连接后已中文目录已可以正常选择.
泪流满面啊, 差点因此放弃crashplan.
之前一直想用drobox作为服务器重要资料的备份, 结果GFW一直干扰, 虽然后来有了VPN+route的解决方案, 但是也一直没用, 可能也是担心同步dropbox后资料不加密的问题.
后来了解到了crashplan这款专门用于备份的神器. 尝试在本机使用后果断在服务器上安装了一个, 现在运行良好, 无限空间+不错的上错速度+加密, 30天的试用过期后考虑购买, 一个月才$4.
1. 首先下载安装包
解压后运行 /install.sh, 安装过程会检测本机是否有jre环境, 没有的话自动下载安装, 由于国外的速度实在太慢, 所有我是用下载工具从win里下载好jre的安装包再上传到同一目录后运行, 速度会快很多.
默认安装到 /usr/local/crashplan目录, 安装后会出现很多询问路径的东西, 除了备份路径需要注意下, 其他回车即可.
服务启动方法:  /usr/local/crashplan/bin/CrashPlanEngine start
服务停止方法:  /usr/local/crashplan/bin/CrashPlanEngine stop
===========================================
如何管理和配置centos6里的crashplan:
使用xshell打开连接到服务器, 添加一个隧道, 如图
在windows的电脑安装CrashPlan的客户端, 默认运行是管理本机, 我们需要修改一下让它直接管理服务器里的服务:
编辑 C:\Program Files\CrashPlan\conf\ui.properties 文件, 将 #servicePort=4243 修改为 servicePort=4200
运行后即可设置.
服务器一开始使用了lnmp.org的一键安装包架设了环境, 后来打算迁移邮件服务器, 不靠iRedMail这种整合包, 手动配置过postfix+dovecot+postfixadmin没成功, 今天终于在一个网友的博文上发现了脚本, 使用后发现部分问题, 修正后发布如下:
修正包括dovecot的下载路径和saslauthd的安装路径.
服务器环境为centos6.6, postfix如安装不成功则需要注意一下安装时候提示的html目录路径是否存在
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# Check if user is root
if [ $(id -u) != &0& ]; then
echo &Error: You must be root to run this script, please use root to install lnmp&
cur_dir=$(pwd)
echo &======postfix+dovecot+cyrus-sasl+postfixadmin one key install==========&
echo &================write by James Yang()================&
echo &=======================================================================&
postfixpwd=&postfixpwd&
echo &Please input the postfix password of mysql:&
read -p &(Default password: postfixpwd):& postfixpwd
if [ &$postfixpwd& = && ]; then
postfixpwd=&postfixpwd&
echo &Please input your domain:&
read -p &(Default domain name: ):& domainname
if [ &$domainname& = && ]; then
domainname=&&
echo &Please input the account name of postfixadmin administrator (should be your email address):&
read -p &(Default account name: ):& accountname
if [ &$accountname& = && ]; then
accountname=&&
echo &================step 1: check install files===============&
if [ -s postfixadmin_2.3.4.tar.gz ]; then
echo &postfixadmin [found]&
echo &postfixadmin not found, downloading now...&
wget -c http://ncu.dl.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-2.3.4/postfixadmin_2.3.4.tar.gz
if [ -s postfix-2.8.9.tar.gz ]; then
echo &postfix-2.8.9.tar.gz [found]&
echo &postfix not found, downloading now...&
wget -c http://mirror.postfix.jp/postfix-release/official/postfix-2.8.9.tar.gz
if [ -s dovecot-2.0.15.tar.gz ]; then
echo &dovecot-2.0.15.tar.gz [found]&
echo &dovecot not found, downloading now...&
wget -c http://dovecot.org/releases/2.0/dovecot-2.0.15.tar.gz
if [ -s cyrus-sasl-2.1.25.tar.gz ]; then
echo &cyrus-sasl-2.1.25.tar.gz [found]&
echo &cyrus-sasl not found, downloading now...&
wget -c http://asg3.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.25.tar.gz
echo &===============step 2: stop sendmail========================&
read -p &press any key to continue....:& input_key
#service sendmail stop
#chkconfig --level 345 sendmail off
yum -y remove sendmail
cd $cur_dir
echo &===============step 3: intall cyrus-sasl===================&
read -p &press any key to continue....:& input_key
yum -y remove cyrus-sasl
tar xzvf cyrus-sasl-2.1.25.tar.gz
cd cyrus-sasl-2.1.25
./configure --enable-login --enable-sql --with-mysql=/usr/local/mysql/
make testsaslauthd
make install
ln -f -s /usr/local/lib/sasl2 /usr/lib64/sasl2
echo &/usr/local/sbin/saslauthd -a shadow&&&/etc/rc.local
cd $cur_dir
echo &==============step 4: install postfixadmin======================&
read -p &press any key to continue....:& input_key
tar zxvf postfixadmin_2.3.4.tar.gz
mv -f postfixadmin-2.3.4 /home/wwwroot/postfixadmin
cd /home/wwwroot/postfixadmin
mv config.inc.php config.inc.php.bak
cp -f $cur_dir/conf/postfixadmin_config.inc.php config.inc.php
cp -f $cur_dir/conf/postfix.sql /home/wwwroot/
sed -i 's/postfixpwd/'$postfixpwd'/g' config.inc.php
sed -i 's//'$accountname'/g' config.inc.php
sed -i '/'$domainname'/g' config.inc.php
sed -i 's//'$accountname'/g' /home/wwwroot/postfix.sql
sed -i 's/postfixpwd/'$postfixpwd'/g' /home/wwwroot/postfix.sql
echo &login mysql root to import database:&
/usr/local/mysql/bin/mysql -uroot -p &/home/wwwroot/postfix.sql
rm /home/wwwroot/postfix.sql -f
#echo &fixing a bug in postfixadmin edit-mailbox.php:&
#sed -i &s/formvars\['local_part'\]/formvars\['\$local_part'\]/g& /home/wwwroot/postfixadmin/edit-mailbox.php
echo &===============postfixadmin install completed==================&
cd $cur_dir
echo &===============step 5: install postfix======================&
read -p &press any key to continue(please always press enter key to continue till install complete)....:& input_key
yum -y remove postfix
groupdel postfix
userdel postfix
groupadd -g 1000 postfix
useradd -u 1000 -g postfix -s /sbin/nologin -d /dev/null postfix
groupadd -g 1001 postdrop
yum -y install db4-devel
tar zxvf postfix-2.8.9.tar.gz
cd postfix-2.8.9
make -f Makefile.init makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DDEF_SERVER_SASL_TYPE=\&dovecot\&' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm'
make && make install
mv /etc/postfix/main.cf /etc/postfix/main.cf.bak
mv /etc/postfix/master.cf /etc/postfix/master.cf.bak
cp -f $cur_dir/conf/main.cf /etc/postfix/
cp -f $cur_dir/conf/master.cf /etc/postfix/
cp -f $cur_dir/conf/mysql-*.cf /etc/postfix/
sed -i &s/postfixpwd/$postfixpwd/g& `grep postfixpwd -rl /etc/postfix/*.cf`
sed -i '/'$domainname'/g' /etc/postfix/main.cf
echo &===============postfix install completed==================&
echo &===============step 6: install dovecot======================&
read -p &press any key to continue....:& input_key
yum -y remove dovecot
cd $cur_dir
groupdel dovecot
groupadd -g 1002 dovecot
tar zxvf dovecot-2.0.15.tar.gz
cd dovecot-2.0.15
./configure --prefix=/usr/local/dovecot --sysconfdir=/etc --with-mysql CPPFLAGS=-I/usr/include/mysql LDFLAGS=-L/usr/lib/mysql
make && make install
mv -f /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.bak
mv -f /etc/dovecot/dovecot-mysql.conf /etc/dovecot/dovecot-mysql.conf.bak
cp -f $cur_dir/conf/dovecot.conf /etc/dovecot/
cp -f $cur_dir/conf/dovecot-mysql.conf /etc/dovecot/
sed -i &s/postfixpwd/$postfixpwd/g& `grep postfixpwd -rl /etc/dovecot`
echo &===============dovecot install completed==================&
newaliases
mkdir -p /var/vmail
chown postfix:postfix /var/vmail -R
/usr/local/sbin/saslauthd -a shadow
/usr/local/dovecot/sbin/dovecot
#chown postfix:postfix /usr/local/dovecot/var/run/dovecot/auth-client -R
postfix start
echo &=============set 7: set postfix & dovecot startup=================&
read -p &press any key to continue....:& input_key
echo &postfix start& &&/etc/rc.local
echo &/usr/local/dovecot/sbin/dovecot& &&/etc/rc.local
echo &Install postfix+dovecot+cyrus-sasl+postfixadmin completed! enjoy it.&
echo &=========================================================================&
echo &POSTFIX FOR REDHAT VPS
Written by James Yang ()&
echo &=========================================================================&
echo &the mysql postfix user is account/password is postfix/&$postfixpwd
echo &default postfixadmin account/password:&$accountname&/admin&
echo &please browser http://www.&$domainname&/postfixadmin/login.php to reset the password and setup your mailserver&
之前一直用自己写的shell脚本增添端口, 突然忘记怎么去手动编辑防火墙配置文件了, 留下来备注吧
vi /etc/sysconfig/iptables}

我要回帖

更多关于 wkhtmltopdf java 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信