LAMP 搭建
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LAMP 搭建相关的知识,希望对你有一定的参考价值。
1.1、下载所需的包
# cd /usr/local/src/ ##http://mirrors.sohu.com/ 搜狐镜像下载所需的mysql apache php都可以找到
1.2、安装配置和编译时所需要的软件
1、首先安装扩展yum源
# yum install -y epel-release
# yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libjpeg-devel libcurl-devel libmcrypt-devel pcre-devel gcc
1.3、安装mysql
# tar zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz
# useradd -M -s /sbin/nologin mysql
# mkdir -p /data/mysql
# chown -R mysql:mysql /data/mysql
# mv mysql-5.1.73-linux-i686-glibc23 /usr/local/mysql
# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
# cp support-files/my-large.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/init.d/mysqld
# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql
# chmod 755 /etc/init.d/mysqld
# chkconfig mysqld on
# vim /etc/profile.d/path.sh ##加入环境变量
export PATH=$PATH:/usr/local/mysql/bin
# source /etc/profile.d/path.sh
# /etc/init.d/mysqld start
# mysql -uroot
1.4、编译安装apache
# cd /usr/local/src/
# tar zxvf httpd-2.2.34.tar.gz
# ./configure --prefix=/usr/local/apache/ --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
#make
#make install
# vim /usr/local/apache/conf/httpd.conf
Server Name localhost:80
# /usr/local/apache/bin/apachectl start
将apache 加入到环境变量
# vim /etc/profile.d/path.sh
export PATH=$PATH:/usr/local/apache/bin
1.5、编译安装php
# cd /usr/local/src/
# tar zxvf php-5.4.44.tar.gz
# cd php-5.4.44
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
# make
# make install
1.6、测试php解析
# cp /usr/local/src/php-5.4.44/php.ini-production /usr/local/php/etc/php.ini
1、修改apache配置文件
# vim /usr/local/apache/conf/httpd.conf
AddType application/x-gzip .gz .tgz ##找到这行在下面添加
AddType application/x-httpd-php .php
DirectoryIndex index.html ##找到这行 在后面添加 index.htm index.php
2、检测配置文件
# /usr/local/apache/bin/apachectl graceful、
3、编写测试php文件
# vim /usr/local/apache/htdocs/info.php
<?php
phpinfo();
?>
浏览器访问测试192.168.230.130/info.php
以上是关于LAMP 搭建的主要内容,如果未能解决你的问题,请参考以下文章