linux下LAMP环境建立.docx
- 文档编号:14919199
- 上传时间:2023-06-28
- 格式:DOCX
- 页数:8
- 大小:17.87KB
linux下LAMP环境建立.docx
《linux下LAMP环境建立.docx》由会员分享,可在线阅读,更多相关《linux下LAMP环境建立.docx(8页珍藏版)》请在冰点文库上搜索。
linux下LAMP环境建立
1.LAMP环境的搭建各种机器的不同以及虚拟机器的不同搭建时所使用的参数也不尽相同。
下面我根据我自己的环境搭建的LAMP所总结的心得做下讲解。
机器配置intelPentiumdual-coreE63004G内存硬盘500显卡独立
虚拟机使用VM9.02linux版本Centos5.9
为什么涉及硬件呢因为很多硬件对于VM虚拟机技术支持的不是很好这里我推荐AMD架构的机器。
因为根据我使用的心得AMD架构全系完全支持虚拟技术
首先我们需要安装VM9.02以及Centos5.9在这里我们就不多做描述了。
有一点需要注意有些机器配置因为对虚拟技术支持的不够完善在安装Centos时会不支持图形界面安装。
这样会让你安装的比较麻烦。
不多做描述了。
在安装Centos我们因为使用NAT模式所以进入系统后只需要激活网卡就可以上网了
2需要上网下载zlib-1.2.8.tar.gzlibpng-1.5.17.tar.gzjpegsrc.v6b.tar.gzfreetype-2.4.0.tar.gzlibmcrypt-2.5.8.tar.gzlibxml2-2.7.2.tar.gzapr-1.4.5.tar.gzapr-util-1.4.1.tarpcre-8.33.tar.gzmysql-5.0.41.tar.gzhttpd-2.2.13.tar.gzphp-5.2.6.tar.gzmhash-0.9.9.9.tar.gzgd-2.0.32.tar.gz
安装的步骤
tarzxvfzlib-1.2.8.tar.gz
cdzlib-1.2.8
./configure--prefix=/usr/local/zlib这里主要是为zlib文件指定目录
make&&makeinstall
tarzxvflibpng-1.5.17.tar.gz
cdlibpng-1.5.17
./configure--prefix=/usr/local/libpng这里主要是为libpng文件指定目录
make&&makeinstall
mkdir/usr/local/jpeg6
tarzxvfjpegsrc.v6b.tar.gz
./configure--prefix=/usr/local/jpeg6
make&&makeinstall
tarzxvffreetype-2.4.0.tar.gz
./configure--prefix=/usr/local/freetype
make&&makeinstall
tarzxvfapr-1.4.5.tar.gz
./configure--prefix=/usr/local/apr
make&&makeinstall
tarzxvfapr-util-1.4.1.tar
./configure--prefix=/usr/local/apr-util
make&&makeinstall
下面是很重要的步骤就是安装gd库
tarzxvfgd-2.0.32.tar.gz
cdgd-2.0.32
./configure\
--prefix=/usr/local/gd2/\
--with-zlib=/usr/local/zlib/\
--with-jpeg=/usr/local/jpeg6/\
--with-libpng=/usr/local/libpng/\
--with-freetype=/usr/local/freetype
make&&makeinstall
下面是安装数据库系统
tarzxvfmysql-5.0.41.tar.gz
cdmysql-5.0.41
./configure\
--prefix=/usr/local/mysql/\
--with-extra-charsets=all
make&&makeinstall
此处常见的错误有很多,如果遇到错误请尝试换mysql版本重新安装下
[root@localhostmysql-5.0.41]#groupaddmysql添加mysql组
[root@localhostmysql-5.0.41]#useraddmysqlmysql添加mysql用户到mysql用户组里
[root@localhostmysql-5.0.41]cd/usr/local/mysql
[root@localhostmysql]#bin/mysql_install_db--user=mysql此处为初始化数据库
[root@localhostmysql]#chown-Rroot:
mysql.设置权限,注意后面有一个"."
[root@localhostmysql]#chown-Rmysql/var/lib/mysql设置mysql目录权限
[root@localhostmysql]#chgrp-Rmysql.注意后面有一个"."
[root@localhostmysql]#cpshare/mysql/my-f/etc/f
cp:
是否覆盖“/etc/f”?
y
[root@localhostmysql]#cpshare/mysql/mysql.server/etc/rc.d/init.d/mysqld开机自动启动mysql
cp:
是否覆盖“/etc/rc.d/init.d/mysqld”?
y
[root@localhostmysql]#chkconfig--addmysqld这里是添加mysql为启动项
除了上述方法还可以使用下面方法添加mysqlapache为开机自动启动
#cd/etc/rc.d
#virc.local
在rc.local加入:
/usr/local/apache/bin/apachectlstart
/usr/local/mysql/bin/mysqld_safe--user=mysql&这样设置就可以了。
接下来我们继续mysql的设置
[root@localhostmysql]#/etc/rc.d/init.d/mysqldstart启动MySQL
StartingMySQL
[root@localhostmysql]#bin/mysqladmin-urootpassword"要设置的密码"
[root@localhostmysql]#servicemysqldstop关闭MySQL
ShuttingdownMySQL
小结:
查看数据库是否启动的关键主要是看3306端口是否启动所以启动完数据库最好使用netstat–ntl命令查看3306端口是否启动
下面是安装APACHE步骤
mkdir/usr/local/jpeg6/bin
mkdir/usr/local/jpeg6/lib
mkdir/usr/local/jpeg6/include
mkdir/usr/local/jpeg6/man
mkdir/usr/local//jpeg6/man/man1
tarzxvfpcre-8.33.tar.gz
cdpcre-8.33
./configure–prefix=/usr/local/pcre
make&&makeinstall
tarzxvfhttpd-2.2.13.tar.gz
cdhttpd-2.2.13
./configure--prefix=/usr/local/apache2--enable-lib64--libdir=/usr/lib64--enable-so--enable-deflate=shared--enable-expires=shared--enable-rewrite=shared--enable-mods-shared=all--enable-modules=all--enable-static-support--with-z=/usr/local/zlib--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util--with-included-apr--with-pcre=/usr/local/pcre--enable-cache--enable-disk-cache--enable-mem-cache--enable-file-cache
make&&makeinstall
#/usr/local/apache2/bin/apachectl-kstart启动apahce
用浏览器查看http:
//localhost,得到itworks,说明apache已经配置成功了.
#/usr/local/apache2/bin/apachectl-kstop停止apache
附录:
先了解一下apache的相对结构。
/etc/httpd/conf/httpd.conf:
主配置文件,其主要设定以它为主;
/etc/httpd/conf.d/*.conf:
额外参数配置,如果你不想修改原始配置文件httpd.conf的话,可以将你自己的设置独立出来,如创建为/etc/httpd/conf.d/child.conf,apache启动时就被载入;
/usr/lib/httpd/modules/:
apache支持很多模块,你所想要的模块都放在其中;
/var/www/html/:
默认‘首页’所在目录,当你输入http:
//localhost时所显示资料所在目录;
/var/www/error/:
配置错误或浏览器要求资料错误时,浏览器上出现的错误讯息以这个目录预设为主;
/var/www/icons/:
它提供Apache默认给予的一些小图示,你可以随意使用,当你输入http:
//localhost/icons/时所显示的资料所在;
/var/www/cgi-bin/:
默认给一些可执行的CGI(网页程序)程序放置的目录;
/var/log/httpd/:
默认的apache登录信息都放在这里,对流量较大的网站,这个目录要小心设置;
/usr/sbin/apachectl:
apache的主要启动文件,其实是shellscript;
/usr/sbin/httpd:
apache的二进制启动文件。
。
APACHE测试
Netstat–tunl|grep‘:
80’
tcp00:
:
:
80
或者用netstat–ntl来查看80端口是否打开
最后打开上网浏览器在地址栏输入localhost
Itworks
就是正常启动了
将apache注册为系统服务
#cd/etc/rc.d
#virc.local
在rc.local加入:
/usr/local/apache/bin/apachectlstart
将APACHE加入到系统的启动项里、
下面是安装PHP的步骤
tarzxvflibxml2-2.7.2.tar.gz
cdlibxml2-2.7.2
./configure--prefix=/usr/local/libxml
make&&makeinstall
tarzxvflibmcrypt-2.5.8.tar.gz
cdlibmcrypt-2.5.8
./configure--prefix=/usr/local/libmcrypt
make&&makeinstall
tarzxvfmhash-0.9.9.9.tar.gz
cdmhash-0.9.9.9
./configure–prefix=/usr/local/mhash
make&&makeinstall
tarzxvfphp-5.2.6.tar.gz
cdphp-5.2.6
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc/--with-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-iconv-dir=/usr/local--with-freetype-dir=/usr/local/freetype/--with-jpeg-dir=/usr/local/jpeg6/--with-png-dir=/usr/local/libpng/--with-zlib=/usr/local/zlib/--with-libxml=/usr/local/libxml/--enable-xml--enable-mbstring=all--enable-ftp--with-gd=/usr/local/gd2/--with-mhash=/usr/local/libmhash--without-pear--enable-sockets--enable-soap--enable-gd-native-ttf--enable-sysvsem--enable-sysvshm--enable-shmop--enable-zip--with-mcrypt=/usr/local/libmcrypt/--with-prce=/usr/local/pcre--enable-bcmath--enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--with-openssl
#vi/usr/local/apache/conf/httpd.conf
找到下面的一行.
#LoadModulephp4_modulemodules/libphp5.so此行表明PHP加载成功
在下面添加AddTypeapplication/x-httpd-php.php
如果安装了ssl就添加AddTypeapplication/x-httpd-php-source.phps
/usr/local/apache2/apachectl–t
测试通过既为PHP安装成功
打开浏览器输入localhost/index.php
如果显示PHP的图标以及列表表明你的环境完全编译成功。
那么LAMP环境的建立就此成功。
很高兴分享我通过无数次失败建立成功的LAMP环境。
拿出来与大家分享。
最后祝福大家都能成功
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- linux LAMP 环境 建立