阿里云CentOS6.5挂载数据盘以及搭建LAMP环境

来源:互联网 发布:pyqt4 linux安装 编辑:程序博客网 时间:2024/05/17 08:11

系统约定 


软件配置:

软件源代码包下载位置

/data/download

软件源代码包存放位置


/usr/local/src

Apache 源码包编译安装位置存放

/usr/local/apache

MySQL源码包编译安装位置

/usr/local/Centling/mysql

PHP 源码包编译安装位置

/usr/local/Centling/php5

脚本以及维护程序存放位置(尚未使用)

/usr/local/Centling/sbin

MySQL 数据库存放位置

/data/mysql

Apache 网站根目录

/data/www

Apache 虚拟主机日志根目录

/data/log

ftp数据目录

/data/ftproot

 

 

 

一、更新yum源/下载安装包

1.查看系统默认安装的yum

[root@iZ281hdlfydZ yum.repos.d]# rpm-qa|grep yum

yum-metadata-parser-1.1.2-16.el6.x86_64

yum-plugin-fastestmirror-1.1.30-17.el6_5.noarch

yum-plugin-security-1.1.30-17.el6_5.noarch

yum-3.2.29-43.el6.centos.noarch

yum-utils-1.1.30-17.el6_5.noarch

2.备份yum源文件

[root@iZ281hdlfydZ yum.repos.d]# mv/etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

[root@iZ281hdlfydZ yum.repos.d]# ls

CentOS-Base.repo.backup  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo  epel.repo

3.获取163的yum源

[root@iZ281hdlfydZ yum.repos.d]# wgetmirrors.163.com/.help/CentOS6-Base-163.repo

--2015-07-03 11:17:10-- http://mirrors.163.com/.help/CentOS6-Base-163.repo

Resolving mirrors.163.com...123.58.173.185, 123.58.173.186

Connecting tomirrors.163.com|123.58.173.185|:80... connected.

HTTP request sent, awaiting response... 200OK

Length: 2006 (2.0K)[application/octet-stream]

Saving to: ?.entOS6-Base-163.repo?

 

100%[==================================================================================>]2,006       --.-K/s   in 0s     

 

2015-07-03 11:17:10 (311 MB/s) -?.entOS6-Base-163.repo?.saved [2006/2006]

[root@iZ281hdlfydZ yum.repos.d]# ls

CentOS6-Base-163.repo  CentOS-Base.repo.backup  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo  epel.repo

4.重命名

[root@iZ281hdlfydZ yum.repos.d]# mvCentOS6-Base-163.repo CentOS-Base.repo

5.建立缓存

[root@iZ281hdlfydZ yum.repos.d]#yummakecache

6.更新yum源

[root@iZ281hdlfydZ yum.repos.d]# yum update

 

 

 

安装包:

apr-1.5.2.tar.gz       

apr-util-1.5.4.tar.gz 

httpd-2.4.12.tar.gz  

mysql-5.6.25.tar.gz

apr-iconv-1.2.1.tar.gz 

cmake-3.2.3.tar.gz    

libiconv-1.14.tar.gz 

php-5.6.10.tar.gz

下载地址:

[root@iZ281hdlfydZ download]# wget http://php.net/get/php-5.6.10.tar.gz

[root@iZ281hdlfydZ download]#

wget http://www.webhostingjams.com/mirror/apache//httpd/httpd-2.4.12.tar.gz

[root@iZ281hdlfydZ download]# wget http://www.cmake.org/files/v3.2/cmake-3.2.3.tar.gz

[root@iZ281hdlfydZ download]#

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.25.tar.gz

[root@iZ281hdlfydZ download]# wget http://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gz

[root@iZ281hdlfydZ download]# wget http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz

[root@iZ281hdlfydZ download]# wget http://mirrors.cnnic.cn/apache//apr/apr-iconv-1.2.1.tar.gz

[root@iZ281hdlfydZ download]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

 

 

二、挂在数据盘

1.查看分区

Linux的云服务器数据盘未做分区和格式化,可以根据以下步骤进行分区以及格式化操作。下面的操作将会把数据盘划分为一个分区来使用。


1、查看数据盘

在没有分区和格式化数据盘之前,使用 “df –h”命令,是无法看到数据盘的,可以使用“fdisk -l”命令查看。

友情提示:若您执行fdisk -l命令,发现没有 /dev/xvdb 表明您的云服务无数据盘,那么您无需进行挂载,此时该教程对您不适用



2、 对数据盘进行分区

执行“fdisk/dev/xvdb”命令,对数据盘进行分区;

根据提示,依次输入“n”,“p”“1”,两次回车,“wq”,分区就开始了,很快就会完成。


3、 查看新的分区

使用“fdisk-l”命令可以看到,新的分区xvdb1已经建立完成了。

 

4.格式化新分区

