CentOS 6.5使用yum快速搭建LAMP环境

由于这里采用yum方式安装,前提是我们必须配置好yum源。为了加快下载速度,建议使用网易的yum源。参考:CentOS配置网易163yum源 http://www.linuxidc.com/Linux/2014-07/104562.htm

这种方式对于初学者来说,非常方便,但是可定制性不强,而且软件版本较低。一般用于实验和学习环境。

CentOS 6.5安装配置LAMP http://www.linuxidc.com/Linux/2014-07/104373.htm

Ubuntu 13.04 安装 LAMPVsftpdWebminphpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm

RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm

LAMP源码环境搭建WEB服务器Linux+Apache+MySQL+PHP http://www.linuxidc.com/Linux/2013-05/84882.htm

基于Ubuntu 的LAMP 优化加固 http://www.linuxidc.com/Linux/2014-07/104092.htm

1、安装Apache

[root@localhost ~]# yum -y install httpd

# 开机自启动

[root@localhost ~]# chkconfig httpd on

# 启动httpd 服务

[root@localhost ~]# service httpd start

### 安装apache 一些扩展

root@localhost ~]# yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql


现在直接在浏览器键入http://localhost  或 http://本机IP  ,应该会看到Apache的测试页面

这里需要注意iptables的设置哦。

CentOS 6.5使用yum快速搭建LAMP环境

2、安装配置MySQL

# mysql          客户端程序

# mysql-server    服务端程序

# mysql-devel    开发设计的库

[root@localhost ~]# yum -y install mysql mysql-server mysql-devel

# 开机启动

[root@localhost ~]# chkconfig mysqld on

# 启动mysqld服务

[root@localhost ~]# service mysqld start

# 进行一些安全性配置

[root@localhost ~]# /usr/bin/mysql_secure_installation

[root@localhost ~]# netstat -tulpn | grep -i mysql

tcp        0      0 0.0.0.0:3306          0.0.0.0:*          LISTEN      1723/mysqld


OK, 我们看到mysqld已经启动,监听在3306端口上。

3、安装php


安装相关模块:为了让PHP支持MySQL,我们可以安装php-mysql软件包;也可使用以下命令搜索可用的php模块

[root@localhost ~]# yum -y install php php-mysql

# 安装php常用扩展

[root@localhost ~]# yum search php

[root@localhost ~]# yum -y install gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap

 ### 重启httpd服务,这一步很重要

[root@localhost ~]# service httpd restart


然后,我们提供php页面,测试

[root@localhost ~]# cd /var/www/html/

[root@localhost html]# vi index.php

<?php

    phpinfo();

?>


然后,我们再次在浏览器键入http://localhost  或 http://本机IP  ,应该会看到如下页面

CentOS 6.5使用yum快速搭建LAMP环境

4、安装配置phpMyAdmin

    安装好MySQL,Apache及PHP后,为了可视化的管理MySQL数据库,我们可以安装phpMyAdmin。到其官网下载最新版本:http://www.phpmyadmin.net/home_page/

    在Windows下,其实Navicat也是一个非常好用的MySQL可视化工具,推荐使用。

[root@localhost ~]# unzip phpMyAdmin-4.2.6-all-languages.zip

[root@localhost ~]# mv phpMyAdmin-4.2.6-all-languages /var/www/html/phpmyadmin

[root@localhost ~]# cd /var/www/html/phpmyadmin

[root@localhost ~]# cp libraries/config.default.php config.inc.php

[root@localhost ~]# vi cnfig.inc.php

$cfg['PmaAbsoluteUri'] = '';这里填写 phpMyAdmin 的访问网址。

$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address

$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port

$cfg['Servers'][$i]['user'] = 'root'; // 填写 MySQL 访问 phpMyAdmin 使用的 MySQL 用户名,默认为 root。

fg['Servers'][$i]['password'] = ''; // 填写对应上述 MySQL 用户名的密码。

# 然后重启,httpd服务

[root@localhost ~]# service httpd restart


在浏览器键入http://localhost/phpmyadmin 即可访问。

