Centos下安装Lamp和vsftpd、redis

[root@localhost ~]#servcie iptables stop --临时关闭防火墙

[root@localhost ~]#chkconfig iptables off --永久关闭防火墙

yum安装httpd和php、mysql服务

 

1: yum search httpd            //搜索httpd开头的软件包
2: yum install httpd.x86_64   //找到apache 对应的软件包名 Apache HTTP Server,安装
3: yum -y install mysql-server mysql php php-mysql php-xml php-gd php-mbstring  //安装 mysql  php 及其扩展
4: service mysqld restart  //启动mysql    mysql -uroot -p  空   show databases; 查看数据表
5: iptables -F   //清空防火墙
6: service iptables save  //保存防火墙规则
7: service iptables stop  //关闭防火墙
8: apachectl restart  //这时候会报错 
9: vi /etc/httpd/conf/httpd.conf    //配置httpd
10::set nu  //显示行号   
11: :/ServerName  //查找ServerName
12: :1  回到最顶行
13: 去掉 ServerName www.example.com:80   前面的#     保存 
14: serveice httpd restart 重启 apache 
15: 访问ip 查看apache启动情况
16: cd /var/www/html   //进入php默认目录
17: vi index.php    //创建PHP文件  保存 刷新查看信息
18:service mysqld start    启动mysql

使用yum 安装apache(httpd) php mysql

 

编译lamp安装方法

一:工具gcc安装

 

yum install gcc gcc-c++ kernel-devel

二:安装zlib

 

tar –zxvf zlib-1.2.5.tar.gz

cd zlib-1.2.5

./configure 

make && make install

三:安装apache

 

tar -jxvf httpd-2.2.19.tar.bz2

cd httpd-2.2.19

./configure --prefix=/usr/local/http2  \

--enable-modules=all \

--enable-mods-shared=all \

--enable-so

make && make install

编辑httpd.conf,把Servername ......80注释去掉

/usr/local/http2/bin/apachectl start  启动apache

四:准备安装PHP,需要安装PHP的一些依赖程序

 

A:安装libxml2

 

tar zxvf libxml2-2.7.2.tar.gz 

cd libxml2-2.7.2

./configure --prefix=/usr/local/libxml2    ///若是编译有问题,可以在configure 加上 --without-zlib 可以编译通过

make && make install

make 完正常情况显示

 

Making install in xstc

make[1]: Entering directory `/usr/local/src/libxml2-2.7.2/xstc'

make[2]: Entering directory `/usr/local/src/libxml2-2.7.2/xstc'

make[2]: Nothing to be done for `install-exec-am'.

make[2]: Nothing to be done for `install-data-am'.

make[2]: Leaving directory `/usr/local/src/libxml2-2.7.2/xstc'

make[1]: Leaving directory `/usr/local/src/libxml2-2.7.2/xstc'

B:安装jpeg8

 

tar -zxvf jpegsrc.v8b.tar.gz 

cd jpeg-8b 

./configure --prefix=/usr/local/jpeg \

--enable-shared --enable-static 

make && make install

C:安装libpng

 

tar zxvf libpng-1.4.3.tar.gz 

cd libpng-1.4.3 

./configure  安装到默认目录

make && make install

D:安装freetype(字体库)

 

tar zxvf freetype-2.4.1.tar.gz 

cd  freetype-2.4.1

./configure --prefix=/usr/local/freetype

make && make install

E:安装GD库

 

tar -zvxf gd-2.0.35.tar.gz 

mkdir -p /usr/local/gd 

cd gd-2.0.35 

./configure --prefix=/usr/local/gd  \

--with-jpeg=/usr/local/jpeg/  \

--with-png --with-zlib \

--with-freetype=/usr/local/freetype

make && make install

F:安装 php5

 

tar -jxvf php-5.3.6.tar.bz2

cd php-5.3.6

./configure --prefix=/usr/local/php \

--with-apxs2=/usr/local/http2/bin/apxs \

