分类归档:开发环境

DEDECMS使用SQL语句批量删除文章

DEDECMS使用SQL批量删除aid文章,有时候批量采集的文章很不满意想都删除不要了,但是在后台一条条的删除文章的话实在太慢了,一次顶多删除30篇文章,所以找了个批量删除文章的SQL语句很好使,切记使用前记得备份下数据库以防万一出问题技术恢复数据库。

SQL语句如下:

DELETE FROM dede_addonarticle WHERE aid >= 1 and aid<=3000;
DELETE FROM dede_arctiny WHERE id >= 1 and id<=3000;
DELETE FROM dede_archives WHERE id >= 1 and id<=3000;

以上的一句意思是从aid1-aid3000 批量删除 ,文章ID在每个文章前面都有。

将以上SQL语句复制粘贴到SQL命令行工具里,然后运行即可。 运行之后完全清空了,回收站里也找不到了。

在ubuntu12.04上架设LAMP(Linode完整教程)

This guide provides step by step instructions for installing a full featured LAMP stack on an Ubuntu 12.04 (Oneiric) system.

In this guide, you will be instructed on setting up Apache, MySQL, and PHP. If you don’t feel that you will need MySQL or PHP, please don’t feel obligated to install them. Make sure you’re logged into your Linode as the “root” user via SSH before proceeding with these instructions.

 

Install and Configure the Apache Web Server

The Apache Web Server is a very popular choice for serving web pages. While many alternatives have appeared in the last few years, Apache remains a powerful option that we recommend for most uses. Issue the following command to install Apache:

apt-get install apache2

Now we’ll configure virtual hosting so that we can host multiple domains (or subdomains) with the server. These websites can be controlled by different users, or by a single user, as you prefer.

Configure Name-based Virtual Hosts

There are different ways to set up virtual hosts, however we recommend the method below. By default, Apache listens on all IP addresses available to it.

First, create a file in the /etc/apache2/sites-available/ directory for each virtual host that you want to set up. Name each file with the domain for which you want to provide virtual hosting. See the following example configurations for the hypothetical “example.com” and “example.org” domains. Substitute your own domain names for those shown below.

File:/etc/apache2/sites-available/example.com

<VirtualHost *:80>
     ServerAdmin webmaster@example.com
     ServerName example.com
     ServerAlias www.example.com
     DocumentRoot /srv/www/example.com/public_html/
     ErrorLog /srv/www/example.com/logs/error.log
     CustomLog /srv/www/example.com/logs/access.log combined
</VirtualHost>

File:/etc/apache2/sites-available/example.org

<VirtualHost *:80>
     ServerAdmin webmaster@example.org
     ServerName example.org
     ServerAlias www.example.org
     DocumentRoot /srv/www/example.org/public_html/
     ErrorLog /srv/www/example.org/logs/error.log
     CustomLog /srv/www/example.org/logs/access.log combined
</VirtualHost>

Notes regarding this example configuration:

  • All of the files for the sites that you host will be located in directories that exist underneath /srv/www. You can symbolically link these directories into other locations if you need them to exist in other places.
  • ErrorLog and CustomLog entries are suggested for more fine-grained logging, but are not required. If they are defined (as shown above), the logs directories must be created before you restart Apache.

Before you can use the above configuration, you’ll need to create the specified directories. For the above configuration, you can do this with the following commands. Substitute your own domain names for those shown below.

mkdir -p /srv/www/example.com/public_html
mkdir /srv/www/example.com/logs

mkdir -p /srv/www/example.org/public_html
mkdir /srv/www/example.org/logs

After you’ve set up your virtual hosts, issue the following commands:

a2ensite example.com
a2ensite example.org

This command symbolically links your virtual host file from sites-available to the sites-enabled directory. Finally, before you can access your sites you must reload Apache with the following command:

service apache2 reload

Assuming that you have configured the DNS for your domain to point to your Linode’s IP address, Virtual hosting for your domain should now work.

The a2dissite command is the inverse of a2ensite. For example, if you wanted to disable the example.com site, you would issue the following command:

a2dissite example.com

