标签:LNMP搭建
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
标签:LNMP搭建
原文地址:http://blog.51cto.com/13673885/2092914