这个时候分区还没有挂载,CentOS6.5默认支持ext4的文件系统,如果不支持可以通过如下命令加载(

使用如下命令,可以完成模块加载过程。

cd/lib/modules/2.6.18-274.12.1.el5/kernel/fs/ext4

modprobe ext4

yum installe4fsprogs

 

 

使用ext4创建文件系统

[root@iZ281hdlfydZ~]# mkfs.ext4 /dev/xvdb1

 

 

5、添加分区信息

将新分区挂载到/data目录,可使用如下命令。注:如果/data目录不存在,需先运行命令”mkdir /data”创建该目录。

“echo'/dev/xvdb1 /data ext4 defaults 0 0' >> /etc/fstab”命令写入新分区信息。

然后使用“cat/etc/fstab”命令查看,出现以下信息就表示写入成功

 

 

6、挂载新分区

使用“mount-a”命令挂载新分区,然后用“df -h”命令查看,出现以下信息就说明挂载成功,可以开始使用新的分区了。


 

三、安装MySQL

 

1.确认未安装mysql和php

2.安装mysql依赖包

 [root@iZ281hdlfydZ mysql-5.6.25]# yum -yinstall ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devellibtiff-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-develfontconfig-devel zlib zlib-devel libevent-devel gcc gcc-c   flex bison bzip2-devel libXpm libXpm-develncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imakeautoconf automake screen sysstat compat-libstdc curl curl-devel

 

3.安装cmake

[root@iZ281hdlfydZ src]#tar zxvf cmake-3.2.3.tar.gz

[root@iZ281hdlfydZ src]# cd cmake-3.2.3

[root@iZ281hdlfydZ cmake-3.2.3]#./configure

[root@iZ281hdlfydZ cmake-3.2.3]# gmake&&gmake install

4. 增加MySQL组和 MySQL用户属于该组

[root@iZ281hdlfydZ cmake-3.2.3]# groupaddmysql

groupadd: group 'mysql' already exists

[root@iZ281hdlfydZ cmake-3.2.3]# useradd -gmysql -s /sbin/nologin mysql

useradd: user 'mysql' already exists

#新建一个数据目录

[root@iZ281hdlfydZcmake-3.2.3]# mkdir -p /data/mysql

#赋予权限

[root@iZ281hdlfydZ cmake-3.2.3]# chown -Rmysql:mysql /data/mysql

#解压

[root@iZ281hdlfydZ src]# tar zxvfmysql-5.6.25.tar.gz

#

[root@iZ281hdlfydZ src]# cd mysql-5.6.25

[root@iZ281hdlfydZ mysql-5.6.25]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/Centling/mysql-DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/usr/local/Centling/etc/  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 

#编译安装

[root@iZ281hdlfydZ mysql-5.6.25]# make&& make install

#初始化数据库

[root@iZ281hdlfydZ mysql]# ./scripts/mysql_install_db--user=mysql

#复制启动脚本到/etc/init.d

[root@iZ281hdlfydZ mysql]# cp./support-files/mysql.server /etc/rc.d/init.d/mysqld

#开机启动

[root@iZ281hdlfydZ mysql]# chkconfig mysqldon

#打开文件/etc/rc.d/init.d/mysqld

basedir=

datadir=

替换为

basedir=/usr/local/Centling/mysql

datadir=/data/mysql

#编辑配置文件

[root@iZ281hdlfydZ Centling]# mkdir -p/usr/local/Centling/etc

[root@iZ281hdlfydZ mysql]# cp./support-files/my-default.cnf /usr/local/Centling/etc/my.cnf

编辑配置文件 /usr/local/Centling/etc/my.cnf,在 [mysqld] 段增加 
datadir = /data/mysql 
wait-timeout = 10 
max_connections = 512 
max_connect_errors = 10000000 
local-infile=0 

 

[root@iZ281hdlfydZ support-files]# mv/usr/local/Centling/mysql/data/* /data/mysql

[root@iZ281hdlfydZ support-files]# servicemysqld start

Starting MySQL.. SUCCESS!

 

#设置环境变量

[root@iZ281hdlfydZ Centling]#vi/etc/profile

 

#在末尾添加以下内容

[root@iZ281hdlfydZ Centling]#PATH=/usr/local/Centling/mysql/bin:$PATH

[root@iZ281hdlfydZ Centling]#export PATH

 

#让刚才的修改生效

[root@iZ281hdlfydZ Centling]#source/etc/profile

 

#初始化mysql的设置 root密码是123

[root@iZ281hdlfydZ Centling]#mysql_secure_installation

 

 

 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT ISRECOMMENDED FOR ALL MySQL

     SERVERS IN PRODUCTION USE!  PLEASEREAD EACH STEP CAREFULLY!

 

In order to log into MySQL to secure it,we'll need the current

password for the root user.  If you've just installed MySQL, and

you haven't set the root password yet, thepassword will be blank,

so you should just press enter here.

 

Enter current password for root (enter fornone):

OK, successfully used password, movingon...

 

Setting the root password ensures thatnobody can log into the MySQL

root user without the proper authorisation.

 

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ...Success!

 

 

By default, a MySQL installation has ananonymous user, allowing anyone

to log into MySQL without having to have auser account created for

them. This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] y

 ...Success!

 