After enabling, disabling, or modifying any part of your Apache configuration, you will need to reload the Apache configuration again with the “service apache2 reload” command. You can create as many virtual hosting files as you need to support the domains that you want to host with your Linode.

Install and Configure the MySQL Database Server

MySQL is a relational database management system (RDBMS) and is a popular component of web development tool-chains. It is used to store data for many popular applications, including WordPress and Drupal.

Install MySQL

The first step is to install the mysql-server package, which is accomplished by the following command:

apt-get install mysql-server

During the installation you will be prompted for a password. Choose something secure (use letters, numbers, and non-alphanumeric characters) and record it for future reference.

At this point MySQL should be ready to configure and run. While you shouldn’t need to change the configuration file, note that it is located at /etc/mysql/my.cnf for future reference.

Configure MySQL and Set Up Databases

After installing MySQL, it’s recommended that you run mysql_secure_installation, a program that helps secure MySQL. While running mysql_secure_installation, you will be presented with the opportunity to change the MySQL root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases. It is recommended that you answer yes to these options. If you are prompted to reload the privilege tables, select yes. Run the following command to execute the program:

mysql_secure_installation

Next, you may create a database and grant your users permissions to use databases. First, log in to MySQL:

mysql -u root -p

Enter MySQL’s root password, and you’ll be presented with a MySQL prompt where you can issue SQL statements to interact with the database.

To create a database and grant your users permissions on it, issue the following command. Note, the semi-colons (;) at the end of the lines are crucial for ending the commands. Your command should look like this:

create database lollipop;
grant all on lollipop.* to 'foreman' identified by '5t1ck';
flush privileges;

In the example above, lollipop is the name of the database, foreman is the username, and 5t1ck is the password. Note that database user names and passwords are only used by scripts connecting to the database, and that database user account names need not (and perhaps should not) represent actual user accounts on the system.

With that completed, you’ve successfully configured MySQL and you may now pass these database credentials on to your users. To exit the MySQL database administration utility issue the following command:

quit

With Apache and MySQL installed you are now ready to move on to installing PHP to provide scripting support for your web pages.

Install and Configure PHP

PHP makes it possible to produce dynamic and interactive pages using your own scripts and popular web development frameworks. Furthermore, many popular web applications like WordPress are written in PHP. If you want to be able to develop your websites using PHP, you must first install it.

Ubuntu includes packages for installing PHP from the terminal. Issue the following command:

apt-get install php5 php-pear

Once PHP5 is installed, you’ll need to tune the configuration file located in /etc/php5/apache2/php.ini to enable more descriptive errors, logging, and better performance. These modifications provide a good starting point if you’re unfamiliar with PHP configuration.

Make sure that the following values are set, and relevant lines are uncommented (comments are lines beginning with a semi-colon (;)):

File excerpt:/etc/php5/apache2/php.ini

max_execution_time = 30
memory_limit = 64M
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
log_errors = On
error_log = /var/log/php.log
register_globals = Off

After making changes to the PHP configuration file, restart Apache by issuing the following command:

service apache2 restart

If you need support for MySQL in PHP, then you must install the php5-mysql package with the following command:

apt-get install php5-mysql

To install the php5-suhosin package, which provides additional security for PHP 5 applications (recommended), issue the following command:

apt-get install php5-suhosin

Restart Apache to make sure everything is loaded correctly:

service apache2 restart

Congratulations! You’ve set up a LAMP server on Ubuntu 11.10 (Oneiric). Happy serving!

SciTE如何与PHP配合?

