CentOS 64位 搭建LAMP环境

LAMP环境搭建
1. 准备环境
操作系统: CentOS 6.5 64位
准备安装:
httpd-2.4.12.tar
php-5.6.7.tar

其中用到的包有
pcre-8.36.tar.gz
apr-util-1.5.4.tar.gz
apr-1.5.1.tar.gz
zlib-1.2.7.tar.gz
freetype-2.5.5.tar.gz
libxml2-2.9.2.tar.gz
autoconf-2.69.tar.gz
php-5.6.7.tar.gz
httpd-2.4.12.tar.gz
libpng-1.6.17.tar.gz
libmcrypt-2.5.7.tar.gz
jpegsrc.v6b.tar.gz
libgd-2.1.1.tar.gz
mysql-advanced-5.6.23-linux-glibc2.5-i686.tar.gz
还有一些在安装过程中出现缺少的依赖包,就用yum去安装了。
Mysql采用的是压缩版,就是已经安装好的文件夹,解压出来,配置下就可以了。但是由于本机上缺少很多依赖库,又得下载安装,其实还不如用安装版的好,全都有了。
2. 前期准备
增加用户
Useradd mysql
Passwd mysql

由于我安装CentOS的时候,选择的是WEB Server,没有界面,所以要自己配置网卡信息

配置网卡
vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
HWADDR=00:0C:29:35:B3:78
TYPE=Ethernet
UUID=f39159c5-4d42-46b3-9c25-4c7ebda1aeb1
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
DNS1=192.168.1.1

IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

USERCTL=no
IPV6INIT=no
PEERDNS=yes

Service network restart
如果能够ping通内网,不能ping外网
那就是默认的网管没弄好
如果你ping的是广域网而不是局域网,那你还要确保网关和DNS设置正确
你可以按下面的步骤来设置网关
这条命令就可以搞定
route add default gw 192.168.1.1

安装vsftpd
http://blog.itpub.net/23277734/viewspace-1111004/

会产生的问题 500oops
http://www.cnblogs.com/lianche/archive/2013/06/20/3147017.html

记得关闭防火墙
Service iptables stop
永久关闭
chkconfig iptables off

Vsftpd 上传文件的时候遇到了550 permission denied vsftpd
解决办法
在配置文件中/etc/vsftpd/vsftpd.conf中的最后加上write_enable=yes
service vsftpd restart

由于原先系统中已经安装好Apache和PHP,但是版本不是最新的,我先测试了下原先系统的环境是否能够运行。

配置httpd和php的连接
/etc/httpd/conf/httpd.conf在配置文件的AddType application/x-gzip .gz .tgz之后加上
Addtype application/x-httpd-php .php .phtml
Addtype application/x-httpd-php-source .phps
添加上面绿色内容,表示apache服务中可以解析php格式文件
接下来要检查apache目录下生成的php动态连接库文件,在目录/usr/local/apache/modules,找到是否存在 libphp5.so文件
测试结果,能够跑通的,但是我要安装最新版本的。

  1. 开始安装
    我将所有的程序都安装在/usr/local/软件名字,./configure –prefix=/usr/local/xxx

1) 安装libxml2遇到的问题
libxml.c:14:20: error: Python.h: No such file or directory

尝试安装python
Yum install python 失败了,还是没装上
Yum install python-devel 成功了

2) 编译安装jpeg
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf jpegsrc.v8c.tar.gz
[root@centos6 LAMP]# cd ./jpeg-8c/
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/(创建jpeg软件的安装目录)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/bin/(创建存放命令的目录)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/lib/(创建jpeg库文件所在目录)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/include/(创建存放头文件目录)
[root@centos6 jpeg-8c]# mkdir -p /usr/local/jpeg/man/man1(建立存放手册的目录)
[root@centos6 jpeg-8c]#
./configure –prefix=/usr/local/jpeg/ –enable-shared –enable-static(建立共享库使用的GNU的libtool和静态库使用的GNU的libtool)
[root@centos6 jpeg-8c]# make ; make install

出现了libtool没有安装
解决 yum install libtool
还是不行
最后在jpeg的目录下/usr/local/src/jpeg-6b/
执行
cp /usr/share/libtool/config/config.sub .
cp /usr/share/libtool/config/config.guess .
将这两个文件覆盖,重新编译安装就好了。

