码迷,mamicode.com
首页 > 其他好文 > 详细

简单的lamp的搭建

时间:2019-03-06 19:17:50      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:cin   soap   浏览器   plain   bar   linux   tool   details   sha   

LAMP

 

一、MySQL安装

技术图片
[root@LAMP ~]# cd /usr/local/src
[root@LAMP src]# wget  http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.47-linux2.6-x86_64.tar.gz
[root@LAMP src]# tar zxvf mysql-5.5.47-linux2.6-x86_64.tar.gz
[root@LAMP src]# mv mysql-5.5.47-linux2.6-x86_64 /usr/local/mysql
[root@LAMP src]# useradd -s /sbin/nologin mysql  //建立MySQL账户,账号用来运行mysql服务
[root@LAMP src]# cd /usr/local/mysql   
[root@LAMP mysql]# mkdir -p /data/mysql   //创建datadir, 数据库文件都会放在这里面
[root@LAMP mysql]# chown -R mysql:mysql /data/mysql  //更改权限 并建立家目录
[root@LAMP mysql]# ./scripts/mysql_install_db --user=mysql
--datadir=/data/mysql   //初始化
[root@LAMP mysql]# cp support-files/my-large.cnf /etc/my.cnf   //拷贝配置文件
[root@LAMP mysql]# cp support-files/mysql.server /etc/init.d/mysqld  //拷贝启动脚本
[root@LAMP mysql]# chmod 755 /etc/init.d/mysqld //修改启动脚本的权限
[root@LAMP mysql]# vim /etc/init.d/mysqld  //修改启动脚本
...
...
basedir=
datadir=/data/mysql
...
...
[root@LAMP mysql]# chkconfig --add mysqld   //加入系统服务项
[root@LAMP mysql]# chkconfig mysqld on  //开机自启动
[root@LAMP mysql]# service mysqld start   //启动MySQL
[root@LAMP mysql]# ps aux|grep mysqld
技术图片

 

 

 

安装MySQL会遇到的错误 :

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 初始化时遇到的错误
 
1  ./bin/mysqld: error while loading shared libraries : libaio.so.1:cannot open shared object file:directory
 
--> yum install -y compat-libstdc++-33
--> yum install -y libaio
 
2.  ./scripts/mysql_install_db: ./bin/my_print_defaults:/lib/ld-linux.so.2:bad ELF interpreter:No such file or directory
 
-->Linux系统与MySQL版本不一致
 
3. ./scripts/mysql_install_db 没办法被补全
 
--> chmod +x mysql_install_db

  

 

 

===================== 我是分割线 。 ====================================

二、apache 安装

 

技术图片
[root@localhost mysql]# cd /usr/local/src/
[root@localhost src]# wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz
[root@localhost src]# tar zxvf httpd-2.2.16.tar.gz
[root@localhost src]# cd httpd-2.2.16
[root@localhost httpd-2.2.16]# ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre

[root@localhost httpd-2.2.16]# make //编译
[root@localhost httpd-2.2.16]# make install //安装
[root@localhost httpd-2.2.16]# echo $? //检查是否编译成功
0
!! --prefix //指定将Apache安装到哪里 --enable-so //启动DSO --enable-deflate=shared //共享方式编译deflate
技术图片

 

安装Apache遇到的错误:

 

技术图片
1.  checking for gcc ... no 

---> yum install -y gcc