--with-mysql=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-freetype-dir=/usr/local/freetype \

--with-gd=/usr/local/gd \

--with-zlib --with-libxml-dir=/usr/local/libxml2 \

--with-jpeg-dir=/usr/local/jpeg \

--with-png-dir \

--enable-mbstring=all \

--enable-mbregex \

--enable-shared 

make && make install 

cp php.ini-development /usr/local/php/lib/php.ini

编辑apache配置文件,使其支持PHP解析

 

AddType application/x-httpd-php .php

LoadModule php5_module modules/libphp5.so   //确保有

DirectoryIndex index.html在index.html 前面添加index.php 设置默认访问页面

五:安装mysql

 

A:编译安装mysql

 

tar -xzvf mysql-5.1.58.tar.gz

cd mysql-5.1.58

yum -y install ncurses-devel

./configure --prefix=/usr/local/mysql \

--with-charset=utf8 \

--with-extra-charsets=gbk,gb2312,binary

make && make install

B:初始化mysql

 

groupadd mysql                     //创建一个组 叫 mysql

useradd  -g mysql mysql         //创建一个用户叫mysql,属于mysql组  ,前面是组,后面是用户

cp support-files/my-medium.cnf /etc/my.cnf //复制配置文件

cd /usr/local/mysql

chown -R mysql.mysql .            //给mysql组赋权限

bin/mysql_install_db --user=mysql \            //创建mysql系统数据库和测试数据库

--datadir=/usr/local/mysql/var

chown -R root .                              //把当前目录文件的主人都改为root,避免数据库

 恢复出厂设置,就是避免上一条数据执行       

chown -R mysql var                            //给数据库存放目录 var 赋予权限给mysql用户,

只能操作当前var目录

bin/mysqld_safe --user=mysql &

#[root@localhost init.d]# 170128 23:56:26 mysqld_safe Logging to '/var/log/mysqld.log'.

#170128 23:56:26 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

#170128 23:56:26 mysqld_safe mysqld from pid file /var/lib/mysql/mysqld.pid ended

# /usr/local/mysql/bin/mysql_install_db --user=mysql  //此命令是出现以上报错解决方法

ps -A | grep mysql   //查看mysql是否启动

创建mysql测试数据库和系统的数据库

 

把当前目录文件的主人都改为root,避免数据库恢复为出厂设置。

 

设置mysql和apache、vsftpd服务自动启动

 

vim /etc/inittab   把id:5:init....     把5改为3 ,让他走配置文件   设置服务器启动自动切换到命令行 

vim /etc/rc.d/rc.local   配置这个文件,加入下面的行命令

/usr/local/http2/bin/apachectl start

/usr/local/mysql/bin/mysqld_safe --user=mysql &

/etc/rc.d/init.d/vsftpd  start  

service vsftpd start

下载redis

wget http://download.redis.io/releases/redis-2.6.16.tar.gz

tar zxvf redis-2.6.16.tar.gz

cd redis-2.6.16.tar.gz

make test

yum install tcl 

make test

make PREFIX=/usr/local/redis install

cp /usr/local/src/redis-2.6.16/redis.conf ./

./bin/redis-server ./redis.conf 

vim redis.conf    把daemonize  改为 yes ,设置自动启动   ,重启redis

安装php扩展编译

 

进入pecl.php.net

 

cd /usr/local/src

wget http://pecl.php.net/get/redis-2.2.4.tgz 

tar zxvf redis-2.2.4.tgz

cd redis-2.2.4.tgz

ls  发现没有configure

/usr/local/php/bin/phpize

ls 发现出现configure

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install ---------/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/     --复制扩展目录

引入编译出的redis.so

 

ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/  发现多出了一个redis.so

cd /usr/local/php/lib

vim php.ini

在 extension=php_shmop.dll 下面添加

 

extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/redis.so

重启就可以了

posted @ 2017-12-30 12:15  御世制人  阅读(204)  评论(0编辑  收藏  举报