liunx安装Lamp

  • 时间:
  • 来源:

   

1、安装Apache

[root@localhost ~]# yum -y install httpd

20140308164024_2956.jpg

# 开机自启动

[root@localhost ~]# chkconfig httpd on

# 启动httpd 服务

[root@localhost ~]# service httpd start

### 安装apache 一些扩展

root@localhost ~]# yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
应该会看到Apache的测试页面

这里需要注意iptables(如果是在虚拟主机装,在本机访问的话就要关闭防火墙chkconfig iptables off)

 

2、安装配置MySQL

# mysql 客户端程序

# mysql-server 服务端程序

# mysql-devel 开发设计的库

[root@localhost ~]# yum -y install mysql mysql-server mysql-devel

# 开机启动

[root@localhost ~]# chkconfig mysqld on

# 启动mysqld服务

[root@localhost ~]# service mysqld start

# 进行一些安全性配置

[root@localhost ~]# /usr/bin/mysql_secure_installation

[root@localhost ~]# netstat -tulpn | grep -i mysql

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1723/mysqld
OK, 我们看到mysqld已经启动,监听在3306端口上。

3.安装php5.6版本

由于centOS6.5的源php版本都比较低(php5.3),所以现在需要更换源

a.检查当前安装的PHP包

yumlistinstalled|grepphp

如果有安装的PHP包,先删除他们

yumremovephp.x86_64php-cli.x86_64php-common.x86_64php-gd.x86_64php-ldap.x86_64php-mbstring.x86_64php-mcrypt.x86_64php-mysql.x86_64php-pdo.x86_64

配置yum源

追加CentOS 6.5的epel及remi源。

1

2

 

以下是CentOS 7.0的源。

1

2

#yuminstallepel-release

#rpm-ivhmillecollet.com/enterprise/remi-release-7.rpm

使用yum list命令查看可安装的包(Packege)。

1

#yumlist--enablerepo=remi--enablerepo=remi-php56|grepphp

安装PHP5.6.x

yum源配置好了,下一步就安装PHP5.6。

1

#yuminstall--enablerepo=remi--enablerepo=remi-php56phpphp-opcachephp-develphp-mbstringphp-mcryptphp-mysqlndphp-phpunit-PHPUnitphp-pecl-xdebugphp-pecl-xhprof

用PHP命令查看版本。

1

2

3

4

5

6

#php--version

PHP5.6.0(cli)(built:Sep3201419:51:31)

Copyright(c)1997-2014ThePHPGroup

ZendEnginev2.6.0,Copyright(c)1998-2014ZendTechnologies

withZendOPcachev7.0.4-dev,Copyright(c)1999-2014,byZendTechnologies

withXdebugv2.2.5,Copyright(c)2002-2014,byDerickRethans

安装PHP-fpm

yuminstall--enablerepo=remi--enablerepo=remi-php56php-fpm

PS:

重启httpd服务报错

httpd: Could not reliably determine the server\'s fully qualified domain name

解决:vi/etc/httpd/conf/http.conf

修改ServerNamelocalhost:80 注释即可,然后重启httpd

启动httpd 报错 NameVirtualHost *:80 has no VirtualHost

解决:因为在http.conf的打开NameVirtualHost *:80 前的注释,然后再进入conf.d文件夹里面的配置时,还有同样的NameVirtualHost *:80存在,那就会报错(多台虚拟主机)