3) 安装apache
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf httpd-2.2.19.tar.gz
[root@centos6 LAMP]# cd ./httpd-2.2.19
[root@centos6 httpd-2.2.19]#
./configure –prefix=/usr/local/apache/ –enable-so –enable-rewrite
[root@centos6 httpd-2.2.19]# make ; make install
[root@centos6 LAMP]# /usr/local/apache/bin/apachectl start
[root@centos6 LAMP]#
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@centos6 LAMP]# chmod +x /etc/init.d/httpd
[root@centos6 ~]# chkconfig –add httpd
注意:如果提示service httpd does not support chkconfig错误
解决办法:编辑/etc/rc.d/init.d/httpd在文件第二行加入
#chkconfig:2345 10 90
#description:Activates/Deactivates Apache Web Server
[root@centos6 ~]# chkconfig –level 2345 httpd on
[root@centos6 LAMP]# service httpd restart
开机自动启动apache的另一种方法:
修改/etc/rc.local文件

vim /etc/rc.local

在文件中添加/usr/local/apache/bin/apachectl start

出问题了,缺少apr
下载地址 http://apr.apache.org/download.cgi
安装过程中,出现了rm: cannot remove `libtoolT’: No such file or directory
解决办法,打开configure文件,查找 RM" cfgfile” ,找到之后在前面加上#注释掉,就可以了,重新执行 ./configure –prefix=/usr/local/apr

http://www.cnblogs.com/Anker/p/3355573.html

缺少APR-util
下载地址http://archive.apache.org/dist/apr/
执行 ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
Make && make install

缺少pcre
下载地址: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
./configure –prefix=/usr/local/pcre
Make && make install

安装Apache命令
./configure –prefix=/usr/local/apache –enable-rewrite –enable-so –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –with-pcre=/usr/local/pcre
Make && make install

找到安装的目录下
/usr/local/apache/bin
执行 ./apachectl start
关闭 ./apachectl stop

最好将它放在/ect/init.d/目录和/usr/sbin目录下
http://blog.chinaunix.net/uid-12461657-id-3024201.html

4) 安装mysql
[root@localhost mysql]# ./scripts/mysql_install_db –user=mysql
sh: ./bin/my_print_defaults: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
FATAL ERROR: Neither host ‘localhost.localdomain’ nor ‘localhost’ could be looked up with
./bin/resolveip
Please configure the ‘hostname’ command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the –force option

http://itlab.idcquan.com/linux/set/928509.html

环境:
[orangle@localhost Downloads]uname -m&&uname -r  
   x86_64  
   2.6.32-220.el6.x86_64  
   [orangle@localhost Downloads]
cat /etc/redhat-release
CentOS release 6.2 (Final)


使用的时候出现一个错误
bash: /usr/local/bin/rar: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

是因为64位系统中安装了32位程序
解决方法:
yum install glibc.i686

重新安装以后还有如下类系错误 再继续安装包

error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
yum install libstdc++.so.6

之后又碰到这个问题
/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
yum install libaio.so.1

再执行 ./scripts/mysql_install_db –user=mysql
成功

root@localhost mysql-5.6.14]# service mysql restart
ERROR! MySQL server PID file could not be found!
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
在日志中出现了如下错误:
Can’t open and lock privilege tables: Table ‘mysql.user’ doesn’t exist
后来采用了下面的语句就可以了:
scripts/mysql_install_db –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data –user=mysql –ldata=/var/lib/mysql

执行这个命令的./bin/mysqladmin -u root password ‘123456’的时候
Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)’
修改配置文件/ect/my.cnf
socket=/tmp/mysql.sock
可能是因为之前存在一个空格的原因,修改下就好了

[root@localhost mysql]# ./bin/mysql -u root -p
./bin/mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
办法: yum install libncurses.so.5
装完重新执行就OK了

5) 安装php
./configure –prefix=/usr/local/php/ –with-apxs2=/usr/local/apache/bin/apxs –with-libxml-dir=/usr/local/libxml2/ –with-jpeg-dir=/usr/local/jpeg/ –with-freetype-dir=/usr/local/freetype/–with-gd-dir=/usr/local/gd/–with-zlib-dir=/usr/local/zlib/–with-mcrypt=/usr/local/libmcrypt/–with-mysqli=/usr/local/mysql/bin/mysql_config –enable-soap –enable-mbstring=all –enable-sockets

  1. 配置文件
    安装好了之后
    cp php.ini-development /usr/local/php/lib/php.ini

vim /usr/local/php/lib/php.ini

其实不动这个配置也可以跑起来,我就修改了一个地方
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-zts-20131226”
这是扩展模块的地址,可以将这些扩展进来

配置Apache中的设置,让Apache能够解析php
vim /usr/local/apache/conf/httpd.conf

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在上面两个之后添加下面两个
Addtype application/x-httpd-php .php .phtml
Addtype application/x-httpd-php-source .phps
添加上面绿色内容,表示apache服务中可以解析php格式文件
接下来要检查apache目录下生成的php动态连接库文件,在目录/usr/local/apache/modules,找到是否存在 libphp5.so文件

  1. 验证
    [root@centos6 ~]# vi /usr/local/apache/htdocs/test.php
    添加内容为
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值