下载地址:http://scintilla.sourceforge.net/SciTEDownload.html
请假设已构建这样一个环境(也就是我自己的环境),所有与研发相关的内容都放置在E:\Develop目录中。这些内容包括:SciTE、PHP、PHP Manual(那份标记为ex的官方手册)、PHP Code Beautifier(http://www.waterproof.fr/products/phpCodeBeautifier/)。
然 后请添加一个标记为SciTE_HOME的环境变量到SciTE的目录。在SciTE的文档中曾经这样写到,新版本的SciTE开始支持用户自定义的 SciTEUSER.properties设定文件,以免修改SciTEGlobal.properties全局设定文件。而SciTE对于 SciTEUSER.properties、SciTE.recent最近访问文件列表文件和SciTE.ses会话文件的读取循序中 SciTE_HOME都处于最高优先级——否则会访问HOME环境变量目录(GTK+)或者USERPROFILE环境变量目录(Windows)。因此 如果方便地话,将SciTE_HOME设置为SciTE目录,所有的定义文件都存放在程序目录中,方便维护。
从Options选项菜单选择Open User Options File打开用户选项文件,SciTE会打开SciTEUser.properties文件,如果不存在则在保存时会创建新文件。
添加以下代码从而支持对PHP的调试,以后在编辑完PHP文件后执行Tools工具菜单的Go执行命令即可调用PHP运行您所编辑的程序文件。
command.go.$(file.patterns.php)=E:\Develop\PHP\php -f $(FilePath)
默认情况下,调试区域位于编辑区域的右侧,并且是隐藏的,如果您更习惯于调试区域位于下方,并且默认可见,请这样设置:
split.vertical=0
output.initial.hide=0
output.vertical.size=150
默认情况下,SciTE是只处理单字节字符的,也就是使用着UTF-7字符集。如果您文件中的中文无法正常显示和编辑,请这样设置以更好地支持中文。65001为Unicode代码页,934为简体中文代码页。
code.page=65001
LC_CTYPE=en_US.UTF-8
output.code.page=934
在SciTE中,要实现自动完成和代码提示功能都需要您提供API文件。这种文件其实就是符合如下格式的以行为纪录的小型数据仓库。您可以在http://scintilla.sourceforge.net/SciTEExtras.html下载其提供的现有PHP API文件
然后再向用户定义文件中添加以下内容,那么在需要的时候使用Edit编辑菜单的Complete Symbol完成符号命令即可显示自动完成可选项列表,使用Edit编辑菜单的Show Calltip显示调用提示命令显示代码提示。
api.$(file.patterns.php)=$(SciteDefaultHome)\php.api
autocomplete.hypertext.ignorecase=1
calltip.php.ignorecase=1
calltip.php.word.characters=_:$(chars.numeric)$(chars.alpha)
calltip.php.parameters.start=(
calltip.php.parameters.separators=,
calltip.php.parameters.end=)
calltip.hypertext.end.definition=)
配置完SciTE的行为设置后,现在还欠缺的就只剩下了快速帮助和代码格式化尚未完成。先向用户定义文件中添加如下代码:
if PLAT_WIN
command.help.subsystem.$(eriw.filepattern.php)=4
command.help.$(eriw.filepattern.php)=$(CurrentWord)!E:\Develop\PHP Manual\php_manual_en.chm
command.name.0.$(eriw.filepattern.php)=Code &Beautifier
command.is.filter.0.$(eriw.filepattern.php)=1
command.save.before.0.$(eriw.filepattern.php)=1
command.shortcut.0.$(eriw.filepattern.php)=Ctrl+F1
if PLAT_WIN
command.quiet.0.$(eriw.filepattern.php)=1
command.replace.selection.0.$(eriw.filepattern.php)=2
command.0.$(eriw.filepattern.php)=\
E:\ Develop\PHP Code Beautifier\phpCB\
–optimize-eol\
–rewrite-only-documentation-comment\

–space-after-if\
–space-after-switch\
–space-after-while\
–space-before-start-angle-bracket\
–space-after-end-angle-bracket\
–extra-padding-for-case-statement\
–one-true-brace\
–glue-arrow\
–change-shell-comment-to-double-slashes-comment\
–force-large-php-code-tag\
–force-true-false-null-contant-lowercase\
–padding-char-count 4\
–comment-rendering-style PEAR\
$(FilePath)
如此一来,当您执行Help帮助菜单的Help帮助命令时,SciTE会打开PHP手册并尝试查找当前光标所在的词汇。而在Tools工具菜单中Go执行命令之下更多出了一个自定义命令Code Beautifier,其快捷键为Ctrl+F1,其执行的结果是将当前文s件代码格式化一次。