安装LAMP
1 2 3 apt-get update apt-get upgrade apt-get install apache2 mysql-server mysql-client php5 php5-mysql
选配:
phpmyadmin
1 2 apt-get install phpmyadmin ln -s /usr/share/phpmyadmin/ /var/www/
vsftpd
1 2 3 4 5 6 7 apt-get install vsftpd useradd -d /var/www ftpypw chown ftpypw /var/wwwpasswd ftpypw nano /etc/vsftpd.conf /etc/init.d/./vsftpd restart
anonymous_enable=NO local_enable=YES write_enable=YES
wordpress
https://cn.wordpress.org/ 下载好最新版,解压后通过ftp上传即可
创建新的ftp用户:
1 2 3 4 mkdir /var/wzquseradd -d /var/wzq ftpwzq chown ftpypw /var/wwwls -l
php相关配置
1 nano /etc/php5/apache2/php.ini
display_errors = On
upload_max_filesize = 8M
max_execution_time = 300
memory_limit = 128M
配置多个站点:apache2:
1 2 cd /etc/apache2/sites-enabledls
1 2 3 4 5 6 7 <VirtualHost *:80 > ServerName ypw.hk ServerAlias ypw.hk DocumentRoot "/var/www/" ErrorLog "/var/log/apache2/edunuke_errors.log" CustomLog "/var/log/apache2/edunuke_accesses.log" common </VirtualHost >
配置mysql编码问题:
1 2 3 4 5 6 7 8 9 10 11 12 13 mysql -u root -proot set character_set_client = utf8;set character_set_server = utf8;set character_set_connection = utf8;set character_set_database = utf8;set character_set_results = utf8;set collation_connection = utf8_general_ci;set collation_database = utf8_general_ci;set collation_server = utf8_general_ci;show variables like 'character_set_%' ; nano /etc/mysql/my.cnf service mysql restart
1 2 3 4 5 6 7 8 [client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] character-set-server=utf8
编码还有问题的话:
php每次查询之前加这句话:mysql_query("SET NAMES UTF8");
就像下面一样:
1 2 3 4 $con = mysql_connect (SAE_MYSQL_HOST_M.':' .SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);$db =mysql_select_db ("app_ypw2" , $con );mysql_query ("SET NAMES UTF8" );$count = mysql_query ("SELECT COUNT(*) FROM content" );
wordpress配置缓存(WP Super
Cache):
1 2 3 4 a2enmod rewrite a2enmod headers a2enmod expires /etc/init.d/apache2 force-reload
去掉工具栏wordpress.org:
在wp-includes/default-widgets.php中修改,搜索wordpress.org然后删除
wordpress配置gravatar头像:
将以下内容添加到主题文件的functions.php里:
1 2 3 4 5 function get_avatar_deadwood ( $avatar ) { $avatar = str_replace (array ("gravatar.proxy.ustclug.org" ,"gravatar.proxy.ustclug.org" ,"gravatar.proxy.ustclug.org" ,"gravatar.proxy.ustclug.org" ),"gravatar.duoshuo.com" ,$avatar ); return $avatar ; } add_filter ( 'get_avatar' , 'get_avatar_deadwood' );
php配置memcached:
1 2 apt-get install memcached php5-memcache php5-memcached /etc/init.d/apache2 restart
wordpress配置memcached:
首先去插件安装Memcached Object Cache 2.0.2 然后:
1 2 cd /var/wwwcp wp-content/plugins/memcached/object-cache.php wp-content/
然后删了之前那个memcached...
复制的那个content目录下的插件会在Drop-in高级插件中显示. 安装成功之后去WP
Super Cache 设置的高级设置中开启 使用对象缓存系统来存储缓存文件。
(实验室功能)
memcached命中率查看:
1 2 3 telnet 127.0.0.1 11211 stats quit
其中我感兴趣的数据就是这些:
1 2 3 4 5 6 STAT cmd_get 919 STAT cmd_set 281 STAT cmd_flush 0 STAT cmd_touch 0 STAT get_hits 746 STAT get_misses 173
给wordpress添加查询次数,加载时间:
1 2 cd /var/www/wp-content/themes/twentyfourteennano footer.php
在最底部添加:
1 本次查询<?php echo get_num_queries ();?> 次,耗时<?php timer_stop (1 );?> 秒
就像这样:
1 2 3 4 5 6 7 8 9 10 11 <p style ="float:right;" > 本次查询<?php echo get_num_queries();?> 次,耗时<?php timer_stop(1);?> 秒 </p > </div > </footer > </div > <?php wp_footer(); ?> </body > </html >