2. configure: error: no acceptable C compiler found in $PATH
See `config.log‘ for more details
configure failed for srclib/apr

---> yum install -y apr apr-devel

3.  error: mod_deflate has been requested but can not be built due to prerequisite failures

---> yum install -y zlib-devel
技术图片

 

安装的版本如果是2.4请移到此处查看错误解答

===================== 我是分割线 。 ====================================

三、安装PHP

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#首先安装PHP依赖的安装包
[root@localhost httpd-2.2.16]# yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel perl libjpeg-devel
[root@localhost httpd-2.2.16]# cd /usr/local/src
[root@localhost src]# wget http://am1.php.net/distributions/php-5.3.27.tar.gz
[root@localhost src]# tar zxvf php-5.3.27.tar.gz
[root@localhost src]# cd php-5.3.27
[root@localhost php-5.3.27]# ./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
[root@localhost php-5.3.27]# make
[root@localhost php-5.3.27]# make install
[root@localhost php-5.3.27]# cp php.ini-production /usr/local/php/etc/php.ini //拷贝配置文件

  

 

安装php会遇到的错误:

 

技术图片
1. configure: error: xml2-config not found. Please check your libxml2 installation.

--> yum install -y libxml2-devel

2.    .configure: error: Cannot find OpenSSL‘s <evp.h>

--> yum install -y openssl openssl-devel

3.  checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

--> yum install -y bzip2 bzip2-devel

4. configure: error: png.h not found.

--> yum install -y libpng libpng-devel

5.  configure: error: freetype.h not found.

--> yum install -y freetype freetype-devel

6. configure: error: mcrypt.h not found. Please reinstall libmcrypt.

-->rpm -ivh "http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"
-->yum install -y libmcrypt-devel //因为centos6.x 默认的yum源没有libmcrypt-devel 这个包,只能借助第三方yum源 

7. Sorry ,I cannot run apxs. Possible reasons follow:

1.Perl is not installed

2.apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs

3.Apache was not not built using --enable-so (the apxs usage page is displayed)
The output of /usr/local/apache2/bin/apxs follows: ./configure: /usr/local/apache2/bin/apxs:

/replace/with/path/to/perl/interpreter: bad interpreter or directory configure:error:Aborting

--> yum install -y perl -->vim /usr/local/apache2/bin/apxs

找到关键字 ”/replace/with/path/to/perl/interpreter“

在第一个行 :#!/replace/with/path/to/perl/interpreter -w

perl的安装目录为/usr/bin/perl 所以将第一行修改为:#! /usr/bin/perl -w

-->./configure \

8. configure: error: jpeglib.h not found

--> yum install -y libjpeg-devel
技术图片

 

 

当看到字样 

Thank you for using PHP.

则安装成功!

 

===================== 我是分割线 。 ====================================

四、Apache结合php  提供服务

技术图片
[root@localhost ~]# vim /usr/local/apache2/conf/httpd.conf //apache的配置文件
...
...
AddType application/x-gzip .gz .tgz
//在该行下面增加
AddType application/x-httpd-php .php
...
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php //在此处增加htm和php
</IfModule>
 ...
#ServerName www.example.com:80 //改为 ServerName localhost:80
...
技术图片

 

===================== 我是分割线 。 ====================================

五、测试LAMP是否配置成功

 

技术图片
[root@localhost ~]# /usr/local/apa:che2/bin/apachectl -t  //Apache检验配置文件是否正确
Syntax OK 
[root@localhost ~]# /usr/local/apache2/bin/apachectl start  //启动Apache
[root@localhost ~]# netstat -lnp |grep httpd  //查看Apache是否启动
tcp        0      0 :::80                       :::*   LISTEN      7667/httpd
[root@localhost ~]# curl localhost  //curl命令简单测试
<html><body><h1>It works!</h1></body></html>
[root@localhost ~]# vim /usr/local/apache2/htdocs/1.php  //测试是否正确解析php
//写入
<?php
    echo "php works"  
?>
[root@localhost ~]# curl localhost/1.php
php works[root@localhost ~]#   //succeed

//初次使用浏览器访问我们的web服务的时候,你可能无法访问,这是因为防火墙的缘故。
[root@localhost ~]# iptables -F
[root@localhost ~]# setenforce 0

简单的lamp的搭建

标签:cin   soap   浏览器   plain   bar   linux   tool   details   sha   

原文地址:https://www.cnblogs.com/dengbingbing/p/10485213.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!