PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Centos下安装Lamp和vsftpd、redis大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

[root@localhost ~]#servcie iptables stop --临时关闭防火墙
@H_419_2@[root@localhost ~]#chkconfig iptables off --永久关闭防火墙

yum安装httpd和PHPMysqL服务

 

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 

@H_677_0@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

@H_677_0@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 可以编译通过

@H_677_0@make && make install

@H_677_0@make 完正常情况显示

 

@H_677_0@making install in xstc

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

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

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

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

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

@H_677_0@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 

@H_677_0@make && make install

C:安装libpng

 

tar zxvf libpng-1.4.3.tar.gz 

cd libpng-1.4.3 

./configure  安装到认目录

@H_677_0@make && make install

D:安装freetype(字体库)

 

tar zxvf freetype-2.4.1.tar.gz 

cd  freetype-2.4.1

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

@H_677_0@make && make install

E:安装GD库

 

tar -zvxf gd-2.0.35.tar.gz 

@H_677_0@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

@H_677_0@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 

@H_677_0@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

@H_677_0@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

@H_677_0@make test

yum install tcl 

@H_677_0@make test

@H_677_0@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

@H_677_0@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

重启就可以了

大佬总结

以上是大佬教程为你收集整理的Centos下安装Lamp和vsftpd、redis全部内容,希望文章能够帮你解决Centos下安装Lamp和vsftpd、redis所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: