WordPress 文件权限设置脚本

参考网上经验,写了个WP文件权限设置脚本。方便部署迁移只用。

#!/bin/bash
# $1 => wp_path
if [ 0 -eq $# ]; then
exit
fi
if [ ! -d "${1}" ]; then
echo invalid path.
exit
fi
cd ${1}
if [ ! -d "./wp-content/" ]; then
echo wordpress not found.
exit
fi
chgrp www-data ./ -R
chmod 644 ./ -R
chmod 755 ./
find ./ -type d -exec chmod 755 {} \;
find ./ -iname "*.php" -exec chmod 644 {} \;
chmod 775 ./wp-content/
chmod 775 ./wp-content/plugins/
chmod 775 ./wp-content/themes/
find ./wp-content/themes/ -iname "*.php" -exec chmod 664 {} \;
find ./wp-content/themes/ -iname "*.css" -exec chmod 664 {} \;
chmod 644 ./wp-content/themes/index.php
if [ -d "./wp-content/uploads" ]; then
chmod 664 ./wp-content/uploads/ -R
chmod 775 ./wp-content/uploads/
find ./wp-content/uploads/ -type d -exec chmod 775 {} \;
fi
if [ -d "./wp-content/upgrade" ]; then
chmod 775 ./wp-content/upgrade/
fi
echo done.

[转]php5.3.10的安装

php5.3.10的安装

下面以最新的php-5.3.10为例进行安装。

wget http://cn.php.net/distributions/php-5.3.10.tar.gz
tar -zxvf php-5.3.10.tar.gz
cd php-5.3.10
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fpm –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap –enable-tidy –enable-json

上面的具体参数可以使用./configure –help查看

make ZEND_EXTRA_LIBS=’-liconv’
make test
make && make install   (此处最好分开做,因为make的时候会有报错出现。)

我在上面的make时就报了下面的错误

root/source/php-5.3.10/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127

解决办法是(我的mysql安装目录是/usr/local/msyql,这个视自己的mysql安装路径而定。)
ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib/
64位系统应使用下面的这行
ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib64/

cp php.ini-production /usr/local/php/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf

修改php.ini文件和php-fpm文件中参数,可以手动更改也可以用下面的sed命令更改

sed -i ‘s#short_open_tag = Off#short_open_tag = On#g’ /usr/local/php/etc/php.ini
sed -i ‘s#;pid = run/php-fpm.pid#pid = run/php-fpm.pid#g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s#pm.max_children = 5#pm.max_children = 32#g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s#pm.start_servers = 2#pm.start_servers = 16#g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s#pm.min_spare_servers = 1#pm.min_spare_servers = 8#g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s#pm.max_spare_servers = 3#pm.max_spare_servers = 32#g’ /usr/local/php/etc/php-fpm.conf
sed -i ‘s#;pm.max_requests = 500#pm.max_requests = 120#g’ /usr/local/php/etc/php-fpm.conf

关于php-fpm几个重要参数的调整方面具体可以参看我的另一篇日志:http://www.361way.com/php-fpm/890.html  另外php官方也给出了其中所有参数项的解释说明,具体见http://www.php.net/manual/en/install.fpm.configuration.php

设置开机启动

chmod 755 /etc/init.d/php-fpm
chkconfig –add php-fpm
/etc/init.d/php-fpm start

至此,php的安装完毕。

最后可以再安装一些php的扩展包和开户php加速(具体软件包可以视网上的最新版进行安装):

tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../

tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/usr/local/php/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../

tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql
make
make install
cd ../

tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../

tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../

修改php.ini文件
手工修改:查找/usr/local/php/etc/php.ini中的extension_dir = “./”
修改为extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”
并在此行后增加以下几行,然后保存:
extension = “memcache.so”
extension = “pdo_mysql.so”
extension = “imagick.so”

再查找output_buffering = Off
修改为output_buffering = On

再查找; cgi.fix_pathinfo=0
修改为cgi.fix_pathinfo=0,防止Nginx文件类型错误解析漏洞。

配置eAccelerator加速PHP:
mkdir -p /opt/webserver/eaccelerator_cache
vi /usr/local/php/etc/php.ini

在php.ini配置文件的最末尾,加上以下配置信息:
[eaccelerator]
zend_extension=”/usr/local/php/lib/php/extensions/eaccelerator.so”
eaccelerator.shm_size=”64″
eaccelerator.cache_dir=”/opt/webserver/eaccelerator_cache”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.filter=””
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”3600″
eaccelerator.shm_prune_period=”3600″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″

php的安全性设置:

找到:;open_basedir =
修改为:open_basedir = .:/tmp/   #防止php木马跨站,重要!!
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC
找到:expose_php = On
修改为:expose_php = OFF  #禁止显示php版本的信息
找到:display_errors = On
修改为:display_errors = OFF  #关闭错误提示

wordpress 迁移后,上传文件失败的问题解决

本来一路顺风,环境搭建有点轻车熟路的感觉,中途还优化了一些配置文件结构(nginx+spawn-fcgi),没想到测试的时候,发现插件更新失败,提示:

Could not create directory. /www/blog/wp-content/upgrade/akismet.tmp

同时上传图片也失败,提示:

The uploaded file could not be moved to /www/blog/wp-content/uploads/2011/01/

个杯具的,经排查:

继续阅读wordpress 迁移后,上传文件失败的问题解决

给ubuntu10加装IE6(wine+IEs4Linux)

这两天开始在虚拟机里折腾ubuntu,恰好看到一篇文章说到IEs4Linux,于是就想装个,免得有些时候再开个XP mode麻烦。

没想到这个东西还真不是像apt-get那么简单···过程如下:

一、支持环境安装

sudo apt-get install wine cabextract

目前是wine1.2.1,这一步费时还挺久的,所以后面可以先整

二、下载IEs4Linux并解压

wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
最新的是ies4linux-2.99.0.1,假设解压到~/ies4linux-2.99.0.1

三、安装前的处理步骤

由于这个包有点年头了,所以有些问题在所难免,吾摸索了一下,经验如下:
由于新版wine(目前是1.3.x)用winepath替代了wineprefixcreate,所以需要去/usr/bin 做个软链:
cd /usr/bin/
sudo ln -s winepath wineprefixcreate
下面要改下源代码,否则安装过程你会非常痛苦: 继续阅读给ubuntu10加装IE6(wine+IEs4Linux)