标签:lamp环境搭建
0. 安装centOS 6.5 minimal
1. 安装mysql
cd /usr/local/src/
yum install –y wget #安装wget
yum install –y vim-enhanced # 安装vim
wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
注意:上面的地址是32位机器用的,如果你的机器是64位,下载这个包(http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-x86_64-icc-glibc23.tar.gz)安装方法是一样的。
tar zxvf /usr/local/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
mv mysql-5.1.40-linux-i686-icc-glibc23/usr/local/mysql
useradd -s /sbin/nologin mysql
cd /usr/local/mysql
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
./scripts/mysql_install_db --user=mysql--datadir=/data/mysql
出现两个OK即为成功,或可以用echo$?查看反回值是否为0
cp support-files/my-large.cnf /etc/my.cnf (实际生产环境内存比较大为support-files/my-huge.cnf)MYSQL的配置文件,提示否覆盖,选择覆盖
cp support-files/mysql.server /etc/init.d/mysqld MYSQL服务的启动文件
chmod 755 /etc/init.d/mysqld 给mysqld文件赋予权限
vim /etc/init.d/mysqld
#修改datadir和basedir如右 datadir=/data/mysql basedir=/usr/local/mysql 然后保存退出。
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start 会提示“Starting MySQL.. SUCCESS!”
2. 安装apache
Yum install gcc 安装gcc编译器
cd /usr/local/src
wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz
tar zvxf httpd-2.2.16.tar.gz
cd httpd-2.2.16
./configure --prefix=/usr/local/apache2 --enable-mods-shared=most --enable-so
make &&make install
3.安装php
cd /usr/local/src
wget http://cn2.php.net/distributions/php-5.3.28.tar.gz
tar zxf php-5.3.28.tar.gz
cd php-5.3.28
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/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
报错:configure: error: xml2-config notfound. Please check your libxml2 installation.
yum install -y libxml2
yum install -y libxml2-devel
报错:configure: error: Cannot findOpenSSL‘s <evp.h>
yum install openssl openssl-devel
报错:configure: error: Please reinstallthe BZip2 distribution
yum install –y bzip2bzip2-devel
报错:configure: error: jpeglib.h notfound.
yum install libjpeglibjpeg-devel
报错:configure: error: png.h not found.
yum install libpnglibpng-devel
报错:configure: error: freetype.h notfound.
yum installfreetype-devel
报错:configure: error: mcrypt.h not found.Please reinstall libmcrypt
rpm -ivh "http://www.lishiming.net/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm" #安装epel源
yum install -ylibmcrypt-devel
make && make install
4. 配置apache让其支持解析php
vim /usr/local/apache2/conf/httpd.conf
找到:AddType application/x-gzip .gz .tgz
在该行下面添加:
AddType application/x-httpd-php .php
找到:
< IfModule dir_module>
DirectoryIndexindex.html
< /IfModule>
将该行改为:
< IfModule dir_module>
DirectoryIndexindex.html index.htm index.php
< /IfModule>
找到:
#ServerNamewww.example.com:80
修改为:
ServerName localhost:80
5. 测试解析php
/usr/local/apache2/bin/apachectl -t
如果有错误则继续修改配置文件httpd.conf;如果显示“Syntax OK”则正常
/usr/local/apache2/bin/apachectl start
netstat -lnp |grep httpd
tcp 0 0 :::80 :::* LISTEN 26570/httpd
vim /usr/local/apache2/htdocs/1.php
写入:
<?php
echo "php ok";
Phpinfo();
?>
保存后,继续测试:
curl localhost/1.php
扩展学习:
mysql5.5源码编译安装 http://www.aminglinux.com/bbs/thread-1059-1-1.html
mysql5.6源码安装报错 http://www.aminglinux.com/bbs/thread-7743-1-1.html
httpd-2.4版本编译安装方法 http://www.aminglinux.com/bbs/thread-7283-1-1.html
apache启动脚本加入系统服务列表 http://www.aminglinux.com/bbs/thread-7344-1-1.html
apache扩展模块安装 http://www.aminglinux.com/bbs/thread-848-1-1.html
如何指定使用worker/prefork http://www.lishiming.net/thread-944-1-1.html
apache 3种工作模式(默认2.2 为prefork, 2.4为event) http://www.cnblogs.com/fnng/archive/2012/11/20/2779977.html
apache的动态和静态 http://www.cnblogs.com/eoiioe/archive/2008/12/23/1360476.html(2.0和2.2一样) http://blog.sina.com.cn/s/blog_6238358c01017gdu.html
php5.5、5.6编译安装方法 http://www.aminglinux.com/bbs/thread-7284-1-1.html
httpd.conf详解 http://www.php100.com/html/webkaifa/apache/2009/0418/1192.html
本文出自 “岁月有痕” 博客,请务必保留此出处http://junnyzhang.blog.51cto.com/6023/1640898
标签:lamp环境搭建
原文地址:http://junnyzhang.blog.51cto.com/6023/1640898