如果遇到访问权限的问题, 请检查SElinux。

1130mysql连接错误解决方法:

mysql -u root -p;

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>FLUSH PRIVILEGES;

mysql>select host, user from user;

完全卸载mysql方法:

yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
rm /etc/my.cnf
查看是否还有mysql软件:
rpm -qa|grep mysql
如果存在的话,继续删除即可。

vsftpd:

centos 安装vsftpd  

2011-08-25 09:21:45|  分类: centos|举报|字号 订阅

 
 

1.查看有没有安装vsftpd:
rpm -qa | grep vsftpd

2.yum安装vsftpd:
yum install vsftpd

3.rpm安装vsftpd:
    可以从下面两个地方获得最新的vsftpd的RPM包https://www.redhat.com/或者http://www.rpmfind.net/

 

 

安装命令:

rpm -Uvh vsftpd-1.1.3-8.i386.rpm

4.设置每次开机时自动运行及手工启动它:
chkconfig vsftpd on
service vsftpd start
netstat -tl 可以查看ftp端口是否在侦听了!

5.为vsftpd添加ftp账号
用useradd建立的用户,如果后面不加参数,建立的用户为普通用户,有系统登陆权限,所以要在useradd命令后面加上参数,为虚拟主机添加不可以登录系统的ftp专用账号,命令如下: 
# useradd –s /sbin/nologin –d /var/www   -g ftp ftpadmin

如果显示如下信息:
Creating mailbox file: File exists
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.

表示用户家目录已经存在(/var/www),不可再新建此目录,并非添加用户失败,接下来给用户设置密码,否则此账号不能使用,命令如下:
# passwd ftpadmin

这样就为linux系统添加用户ftpadmin,用户目录指定为/var/www,属于ftp用户组,且此用户不能登陆系统。

注:
-s /sbin/nologin是让其不能登陆系统
-d 是指定用户目录为/var/www
-g ftp 把用户加入到ftp组中

修改/var/www目录属性:
chmod -R 777 /var/www 递归地给此目录下所有文件和子目录的读、写、执行权限
$ chgrp -R ftp   /var/www 递归地把此目录及该目录下所有文件和子目录的组属性设置成ftp组 

6.配置etc/vsftpd/vsftpd.conf文件:

nano -w /etc/vsftpd/vsftpd.conf
注:用nano编辑配置文件要加参数“-w”,用于取消自动换行,否则有可能会出错。

配置文件范例:

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and 
# listens on IPv4 sockets. This directive cannot be used in conjunction 
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd whith two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES

pam_service_name=vsftpd
chroot_local_user=YES
userlist_enable=YES
tcp_wrappers=YES

注:此配置文件仅在默认配置文件基础上修改为如下两项:

anonymous_enable=NO #禁止匿名登录

chroot_local_user=YES     #把系统内所有的FTP用户都限制在家目录中

7.查看谁登陆了FTP,并杀死它的进程
ps –xf |grep ftp
kill 进程号 

8.使vsftp下root登录:
1)编辑两个FTP配置文件:/etc/vsftpd.ftpusers和/etc/vsftpd.user_list,将root那一行删掉或#注释掉; 

2)重启vsftpd服务:

service vsftpd restart

设置虚拟目录

# cd /var/ftp

# mkdir v1

# mount --bind /sourcedir /var/ftp/v1

# vi /etc/fstab

在最后增加一行:

/sourcedir /var/ftp/v1 none ro,bind 0 0 # /etc/init.d/vsftpd restart

dedecms修改:

1.channelartlist标签在5.7中只有row属性,如果是需要频道页面样式比较独特的网站不能够满足循环调用的需求,所以,给它加上limit属性就好了。

给这个标签加limit属性也非常容易,dedecms的程序优点就在于扩展。

打开include/taglib/channelartlist.lib.php文件,约62行处,在下面加一行

if(empty($totalnum)) $totalnum = 20;


if(!empty($limit)) $totalnum = $limit;

这样,如果有limit属性的话就用limit属性来控制调用的记录数量了。

原文地址:https://www.cnblogs.com/atomgame/p/4218509.html