Normally, root should only be allowed toconnect from 'localhost'.  This

ensures that someone cannot guess at theroot password from the network.

 

Disallow root login remotely? [Y/n] y

 ...Success!

 

By default, MySQL comes with a databasenamed 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a productionenvironment.

 

Remove test database and access to it?[Y/n] y

 -Dropping test database...

 ...Success!

 -Removing privileges on test database...

 ...Success!

 

Reloading the privilege tables will ensurethat all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y

 ...Success!

 

 

 

 

All done! If you've completed all of the above steps, your MySQL

installation should now be secure.

 

Thanks for using MySQL!

 

 

Cleaning up...

 

#修改mysql安装目录

[root@iZ281hdlfydZ mysql]# cd/usr/local/Centling/mysql

[root@iZ281hdlfydZ mysql]# chown -Rmysql:mysql .

[root@iZ281hdlfydZ mysql]# chgrp -R mysql .

#修改mysql数据库文件目录       

[root@iZ281hdlfydZmysql]# cd /data/mysql

[root@iZ281hdlfydZmysql]# chown -R mysql:mysql .

#初始化数据库

./scripts/mysql_install_db --user=mysql--basedir=/usr/local/Centling/mysql --datadir=/data/mysql --defaults-file=/usr/local/Centling/etc/my.cnf

