当前位置:8090st.com >环境搭建 > 查看文章
阿里云优惠码

系统环境centos6.5 32bit 系统为最小化安装

Mysql5.5.47 Apache2.2.31

yum install  bzip2 bzip2-devel libxml2-devel libcurl-devel  libjpeg-devel libpng-devel  freetype-devel  libmcrypt-devel 

一、安装mysql二进制包

1. 下载mysql到/usr/local/src/

cd /usr/local/src/ 
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.47-linux2.6-i686.tar.gz

2. 解压

[root@localhost src]# tar zxvf /usr/local/src//mysql-5.5.47-linux2.6-i686.tar.gz

3. 把解压完的数据移动到/usr/local/mysql

[root@localhost src]# mv mysql-5.5.47-linux2.6-i686.tar.gz /usr/local/mysql 

4. 建立mysql用户

[root@localhost src]# useradd -s /sbin/nologin mysql 

5. 初始化数据库

 
[root@localhost src]# cd /usr/local/mysql 
[root@localhost mysql]# mkdir -p /data/mysql ; chown -R mysql:mysql /data/mysql 
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql  

./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or director

yum install libaio-devel -y 然后重新初始化

–user 定义数据库的所属主, –datadir 定义数据库安装到哪里,建议放到大空间的分区上,这个目
录需要自行创建。这一步骤很关键,如果您看到两个 “OK” 说明执行正确,否则请仔细查看错误信息,

6. 拷贝配置文件

[root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnf 

7. 拷贝启动脚本文件并修改其属性

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld 
[root@localhost mysql]# chmod 755 /etc/init.d/mysqld 

8. 修改启动脚本

 
[root@localhost mysql]# vim /etc/init.d/mysqld 
需要修改的地方有 ``datadir=/data/mysql'' (前面初始化数据库时定义的目录)
 

9. 把启动脚本加入系统服务项,并设定开机启动,启动mysql

 
[root@localhost mysql]# chkconfig --add mysqld 
[root@localhost mysql]# chkconfig mysqld on 
[root@localhost mysql]# service mysqld start 

如果启动不了,请到 /data/mysql/ 下查看错误日志,这个日志通常是主机名.err. 检查mysql是否启动
的命令为:

[root@localhost mysql]# ps aux |grep mysqld 

10.设置环境变量

vi /etc/profile.d/path.sh
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile.d/path.sh

二、安装httpd
1.下载

wget   http://apache.fayea.com//httpd/httpd-2.2.31.tar.gz

解压

tar zxf httpd-2.2.31.tar.gz
cd httpd-2.2.31

./configure  --prefix=/usr/local/apache2 \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--enable-headers=shared \
--with-pcre \
--enable-ssl \
--with-ssl=/usr 

configure: error: in `/root/httpd-2.2.11/srclib/apr’:
configure: error: no acceptable C compiler found in $PATH

主要是没有安装gcc 编译器、解决办法是:yum install gcc -y

checking for zlib location… not found
checking whether to enable mod_deflate… configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

解决办法是: yum install zlib-devel -y

no SSL-C headers found
configure: error: …No recognized SSL/TLS toolkit detected

解决办法是: yum install openssl-devel -y

make
make install
/usr/local/apache2/bin/apachectl start

httpd: apr_sockaddr_info_get() failed for shiwei
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

vim /etc/hosts 加入主机名

vim /usr/local/apache2/conf/httpd.conf 将里面的 #ServerName localhost:80 注释去掉即可。

三、安装php
1.下载

wget http://mirrors.sohu.com/php/php-5.4.45.tar.gz
tar zxf php-5.4.45.tar.gz #解压
cd php-5.4.45



./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-mysqli=/usr/local/mysql/bin/mysql_config \
--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 \
--with-curl \
--with-openssl \
--with-zlib-dir \
--enable-ftp

checking for xml2-config path…
configure: error: xml2-config not found. Please check your libxml2 installation.
解决办法是:

yum install  libxml2-devel -y

checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution
解决办法:

yum install  bzip2 bzip2-devel -y

checking for cURL in default path… not found
configure: error: Please reinstall the libcurl distribution –
easy.h should be in /include/curl/
解决办法:

yum install libcurl-devel -y

configure: error: jpeglib.h not found.

解决办法:

yum install libjpeg-devel

configure: error: png.h not found.
解决办法:

yum install libpng-devel

configure: error: freetype-config not found.
解决办法:

yum install freetype-devel -y

configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决办法:

yum install libmcrypt-devel -y

make
make install

拷贝配置文件:

[root@localhost php-5.4.45]# cp php.ini-production /usr/local/php/etc/php.ini
apache结合php

Apache主配置文件为:/usr/local/apache2/conf/httpd.conf

vim /usr/local/apache2/conf/httpd.conf
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加:
AddType application/x-httpd-php .php
找到:

DirectoryIndex index.html

将该行改为:

DirectoryIndex index.html index.htm index.php

找到:
#ServerName www.example.com:80
修改为:
ServerName localhost:80
测试LAMP是否成功

启动apache之前先检验配置文件是否正确:

/usr/local/apache2/bin/apachectl -t

如果有错误,请继续修改httpd.conf, 如果是正确的则显示为 “Syntax OK”, 启动apache的命令为:

/usr/local/apache2/bin/apachectl start

查看是否启动:

[root@localhost ~]# netstat -lnp |grep httpd
tcp        0      0 :::80                       :::*   LISTEN      7667/httpd

如果有显示这行,则启动了。 也可以使用curl命令简单测试:
[root@localhost ~]# curl localhost

It works!

测试php

相关文章
为您推荐
各种观点
暂时还木有人评论,坐等沙发!
发表评论

快捷键:Ctrl+Enter