Red Hat下如何安装LAMP

64次阅读
没有评论

共计 4454 个字符,预计需要花费 12 分钟才能阅读完成。

这篇文章给大家分享的是有关 Red Hat 下如何安装 LAMP 的内容。丸趣 TV 小编觉得挺实用的,因此分享给大家做个参考,一起跟随丸趣 TV 小编过来看看吧。

LAMP 安装

1、安装 MYSQL

#tar –zxvf mysql-5.0.22.tar.gz // 解开安装包  #cd mysql-5.0.22 // 进入安装目录  #mkdir /usr/local/mysql // 创建 mysql 目录  #./configure --prefix=/usr/local/mysql // 设置安装目录  #make // 编译  #make install // 安装  //  或是这样  #make   make install  编译并安装  #groupadd mysql // 新建名为 mysql 的组  #useradd –g mysql mysql // 新建名为 mysql 的用户,并且默认属于 mysql 组  #chgrp –R mysql /usr/local/mysql // 改变 /usr/local/mysql 及下属文件与目录属于的组  #cp support-files/my-large.cnf /etc/my.cnf // 拷贝 my-large.cnf 到 /etc 中,替换原有的 my.cnf #scripts/mysql_install_db // 建立初始数据  #chown –R mysql:mysql /usr/local/mysql/var // 更改 var 及下面的文件目录属组与属主  #cp support-files/mysql.server /etc/init.d/mysqld // 拷贝 mysql.server 到 init.d 目录中并重命名为 mysql, 启动文件  #chmod 755 /etc/init.d/mysqld // 设置启动文件的权限为 755 #chkconfig --add mysqld // 把此服务添加到系统启动中,add 为添加至 /etc/rc.d/init.d 中  #chkconfig mysqld on //on 默认在 3\5 级别服务默认启动  #/etc/init.d/mysqld start #/usr/local/mysql/bin/mysqld_safe   // 启动 mysql #/usr/local/mysql/bin/mysqladmin –u root –p password 123 // 默认 root 用户密码为空,设置密码为 123 #/usr/local/mysql/bin/mysql –u root –p // 输入上面设置的 123 后,以 root 身份登陆  #./mysqladmin -u root -p password 456 // 输入上面设置的 123 后. 以 root 身份登陆  mysql  grant select on test.* to  ttt  @ %  identified by ttt  with grant option; // 添加一个名称为 ttt, 密码为 ttt 的 mysql 账户, 对 test 数据库有修改权限 

2、Apahce 的安装

#tar -zxvf httpd-2.2.3.tar.gz // 解压 httpd-2.2.3.tar.gz 包  #./configure –prefix=/usr/local/apache2 --enbale-module=so // 这里的—prefix 指定 apache  的安装将安装到:/usr/local/apache2 目录下  #make // 编译  #make install // 安装  #vi /usr/local/apache2/conf/httpd.conf // 将里面的 ServerName 前面的 #去掉,后面是:自己的 ip:80 #/usr/local/apache2/bin/apachectl start // 启动 apache 服务 

如果你想一开机就让 apache 自动运行的话,那么进行如下操作:

 编辑 etc/rc.d /rc.local # vi /etc/rc.d/rc.local

在 *** 加上一句:/usr/local/apache2/bin/apachectl start

看这里的 /usr/local/apache2 的安装路径用到了吧,所以大家装的时候一定要记清楚哦。。。。

jpeg 包的安装和设定

#mkdir -p /usr/local/jpeg6 # mkdir -p /usr/local/jpeg6/bin # mkdir -p /usr/local/jpeg6/lib # mkdir -p /usr/local/jpeg6/include # mkdir -p /usr/local/jpeg6/man/man1 // 上面的创建目录  #tar –zxvf jpegsrc.v6b.tar.gz // 解压 jpegsrc.v6b.tar.gz 包  #./configure –prefix=/usr/local/jpeg6/ --enable-static #make // 编译  #make install // 安装   安装 libpng # tar xvzf libpng-1.2.8.tar.gz # cd libpng-1.2.8 # cp scritp/makefile.gcmmx makefile(本身自带 makefile 文件,无需 configure,copy 一下就 OK 了) # make # make install

3、安装 freetype

#tar –zxvf freetype-2.3.5.tar.gz #cd freetype-2.3.5 #mkdir –p /usr/local/freetype #./configure –prefix=/usr/local/freetype #make #make install

4、安装 zlib(lib png 支持包)

#tar –zxvf zlib-1.2.2.tar.gz #cd zlib-1.2.2.tar.gz #./configure #make #make insatll  安装 GD 库 # #tar –zxvf gd-2.0.33.tar.gz #cd gd-2.0.33.tar.gz # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/ --with-zlib=/usr/local/lib/ --with-freetype=/usr/local/freetype/ #make #make install #cp gd.h /usr/local/lib/

5、安装 xml 包

#tar –zxvf libxml2-2.6.19.tar.gz #cd libxml2-2.2.6.19 #./configure –prefix=/usr/local/libxml2 #make #make install

6、安装 Curl 库

#tar –zxvf curl-7.16.4.tar.gz #cd curl-7.16.4 #./configure –prefix=/usr/local/curl #make #make install

7、安装 php

#tar –zxvf php-5.2.3.tar.gz #cd php-5.2.3.tar.gz #./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-curl=/usr/local/curl --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-gd-dir=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/lib --with-png=/usr/local/lib/ --with-freetype-dir=/usr/local/freetype #make #make install #cp php.ini-dist /usr/local/lib/php.ini

其中./configure 后的 –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –with-mysql=/usr/local/mysql/ –with-libxml-dir=/usr/local/libxml2 是必要的选项 –with-gd=/usr/local/gd2/ –with-jpeg-dir=/usr/local/jpeg6/ –with-png=/usr/local/lib –with-zlib-dir=/usr/lib –with-freetype-dir=/usr/local/freetype 这是让 PHP 支持 GD 库的配置选项

–with-curl=/usr/local/curl 支持 CURL 库 –enable-ftp 打开 FTP 库函数支持

–enable-soap –with-xsl=/usr/local/libxslt –enable-xslt 让 PHP 支持 SOAP, 上面这些一般用得少, 可以去掉

— 收尾工作:

编辑 apache 的配置文件 httpd.conf

vi /etc/httpd/httpd.conf

找到“#AddType application/x-gzip .gz .tgz”

并在后面加入

AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps

这两行的目的是让 apache 识别 php。

再找到“DirectoryIndex index.html”

加上 index.php 让它把 index.php 做为默认页

— 测试环境:

在 /usr/local/apache/htdocs/ 下面建立 php 文件。

# vi /usr/local/apache/htdocs/index.php

输入:

 phpinfo(); ?

6、重启 apache 服务器

# /usr/local/apache/bin/apachectl restart

浏览器中输入:http://127.0.0.1/index.php 测试一下,激动的话面就出来喽

感谢各位的阅读!关于“Red Hat 下如何安装 LAMP”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-25发表,共计4454字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)