[root@iZ281hdlfydZmysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/Centling/mysql--datadir=/data/mysql --defaults-file=/usr/local/Centling/etc/my.cnf

Installing MySQLsystem tables...2015-07-04 09:50:32 0 [Warning] TIMESTAMP with implicit DEFAULTvalue is deprecated. Please use --explicit_defaults_for_timestamp server option(see documentation for more details).

2015-07-0409:50:32 0 [Note] /usr/local/Centling/mysql/bin/mysqld (mysqld 5.6.25) startingas process 22376 ...

2015-07-0409:50:32 22376 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-07-0409:50:32 22376 [Note] InnoDB: The InnoDB memory heap is disabled

2015-07-0409:50:32 22376 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-07-0409:50:32 22376 [Note] InnoDB: Memory barrier is not used

2015-07-0409:50:32 22376 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-07-0409:50:32 22376 [Note] InnoDB: Using CPU crc32 instructions

2015-07-0409:50:32 22376 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-07-0409:50:32 22376 [Note] InnoDB: Completed initialization of buffer pool

2015-07-0409:50:32 22376 [Note] InnoDB: Highest supported file format is Barracuda.

2015-07-0409:50:32 22376 [Note] InnoDB: 128 rollback segment(s) are active.

2015-07-0409:50:32 22376 [Note] InnoDB: Waiting for purge to start

2015-07-0409:50:32 22376 [Note] InnoDB: 5.6.25 started; log sequence number 1626047

2015-07-0409:50:32 22376 [Note] Binlog end

2015-07-0409:50:32 22376 [Note] InnoDB: FTS optimize thread exiting.

2015-07-0409:50:32 22376 [Note] InnoDB: Starting shutdown...

2015-07-0409:50:33 22376 [Note] InnoDB: Shutdown completed; log sequence number 1626057

OK

 

Filling helptables...2015-07-04 09:50:33 0 [Warning] TIMESTAMP with implicit DEFAULT valueis deprecated. Please use --explicit_defaults_for_timestamp server option (seedocumentation for more details).

2015-07-0409:50:33 0 [Note] /usr/local/Centling/mysql/bin/mysqld (mysqld 5.6.25) startingas process 22400 ...

2015-07-0409:50:33 22400 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-07-0409:50:33 22400 [Note] InnoDB: The InnoDB memory heap is disabled

2015-07-0409:50:33 22400 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-07-0409:50:33 22400 [Note] InnoDB: Memory barrier is not used

2015-07-0409:50:33 22400 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-07-0409:50:33 22400 [Note] InnoDB: Using CPU crc32 instructions

2015-07-0409:50:33 22400 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-07-0409:50:33 22400 [Note] InnoDB: Completed initialization of buffer pool

2015-07-0409:50:33 22400 [Note] InnoDB: Highest supported file format is Barracuda.

2015-07-0409:50:33 22400 [Note] InnoDB: 128 rollback segment(s) are active.

2015-07-0409:50:33 22400 [Note] InnoDB: Waiting for purge to start

2015-07-0409:50:33 22400 [Note] InnoDB: 5.6.25 started; log sequence number 1626057

2015-07-0409:50:33 22400 [Note] Binlog end

2015-07-0409:50:33 22400 [Note] InnoDB: FTS optimize thread exiting.

2015-07-0409:50:33 22400 [Note] InnoDB: Starting shutdown...

2015-07-0409:50:35 22400 [Note] InnoDB: Shutdown completed; log sequence number 1626067

OK

 

To start mysqldat boot time you have to copy

support-files/mysql.serverto the right place for your system

 

PLEASE REMEMBERTO SET A PASSWORD FOR THE MySQL root USER !

To do so, startthe server, then issue the following commands:

 

  /usr/local/Centling/mysql/bin/mysqladmin -uroot password 'new-password'

  /usr/local/Centling/mysql/bin/mysqladmin -uroot -h iZ281hdlfydZ password 'new-password'

 

Alternatively youcan run:

 

 /usr/local/Centling/mysql/bin/mysql_secure_installation

 

which will alsogive you the option of removing the test

databases andanonymous user created by default.  Thisis

stronglyrecommended for production servers.

 

See the manualfor more instructions.

 

You can start theMySQL daemon with:

 

  cd . ;/usr/local/Centling/mysql/bin/mysqld_safe &

 

You can test theMySQL daemon with mysql-test-run.pl

 

  cd mysql-test ; perl mysql-test-run.pl

 

Please report anyproblems at http://bugs.mysql.com/

 

The latestinformation about MySQL is available on the web at

 

  http://www.mysql.com

 

Support MySQL bybuying support/licenses at http://shop.mysql.com

 

WARNING: Foundexisting config file /usr/local/Centling/mysql/my.cnf on the system.

Because this filemight be in use, it was not replaced,

but was used inbootstrap (unless you used --defaults-file)

and when youlater start the server.

The new defaultconfig file was created as /usr/local/Centling/mysql/my-new.cnf,

please compare itwith your file and take the changes you need.

#备份原来的my.cnf

[root@iZ281hdlfydZmysql]# mv my.cnf my.cnf.old

[root@iZ281hdlfydZmysql]# ls

bin      data include         lib  my.cnf.old mysql-test  scripts  sql-bench

COPYING  docs INSTALL-BINARY  man  my-new.cnf README      share    support-files

[root@iZ281hdlfydZmysql]# ./scripts/mysql_install_db --user=mysql--basedir=/usr/local/Centling/mysql --datadir=/data/mysql--defaults-file=/usr/local/Centling/etc/my.cnf

Installing MySQLsystem tables...2015-07-04 09:54:59 0 [Warning] TIMESTAMP with implicit DEFAULTvalue is deprecated. Please use --explicit_defaults_for_timestamp server option(see documentation for more details).

2015-07-0409:54:59 0 [Note] /usr/local/Centling/mysql/bin/mysqld (mysqld 5.6.25) startingas process 22431 ...

2015-07-0409:54:59 22431 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-07-0409:54:59 22431 [Note] InnoDB: The InnoDB memory heap is disabled

2015-07-0409:54:59 22431 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-07-0409:54:59 22431 [Note] InnoDB: Memory barrier is not used

2015-07-0409:54:59 22431 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-07-0409:54:59 22431 [Note] InnoDB: Using CPU crc32 instructions

2015-07-0409:54:59 22431 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-07-0409:54:59 22431 [Note] InnoDB: Completed initialization of buffer pool

2015-07-0409:54:59 22431 [Note] InnoDB: Highest supported file format is Barracuda.

2015-07-0409:54:59 22431 [Note] InnoDB: 128 rollback segment(s) are active.

2015-07-0409:54:59 22431 [Note] InnoDB: Waiting for purge to start

2015-07-0409:54:59 22431 [Note] InnoDB: 5.6.25 started; log sequence number 1626067

2015-07-0409:54:59 22431 [Note] Binlog end

2015-07-0409:54:59 22431 [Note] InnoDB: FTS optimize thread exiting.

2015-07-0409:54:59 22431 [Note] InnoDB: Starting shutdown...

2015-07-0409:55:00 22431 [Note] InnoDB: Shutdown completed; log sequence number 1626077

OK

 

Filling helptables...2015-07-04 09:55:00 0 [Warning] TIMESTAMP with implicit DEFAULT valueis deprecated. Please use --explicit_defaults_for_timestamp server option (seedocumentation for more details).

2015-07-0409:55:00 0 [Note] /usr/local/Centling/mysql/bin/mysqld (mysqld 5.6.25) startingas process 22454 ...

2015-07-0409:55:00 22454 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-07-0409:55:00 22454 [Note] InnoDB: The InnoDB memory heap is disabled

2015-07-0409:55:00 22454 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-07-04 09:55:0022454 [Note] InnoDB: Memory barrier is not used

2015-07-0409:55:00 22454 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-07-0409:55:00 22454 [Note] InnoDB: Using CPU crc32 instructions

2015-07-0409:55:00 22454 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-07-0409:55:00 22454 [Note] InnoDB: Completed initialization of buffer pool

2015-07-0409:55:00 22454 [Note] InnoDB: Highest supported file format is Barracuda.

2015-07-0409:55:00 22454 [Note] InnoDB: 128 rollback segment(s) are active.

2015-07-0409:55:00 22454 [Note] InnoDB: Waiting for purge to start

2015-07-0409:55:00 22454 [Note] InnoDB: 5.6.25 started; log sequence number 1626077

2015-07-0409:55:00 22454 [Note] Binlog end

2015-07-0409:55:00 22454 [Note] InnoDB: FTS optimize thread exiting.

2015-07-0409:55:00 22454 [Note] InnoDB: Starting shutdown...

2015-07-0409:55:02 22454 [Note] InnoDB: Shutdown completed; log sequence number 1626087

OK

 

To start mysqldat boot time you have to copy

support-files/mysql.serverto the right place for your system

 

PLEASE REMEMBERTO SET A PASSWORD FOR THE MySQL root USER !

To do so, startthe server, then issue the following commands:

 

  /usr/local/Centling/mysql/bin/mysqladmin -uroot password 'new-password'

  /usr/local/Centling/mysql/bin/mysqladmin -uroot -h iZ281hdlfydZ password 'new-password'

 

Alternatively youcan run:

 

 /usr/local/Centling/mysql/bin/mysql_secure_installation

 

which will alsogive you the option of removing the test

databases andanonymous user created by default.  Thisis

stronglyrecommended for production servers.

 

See the manualfor more instructions.

 

You can start theMySQL daemon with:

 

  cd . ;/usr/local/Centling/mysql/bin/mysqld_safe &

 

You can test theMySQL daemon with mysql-test-run.pl

 

  cd mysql-test ; perl mysql-test-run.pl

 

Please report anyproblems at http://bugs.mysql.com/

 

The latestinformation about MySQL is available on the web at

 

  http://www.mysql.com

 

Support MySQL bybuying support/licenses at http://shop.mysql.com

 

New defaultconfig file was created as /usr/local/Centling/mysql/my.cnf and

will be used bydefault by the server when you start it.

You may edit thisfile to change server settings

 

#复制启动脚本到/etc/init.d

[root@iZ281hdlfydZmysql]#cp support-files/mysql.server /etc/init.d/mysqld

 

[root@iZ281hdlfydZmysql]# chmod 755 /etc/rc.d/init.d/mysqld

[root@iZ281hdlfydZmysql]# chkconfig --add mysqld

[root@iZ281hdlfydZmysql]# chkconfig mysqld on

[root@iZ281hdlfydZmysql]#echo "export PATH=$PATH:/usr/local/Cemtling/mysql/bin">>/etc/profile 
[root@iZ281hdlfydZ mysql]#source /etc/profile

[root@iZ281hdlfydZmysql]# service mysqld start

Starting MySQLSUCCESS!

[root@iZ281hdlfydZmysql]# netstat -anpt |grep mysqld

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

#我们发现它默认监听在TCP 的" 3306 "端口    

[root@iZ281hdlfydZmysql]# mysql -uroot -h localhost -p

Enter password:

Welcome to theMySQL monitor.  Commands end with ; or\g.

Your MySQLconnection id is 1

Server version:5.6.25 Source distribution

 

Copyright (c)2000, 2015, Oracle and/or its affiliates. All rights reserved.

 

Oracle is aregistered trademark of Oracle Corporation and/or its

affiliates. Othernames may be trademarks of their respective

owners.

 

Type 'help;' or'\h' for help. Type '\c' to clear the current input statement.

 

mysql> exit

Bye

 

#设置mysql password

[root@iZ281hdlfydZmysql]# cp -r data/* /data/mysql

[root@iZ281hdlfydZmysql]# service mysqld stop

Shutting downMySQL. SUCCESS!

[root@iZ281hdlfydZmysql]# mysqld_safe --skip-grant-tables & mysql -uroot -p

[1] 23057

Enter password:150704 10:42:13 mysqld_safe Logging to '/data/mysql/iZ281hdlfydZ.err'.

150704 10:42:13mysqld_safe Starting mysqld daemon with databases from /data/mysql

 

Welcome to theMySQL monitor.  Commands end with ; or\g.

Your MySQLconnection id is 1

Server version:5.6.25 Source distribution

 

Copyright (c)2000, 2015, Oracle and/or its affiliates. All rights reserved.

 

Oracle is aregistered trademark of Oracle Corporation and/or its

affiliates. Othernames may be trademarks of their respective

owners.

 

Type 'help;' or'\h' for help. Type '\c' to clear the current input statement.

 

mysql> usemysql;

Reading tableinformation for completion of table and column names

You can turn offthis feature to get a quicker startup with -A

 

Database changed

mysql> updateuser set password=PASSWORD('123')where user='root'

    -> ;

Query OK, 0 rowsaffected (0.00 sec)

Rows matched:3  Changed: 0  Warnings: 0

 

mysql> flushprivileges;

Query OK, 0 rowsaffected (0.00 sec)

 

mysql> quit

Bye

[root@iZ281hdlfydZmysql]# service mysqld restart

Shutting downMySQL..150704 10:44:49 mysqld_safe mysqld from pid file/data/mysql/iZ281hdlfydZ.pid ended

 SUCCESS!

Starting MySQL.SUCCESS!

[1]+  Done                    mysqld_safe --skip-grant-tables

[root@iZ281hdlfydZmysql]# mysql -uroot -p123

Warning: Using apassword on the command line interface can be insecure.

Welcome to theMySQL monitor.  Commands end with ; or\g.

Your MySQLconnection id is 1

Server version: 5.6.25Source distribution

 

Copyright (c)2000, 2015, Oracle and/or its affiliates. All rights reserved.

 

Oracle is aregistered trademark of Oracle Corporation and/or its

affiliates. Othernames may be trademarks of their respective

owners.

 

Type 'help;' or'\h' for help. Type '\c' to clear the current input statement.

 

mysql> exit

Bye

四、安装apache

[root@iZ281hdlfydZ src]#cd /usr/local/src

[root@iZ281hdlfydZ src]#tar zxvf httpd-2.4.12.tar.gz

[root@iZ281hdlfydZ src]# cd httpd-2.4.12

[root@iZ281hdlfydZ httpd-2.4.12]# ls

ABOUT_APACHE     ap.d          CHANGES         docs         INSTALL         Makefile.in    os                server

acinclude.m4     build         CMakeLists.txt  emacs-style InstallBin.dsp  Makefile.win   README           srclib

Apache-apr2.dsw  BuildAll.dsp config.layout   httpd.dsp    LAYOUT         modules        README.cmake      support

Apache.dsw       BuildBin.dsp  configure       httpd.spec   libhttpd.dsp    NOTICE         README.platforms  test

apache_probes.d  buildconf    configure.in    include      LICENSE         NWGNUmakefile  ROADMAP           VERSIONING

 

#安装 apr

[root@iZ281hdlfydZ src]#tar zxvf apr-1.5.2.tar.gz

[root@iZ281hdlfydZ src]# cd apr-1.5.2

[root@iZ281hdlfydZ apr-1.5.2]# ./configure--prefix=/usr/local/apr

[root@iZ281hdlfydZ apr-1.5.2]# make&& make install

#安装apr-util

[root@iZ281hdlfydZ src]# tar zxvfapr-util-1.5.4.tar.gz

[root@iZ281hdlfydZ src]# cd apr-util-1.5.4

[root@iZ281hdlfydZapr-util-1.5.4]#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

[root@iZ281hdlfydZ apr-util-1.5.4]# make&& make install

#安装httpd

[root@iZ281hdlfydZ src]# cd httpd-2.4.12

[root@iZ281hdlfydZ src]#./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd--enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util --enable-modules=most

[root@iZ281hdlfydZ httpd-2.4.12]# echo $?

0

[root@iZ281hdlfydZ httpd-2.4.12]# make&& make install

[root@iZ281hdlfydZ httpd-2.4.12]# echo $?

0

Apache编译安装成功后安装路径为:/usr/local/apache 

配置文件路径为:/etc/httpd/httpd.conf  

然后为Apache添加服务脚本,并添加到环境变量

[root@iZ281hdlfydZ httpd-2.4.12]# cp/usr/local/apache/bin/apachectl /etc/init.d/httpd

[root@iZ281hdlfydZ httpd-2.4.12]# echo'export PATH=$PATH:/usr/local/apache/bin' > /etc/profile.d/httpd.sh

[root@iZ281hdlfydZ httpd-2.4.12]# chmod +x/etc/profile.d/httpd.sh

[root@iZ281hdlfydZ httpd-2.4.12]# source/etc/profile.d/httpd.sh

[root@iZ281hdlfydZ httpd-2.4.12]#

#编辑配置文件/etc/httpd/httpd.conf添加 ServerNamelocalhost

[root@iZ281hdlfydZ httpd-2.4.12]# servicehttpd start

[root@iZ281hdlfydZ httpd-2.4.12]# netstat-anpt |grep "80"

 

#浏览器访问测试

#开机启动

[root@iZ281hdlfydZ httpd-2.4.12]# chkconfig--add httpd

service httpd does not support chkconfig

[root@iZ281hdlfydZ httpd-2.4.12]# chkconfighttpd on

service httpd does not support chkconfig

如果想把apache服务加入到开机自启,可以修改服务启动脚本:

# vim /etc/init.d/httpd

在第二行下添加:

# chkconfig:235 85 15

# description: This is apache server

其中235代表在第2,3,5运行级别下会开机启动

85和15代表开机和关机的启动顺序,数值越大代表启动的优先级越低

后启动的一般要先关闭,参数可以随你的喜好调整

description后的内容可以随意写

加入开机自启:

[root@iZ281hdlfydZ httpd-2.4.12]# chkconfig --add httpd

[root@iZ281hdlfydZhttpd-2.4.12]# chkconfig httpd on

[root@iZ281hdlfydZhttpd-2.4.12]# echo $?

0

五、安装PHP

#安装依赖库libiconv libmcryptmhash

[root@iZ281hdlfydZ php-5.6.10]# yum installlibmcrypt libmcrypt-devel mcrypt mhash

#安装php

[root@iZ281hdlfydZ src]# tar zxvfphp-5.6.10.tar.gz

[root@iZ281hdlfydZ src]# cd php-5.6.10

#安装iconv

[root@iZ281hdlfydZ src]# tar zxvflibiconv-1.14.tar.gz

[root@iZ281hdlfydZ src]# cd libiconv-1.14

[root@iZ281hdlfydZ libiconv-1.14]#./configure --prefix=/usr/local

[root@iZ281hdlfydZ libiconv-1.14]# echo $?

0

[root@iZ281hdlfydZ libiconv-1.14]# make&& make install

[root@iZ281hdlfydZ libiconv-1.14]# echo $?

0

 [root@iZ281hdlfydZphp-5.6.10]#./configure --prefix=/usr/local/Centling/php5--with-config-file-path=/usr/local/Centling/etc --enable-mbstring --enable-ftp--with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-magic-quotes--with-mysql=/usr/local/Centling/mysql --with-pear --enable-sockets --with-ttf--with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --enable-sysvsem--enable-exif --enable-sysvshm --with-libxml-dir=/usr --with-apxs2=/usr/local/apache/bin/apxs--with-iconv=/usr/local/libiconv --with-iconv-dir=/usr/local --with-xmlrpc--enable-xml --enable-shmop --enable-zip --with-mhash --with-mcrypt--enable-discard-path --enable-bcmath --enable-inline-optimization --with-curl--with-curlwrappers --enable-mbregex --with-openssl  --disable-fileinfo

[root@iZ281hdlfydZ php-5.6.10]# make && make install

[root@iZ281hdlfydZ php-5.6.10]# cp php.ini-production/usr/local/Centling/etc/php.ini

[root@iZ281hdlfydZ php-5.6.10]# echo'ulimit -SHn 65535' >> /etc/rc.local

[root@iZ281hdlfydZ php-5.6.10]# servicehttpd start

httpd (pid 21581) already running

#编辑/etc/profile,末尾添加以下内容

PATH=/usr/local/Centling/php5/bin:$PATH

export PATH

[root@iZ281hdlfydZ php-5.6.10]# vim/etc/profile

[root@iZ281hdlfydZ php-5.6.10]# source/etc/profile

#找到这行

AddType application/x-gzip .gz .tgz 

#添加这一句

AddType application/x-httpd-php .php

#找到以下这句,在后面添加index.php

DirectoryIndex index.html

DirectoryIndex index.html index.php

#测试

/usr/local/apache/htdocs/phpinfo.php

<?php

 

// ?示???息拢卢默??示 INFO_ALL

phpinfo();

 

// Show just the module information. 陆枚?戮PHP模驴茅息拢卢

// phpinfo(8) 路碌禄?卢?碌慕谩隆拢

phpinfo(INFO_MODULES);

 

?>

 

六、更改apache根目录为/data/www

现在apache的默认目录是/usr/local/apache/htdocs

[root@iZ281hdlfydZ data]#mkdir www

[root@iZ281hdlfydZ data]# chmod -R 755/data/www

Vi /etc/httpd/httpd.conf

找到DocumentRoot “/usr/local/apache/htdocs” 这一段 #apache的根目录

把/usr/local/apache/htdocs这个目录改为/data/www

再找到#定义apache /usr/local/apache/htdocs这个区域

把 /usr/local/apache/htdocs改成/data/www

[root@iZ281hdlfydZhtdocs]# vim /etc/httpd/httpd.conf

[root@iZ281hdlfydZhtdocs]# service httpd restart

 

 

七、搭建FTP服务器

[root@iZ281hdlfydZ www]# rpm -qa |grepvsftpd

[root@iZ281hdlfydZ www]# yum -y installvsftpd

#启动服务并设为开机启动

[root@iZ281hdlfydZ www]# chkconfig vsftpdon

 

启动vsftpd:  service vsftpd start

停止vsftpd:  service vsftpd stop

重启vsftpd:  service vsftpd restart

 

[root@iZ281hdlfydZ www]# service vsftpdstart

Starting vsftpd for vsftpd:                                [  OK  ]

 

#备份配置文件

[root@iZ281hdlfydZ www]#  cp /etc/vsftpd/vsftpd.conf/etc/vsftpd/vsftpd.conf.bak

#配置防火墙

[root@iZ281hdlfydZ ~]# service iptablesstatus

iptables: Firewall is not running.

[root@iZ281hdlfydZ ~]# iptables -P OUTPUTACCEPT

[root@iZ281hdlfydZ ~]# service iptablessave

iptables: Saving firewall rules to/etc/sysconfig/iptables:[  OK  ]

[root@iZ281hdlfydZ ~]# service iptablesstatus

 

#修改/etc/vsftpd/vsftpd.conf配置新用户

#禁止匿名用户登陆

anonymous_enable=NO

#把传输记录的日志保存到/var/log/vsftpd.log

 # 创建vsftp的日志文件

[root@iZ281hdlfydZ ~]# touch /var/log/vsftpd.log

xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=NO

# 允许ASCII模式上传
ascii_upload_enable=YES 
# 允许ASCII模式下载
ascii_download_enable=YES

# 欢迎标语
ftpd_banner=Welcome to use Centling ftp server.

#递归地给此目录下所有文件和子目录的读、写、执行权限

[root@iZ281hdlfydZ ~]# chmod -R 777/data/ftproot

#递归地把此目录及该目录下所有文件和子目录的组属性设置成ftp组

[root@iZ281hdlfydZ ~]# chgrp -R ftp/data/ftproot

#创建用户ftpuser指向目录/data/ftproot,禁止登录SSH权限

[root@iZ281hdlfydZ ~]# useradd -d/data/ftproot -g ftp -s /sbin/nologin ftpuser

useradd: warning: the home directory alreadyexists.

Not copying any file from skeldirectory into it.

#添加密码123

[root@iZ281hdlfydZ ~]# passwd ftpuser

Changing password for user ftpuser.

New password:

BAD PASSWORD: it is WAY too short

BAD PASSWORD: is too simple

Retype new password:

passwd: all authentication tokens updatedsuccessfully.

 

#重启FTP

[root@iZ281hdlfydZ www]# service vsftpd restart

 

八、安装phpMyAdmin


1、官网http://www.phpmyadmin.net/  下载phpMyAdmin-4.4.10-all-languages.tar.gz


2、再解压到 web 可以访问的目录下,如果是虚拟空间,可以解压后通过 ftp 工具上传到 web 目录下,同时您可以修改解压后该文件的名称(你可以自定义目录名称)。
/data/www/phpMyAdmin
二、配置
3、打开 /libraries/config.default.php文件(旧版本是根目录下的config.inc.php文件),用写字板(不要用记事本,这是UTF8编码)进行编辑,按照说明配置即可。 
4、查找 $cfg['PmaAbsoluteUri']=‘';   // 修改为你将上传到空间的phpMyAdmin的网址 
如:$cfg['PmaAbsoluteUri'] =‘http:   // 网站域名/phpmyadmin/';  


5、查找 $cfg['Servers'][$i]['host'] =‘localhost';    // 通常用默认,也有例外,可以不用修改 
6、查找 $cfg['Servers'][$i]['auth_type'] =‘config';   // 在自己的机子里调试用config;如果在网络上的空间用cookie.
在此有四种模式可供选择:cookie,http,HTTP,config
① config 方式即输入phpMyAdmin 的访问网址即可直接进入,无需输入用户名和密码,是不安全的,不推荐使用。 
② 设置cookie,http,HTTP方式,登录phpMyAdmin 需要数据用户名和密码进行验证。
具体如下:PHP 安装模式为 Apache,可以使用 http 和 cookie;PHP 安装模式为 CGI,可以使用 cookie。 
7、查找 $cfg['Servers'][$i]['user'] = ‘root';   // MySQL用户名 
8、查找 $cfg['Servers'][$i]['password'] ='';   // MySQL 密码 (onlyneeded 留空就可以了)
9、查找 $cfg['Servers'][$i]['only_db'] = '';   // 你只有一个数据就设置一下,设置为你的数据库名;如果你想架设服务器,那么建议留空 
10、查找 $cfg['DefaultLang'] = ‘zh';   // 这里是选择语言,zh代表简体中文的意思 
11、查找$cfg['blowfish_secret'] ='';   // 如果认证方法设置为cookie,就需要设置短语密码,设置为什么密码,由您自己决定,这里不能留空,否则会在登录 phpMyAdmin 时提示如下图所示的错误。

 

 

 

 

0 0