lamp(apache2.2mysql5.0php5.3)
一、下载源码包
[root@ceshi ~]# mkdir -p /www/xiazai //新建文件夹
[root@ceshi ~]# cd /www/xiazai //进入放置软件包目录
[root@ceshi xiazai]# wgethttp://mirrors.sohu.com/apache/httpd-2.2.34.tar.gz下载apache
[root@ceshixiazai]#wgethttp://mirrors.sohu.com/mysql/MySQL-5.0/mysql-5.0.95-linux-x86_64-glibc23.tar.gz
http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
[root@ceshixiazai]#wgethttp://mirrors.sohu.com/php/php-5.3.27.tar.gz
二、安装mysql
[root@ceshixiazai]#tar-zxvfmysql-5.0.95-linux-x86_64-glibc23.tar.gz //解压
1、把解压完的数据移动到[root@o20150628102525xiazai]#mkdir-p/www/server
[root@ceshixiazai]#mv mysql-5.0.95-linux-x86_64-glibc23/www/server/mysql//移动到mysql目录下
[root@ceshixiazai]#useradd-s/sbin/nologin-Mmysql//建立用户
[root@ceshixiazai]#cd/www/server/mysql//进入mysql安装目录
[root@ceshimysql]#mkdir-p/www/data/mysqldata//新建数据库存放地址
[root@ceshimysql]#chown-Rmysql:mysql/www/data/mysqldata//设置mysql数据库存放目录权限
[root@ceshimysql]#./scripts/mysql_install_db--user=mysql--datadir=/www/data/mysqldata
--user 定义数据库的所属主, --datadir 定义数据库安装到哪里,建议放到大空间的分区上,这个目录需要自行创建。这一步骤很关键,如果你看到两个 “OK” 说明执行正确
4、拷贝配置文件
[root@ceshimysql]#cpsupport-files/my-large.cnf/etc/my.cnf//拷贝配置文件
5、拷贝启动脚本文件并修改其属性
[root@ceshi mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@ceshi mysql]# chmod 755 /etc/init.d/mysqld
6、修改启动脚本
[root@ceshi mysql]# yum install vim*
[root@ceshi mysql]# vim /etc/init.d/mysqld //编辑数据库主配置文件
需要修改的地方有 “datadir=/data/mysql” (前面初始化数据库时定义的目录)
basedir=/www/server/mysql
datadir=/www/data/mysqldata
7、把启动脚本加入系统服务项,并设定开机启动,启动mysql
[root@ceshi mysql]# chkconfig --add mysqld
[root@ceshimysql]#chkconfigmysqldon
[root@jiahaowumysql]#servicemysqldstart
[root@jiahaowumysql]#netstat-lnp|grepmysql //查看端口是否运行
[root@o20150628102525mysql]#echo"PATH=$PATH:/www/server/mysql/bin">>/etc/profile
echo"PATH=$PATH:/www/wdlinux/apache_php-5.6.21/bin">>/etc/profile
/www/wdlinux/apache_php-5.6.21/bin/
[root@o20150628102525 mysql]# source /etc/profile 设置变量开机加载
#/www/server/mysql/bin/mysqladmin -u root password75dn289z //设置MySQL密码
8、测试
[root@o20150628102525mysql]#shutdown-rnow //重启
[root@o20161209038952~]#mysql-uroot-p
三、安装Apache
首先添加依赖应用
yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel zlib-develpcrepcre-develaprapr-devel
yum install gcc zlib-devel openssl-deve
[root@ceshi xiazai]# tar -zxvf httpd-2.2.32.tar.gz //解压缩包
2、进入目录
[root@ceshixiazai]#cdhttpd-2.2.32
[root@ceshi httpd-2.2.32]# mkdir -p /www/server新建安装目录
3、编译
[root@o20161209038952httpd-2.2.31]#./configure--prefix=/www/server/httpd--with-included-apr--enable-so--enable-deflate=shared--enable-expires=shared--enable-rewrite=shared--with-pcre
--prefix指定安装到哪里,--enable-so表示启用DSO[1]--enable-deflate=shared表示共享的方式编译deflate,后面的参数同理。
如果这一步你出现了这样的错误error: mod_deflate has been requested but can not be built dueto prerequisite failures
解决办法yum install -y zlib-devel
为了避免在make的时候出现错误,所以最好是提前先安装好一些库文件
[root@o20161209038952httpd-2.2.31]##yuminstall-ypcrepcre-develaprapr-devel
[root@ceshi httpd-2.2.32]# echo $?
0
[root@ceshi httpd-2.2.32]# make install
[root@o20161209038952httpd-2.2.31]##echo$?
[root@o20161209038952httpd-2.2.31]#vi/etc/init.d/httpd新建启动脚本
[root@iZbp18ekm5cjum3elk9bgaZhttpd-2.2.31]#chmod775/etc/init.d/httpd //设置权限
[root@iZbp18ekm5cjum3elk9bgaZhttpd-2.2.31]#chkconfig--addhttpd
[root@iZbp18ekm5cjum3elk9bgaZhttpd-2.2.31]#chkconfighttpdon
http://note.youdao.com/noteshare?id=e4485bc811f68e4a70bb8f8be7b1f16bhttpd启动脚本
四、安装PHP
[root@o20161209038952httpd-2.2.31]#cd/www/xiazai/
下面我们来 添加 jpeg 格式文件的支持
wgethttp://y.w-jiahao.cn/by/la/jpegsrc.v8b.tar.gz
tar -zxvf jpegsrc.v8b.tar.gz
cd jpeg-8b
./configure --prefix=/www/server/jpeg --enable-shared --enable-static
make && make install
使用php mcrypt 前必须先安装Libmcrypt
libmcrypt源码安装方法:
cd/www/xiazai
wgethttp://y.w-jiahao.cn/by/la/libmcrypt-2.5.8.tar.gz
tar-zxvflibmcrypt-2.5.8.tar.gz
cdlibmcrypt-2.5.8
./configure--prefix=/www/server/libmcrypt
make
makeinstall
1、解压
[root@jiahaowusrc]#tar-zxvfphp-5.3.27.tar.gz
2、配置参数
[root@o20161209038952xiazai]#cdphp-5.3.27
[root@o20161209038952php-5.3.27]#./configure--prefix=/www/server/php--with-apxs2=/www/server/httpd/bin/apxs--with-config-file-path=/www/server/php/etc--with-mysql=/www/server/mysql--with-libxml-dir--with-gd--with-jpeg-dir=/www/server/jpeg--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt=/www/server/libmcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exif--disable-ipv6
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/httpd/bin/apxs--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-libxml-dir--with-gd--with-jpeg-dir=/usr/local/jpeg--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt=/usr/local/libmcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets--enable-exif--disable-ipv6
遇到如下错误
configure: error: xml2-config not found. Please check your libxml2 installation.
解决办法yum install -y libxml2-devel
configure: error: Cannot find OpenSSL's <evp.h>
解决办法yum install -y openssl openssl-devel
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
解决办法yum install -y bzip2 bzip2-devel
configure: error: png.h not found
解决办法yum install -y libpng libpng-devel
configure: error: freetype.h not found.
解决办法yum install -y freetype freetype-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt
[root@jiahaowuphp-5.3.27]#echo$?
[root@jiahaowuphp-5.3.27]#make
报错:make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
解决办法
这是由于内存小于1G所导致.
在./configure加上选项:
--disable-fileinfo
有时候我们编译php的时候会出现以下错误:
make ***[libphp5.la] Error 1
处理方法:
安装两个rpm包#yum -y install libtool.x86_64 libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64
然后make clean;make
[root@jiahaowuphp-5.3.27]#echo$?
[root@jiahaowuphp-5.3.27]#makeinstall
[root@jiahaowuphp-5.3.27]#echo$? ///待续
3、拷贝配置文件
[root@o20161209038952php-5.3.27]#cpphp.ini-production/www/server/php/etc/php.ini 四、apache结合php
Apache主配置文件为:/www/server/httpd/conf/httpd.conf
[root@o20161209038952php-5.3.27]#vi/www/server/httpd/conf/httpd.conf
找到
<IfModule dir_module>
x
DirectoryIndex index.html
</IfModule>
改为
<IfModuledir_module>
DirectoryIndexindex.htmlindex.htmindex.php
</IfModule>
找到AddTypeapplication/x-gzip.gz.tgz 在下面添加AddType application/x-httpd-php .php 314
找到#ServerName www.example.com:80改为ServerName localhost:80 102
#AllowOverrideNone改为AllowOverrideAll
#Includeconf/extra/httpd-vhosts.conf改为Includeconf/extra/httpd-vhosts.conf
wq保存
六、测试PHP
[root@jiahaowuconf]#curllocalhost 查看是否正常显示Itworks!
测试php
[root@iZ30rtw8o80Z conf]#echo"<?phpphpinfo();?>">/www/server/httpd/htdocs/index.php添加php文档
http://note.youdao.com/noteshare?id=731fc872a408734d6b1b803a1a3ec193httpd启动脚本
初次使用浏览器访问web服务的时候,可能无法访问,这是因为防火墙的缘故。请运行下面的命令
[root@jiahaowu~]#iptables-F 关闭防火墙
截图范:
==============================
curl组件安装
进入安装目录/usr/local/src/php-5.3.27/ext/curl
执行/www/server/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-curl=/usr/local/php/lib/php/extensions
make && make install
在php.ini添加路径
extension="/usr/local/php/lib/php/extensions/curl.so"
==============================================
Zend安装
换成:vim/www/server/php/etc/php.ini
[Zend]
zend_extension = /www/server/zujian/ZendGuardLoader.so
zend_loader.enable = 1
配置ionCube:
修改php.ini 在文件尾部添加以下代码:
[ionCube Loader]
zend_extension="/usr/local/ioncube/ioncube_loader_lin_php5.4.so"
#################################
php添加开启pdo_mysql扩展模块
/www/server/php/bin/phpize
./configure --with-php-config=/www/server/php/bin/php-config --with-pdo-mysql=/www/server/mysql
make
make install
手动开启PDO,在php-ini文件上开启,连接数据库用。mysql开启PDO, 在php.ini加上extension=pdo_mysql.so,extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613", 再重启php即可
mysqli安装
/www/server/php/bin/phpize
./configure --with-php-config=/www/server/php/bin/php-config --with-mysqli=/www/server/mysql/bin/mysql_config
make
make install
############################
Redis扩展安装
wgethttp://pecl.php.net/get/redis-3.0.0.tgz
mvredis-3.0.0.tgzredis-3.0.0.tar.gz
tar-zxvfredis-3.0.0.tar.gz
cdredis-3.0.0
/www/server/php/bin/phpize
./configure--with-php-config=/www/server/php/bin/php-config
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。