CentOS 安装 PHP

分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net

1.获取PHP安装文件: downloads  或直接下载 php-5.5.9.tar.gz

获取安装php需要的支持文件: libxml2  或直接下载 libxml2-2.9.1.tar.gz

2.安装libxml2


tar zxvf libxml2-2.9.1.tar.gz
cd libxml2-2.6.32./configure --prefix=/usr/local/libxml2
make
make install

如果安装成功以后,在/usr/local/libxml2/目录下将生成bin、include、lib、man和share五个目录。在后面安装PHP5源代码包的配置时,会通过在configure命令的选项中加上"--with-libxml-dir=/usr/ local/libxml2"选项,用于指定安装libxml2库文件的位置。

3.安装php5

#tar zvxf php-5.3.8.tar.gz

#cd php-5.3.8
#./configure \
--prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-apxs=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2
#make
#make install 

4.重新配置apache2让他支持php

  • 配置 httpd.conf 让apache支持PHP:

  # vi /usr/local/apache/conf/httpd.conf

  找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容

  AddType application/x-httpd-php .php      (.前面有空格)

  AddType application/x-httpd-php-source .phps        (.前面有空格)

  • 然后CPOPY PHP的配置文件

  cp php-5.3.8/php.ini.dist /usr/local/php/lib/php.ini

(如果没有php.ini.dist 则把php.ini-development php.ini-production中的任何一个重命名为php.ini.dist即可。)

  修改php.ini文件 register_globals = On

  • 重启apache

  service apache restart

5.测试php是否成功安装

写一个php测试页info.php,放到apache2/htdocs中。

<?php

phpinfo();

?>;

在浏览器中输入:服务器地址/info.php

如果能正常显示出php的信息,则说明Apche+Mysql+PHP安装成功!

------------------------------

CentOS 5.5使用yum来安装LAMP

1. 换源,使用sohu安装源
1.1 备份CentOS-Base.repo 
cd /etc/yum.repos.d/ 
cp CentOS-Base.repo CentOS-Base.repo.bak 
1.2 替换源 
用vi打开CentOS-Base.repo,并将内容清空,然后将下面的内容复制进去,并保存。 
# CentOS-Base.repo 

# This file uses a new mirrorlist system developed by Lance Davis for CentOS. 
# The mirror system uses the connecting IP address of the client and the 
# update status of each mirror to pick mirrors that are updated to and 
# geographically close to the client. You should use this for CentOS updates 
# unless you are manually picking other mirrors. 

# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead. 


[base] 
name=CentOS-$releasever - Base 
baseurl=http://mirrors.sohu.com/centos/$releasever/os/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
#released updates 
[updates] 
name=CentOS-$releasever - Updates 
baseurl=http://mirrors.sohu.com/centos/$releasever/updates/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
#packages used/produced in the build but not released 
[addons] 
name=CentOS-$releasever - Addons 
baseurl=http://mirrors.sohu.com/centos/$releasever/addons/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
#additional packages that may be useful 
[extras] 
name=CentOS-$releasever - Extras 
baseurl=http://mirrors.sohu.com/centos/$releasever/extras/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
#additional packages that extend functionality of existing packages 
[centosplus] 
name=CentOS-$releasever - Plus 
baseurl=http://mirrors.sohu.com/centos/$releasever/centosplus/$basearch/ 
gpgcheck=1 
enabled=0 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
1.3更新一下 yum -y update

2. 用yum安装Apache、Mysql、PHP
2.1 安装Apache 
yum install httpd httpd-devel 
安装完成后,启动apache

/etc/init.d/httpd start 
设为开机启动:chkconfig httpd on 
2.2 安装mysql 
yum install mysql mysql-server mysql-devel 
完成后,启动mysql

/etc/init.d/mysqld start 
2.2.2 设置mysql密码

mysql -uroot
mysql> USE mysql; 
mysql> UPDATE user SET Password=PASSWORD(‘newpassword‘) WHERE user=‘root‘; FLUSH PRIVILEGES; 
2.2.3 允许远程登录 
mysql -u root -p 
Enter Password: <your new password> 
mysql>GRANT ALL PRIVILEGES ON *.* TO ‘username‘@‘%‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;  FLUSH PRIVILEGES; 
完成后就能用mysql-front远程管理mysql了。 
2.2.4 设为开机启动 
chkconfig mysqld on 
3. 安装php 
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml 
/etc/init.d/httpd start 
4. 测试一下 
4.1在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。 
<?php 
phpinfo(); 
?> 
4.2 防火墙配置 
a.添加.允许访问端口{21: ftp, 80: http}. 
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT 
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT 
b.关闭防火墙{不推荐}. 
service iptables stop 
c.重置加载防火墙 
service iptables restart 
4.3然后在客户端浏览器里打开http://serverip/test.php,若能成功显示,则表示安装成功。 
至此,安装完毕。感慨,yum真是太好用了。

PHP 升级

1.先查看当前php版本
#php -v

2.升级php版本
rpm --import http://repo.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy

wget -P /etc/yum.repos.d/ http://repo.webtatic.com/yum/webtatic.repo

yum --enablerepo=webtatic update php mysql
升级php最好是连mysql一起升级,好了可以看到php已经升级成5.3.28

3、查看升级后的php版本

#php -v

PHP 5.3.28 (cli) (built: Dec 15 2013 17:43:05) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

可以看到php的版本已经更新到5.3.X

重启 /etc/init.d/httpd restart 或 apache  service httpd restart

----------------------

升级 2(推荐)

1) 预安装

yum --enablerepo=remi,remi-php55 install php-pecl-apc php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

2) 升级php

yum --enablerepo=remi,remi-php55 install php-opcache

Unable to load dynamic library ‘/usr/lib64/php/modules/gd.so

[root@ithomer ~]# php -v
PHP Warning:  PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/gd.so‘ - libvpx.so.0: cannot map zero-fill pages: Cannot allocate memory in Unknown on line 0
PHP 5.5.9 (cli) (built: Feb 18 2014 14:51:49) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

解决:

How To Add Swap on CentOS 6

-----------------------------------------------------------

libcurl.so.3

Error: Package: php-common-5.3.28-2.w5.x86_64 (webtatic)
           Requires: libcurl.so.3()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

yum install libcurl libcurl-devel

----------------------------

MySQL 升级

CentOS 5.5的源mysql目前还停留在5.0.19上,要做数据库主从的时候,必须升级到5.1以上,索性直接到5.5.36

1、安装MySQL 5.5.x的yum源:

rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm

2、安装MySQL客户端的支持包:

yum install libmysqlclient15 --enablerepo=webtatic

3、卸载MySQL老版本的软件包:

yum remove mysql mysql-*

4、安装MySQL 5.5的客户端和服务端:

yum install mysql55 mysql55-server --enablerepo=webtatic

5、启动MySQL系统服务,更新数据库:

/etc/init.d/mysqld restart

mysql_upgrade -uroot -proot

升级完毕

/etc/init.d/mysqld restart

------------------------------------------------------------

升级 1(推荐)

To list Old MySql
yum list installed | grep -i mysql

To remove Old MySql
yum remove mysql mysql-*

Remi Dependency on CentOS 6 and Red Hat (RHEL) 6
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Install MySQL server
yum --enablerepo=remi,remi-test install mysql mysql-server

To list New MySql
yum list installed | grep -i mysql
start MySql server

/etc/init.d/mysqld start  ## use restart after update
OR
service mysqld start  ## use restart after update

chkconfig --levels 235 mysqld on

Last
mysql_upgrade -u root -p
Now my MySql version is 5.5.32

Ref:
http://www.webtatic.com/packages/mysql55/
http://www.if-not-true-then-false.com/2010/install-mysql-on-fedora-centos-red-hat-rhel/

update MySQL version from 5.1 to 5.5 in CentOS 6.2

Centos 使用YUM安装MariaDB

1、在 /etc/yum.repos.d/ 下建立 MariaDB.repo
$ cd /etc/yum.repos.d 
$ vim /etc/yum.repos.d/MariaDB.repo

添加如下配置:

# MariaDB 10.0 CentOS repository list - created 2013-08-23 13:08 UTC 
http://mariadb.org/mariadb/repositories/ 
[mariadb] 
name = MariaDB 
baseurl = http://yum.mariadb.org/10.0/centos6-amd64 
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 
gpgcheck=1

如果是其他的操作系统,可以在这里找到相关信息。

2、使用YUM安装MariaDB 
$ sudo yum -y install MariaDB-client MariaDB-server MariaDB-devel

3、启动数据库 
$ sudo service mysql start

4、修改Root的密码

$ mysqladmin -u root password ‘passwd’

5、配置远程访问,MariaDB为了安全起见,默认情况下绑定ip( 127.0.0.1)。

$ mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g. 
Your MariaDB connection id is 4 
Server version: 10.0.4-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘passwd’ WITH GRANT OPTION;

MariaDB [(none)]> flush privileges;

第一句中"%"表示任何主机都可以远程登录到该服务器上访问。如果要限制只有某台机器可以访问,将其换成相应的IP即可,如:

GRANT ALL PRIVILEGES ON *.* TO root@"172.168.193.25" IDENTIFIED BY "root";

第二句表示从mysql数据库的grant表中重新加载权限数据。因为MySQL把权限都放在了cache中,所以在做完更改后需要重新加载。

6、防火墙配置

如果系统的防火墙开着(or behind a hardware firewall or NAT)你必须放开mysql使用的TCP端口,通常都是3306。

7、大小写敏感

用root帐号登录后,在/etc/my.cnf 中的[mysqld]后添加添加lower_case_table_names=1,重启MYSQL服务,这时已设置成功:不区分表名的大小写;
lower_case_table_names参数详解:
lower_case_table_names = 0 
其中 0:区分大小写,1:不区分大小写

------------------------------------------------------------

ERROR 1045 (28000): Access denied for user ‘ithomer‘@‘localhost‘ (using password: YES)

/etc/init.d/mysqld stop
mysqld_safe --skip-grant-tables &
mysql -u root
mysql> use mysql;

mysql> grant all privileges on *.* to "root"@"%" identified by "password" with grant option;  flush privileges;    # 添加用户

mysql> grant Select on your_dbname.* to "username"@"%" identified by "password" with grant option;  flush privileges;    # 赋值只读权限(Select)
mysql> update user set password=PASSWORD("newrootpassword") where User=‘root‘;  flush privileges;    # 修改密码
mysql> quit
/etc/init.d/mysqld restart
/etc/init.d/mysqld stop
/etc/init.d/mysqld start

rpm安装

1.安装命令
rpm -ivh filename.rpm
参数解释
-i 安装
-h 解压rpm的时候打印50个斜条 (#)
-v 显示详细信息

2.升级命令
rpm -Uvh filename.rpm
参数解释
-U 升级
-h 解压rpm的时候打印50个斜条 (#)
-v 显示详细信息

rzsz安装

ubuntu: sudo apt-get install lrzsz

centos: yum -y install lrzsz

hostname修改

需修改两处:

1)vim  /etc/sysconfig/network 修改 HOSTNAME=your_hostname

2)vim  /etc/hosts  修改 12.160.134.168  your_hostname

Python 安装

1) 下载 Python, 直接下载 Python-2.7.6.tar.xz

2) 安装.tar.xz 解压工具: yum -y install xz

3) 解压.tar.xz文件: unxz Python-2.7.6.tar.xz     和   tar xvf Python-2.7.6.tar

4) cd Python-2.7.6

5) ./configure--prefix=/usr/local--enable-unicode=ucs4--enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"

make&&makealtinstall

pip 安装

1) wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py

2) python2.7ez_setup.py

3) easy_install-2.7pip

4) pip2.7install[packagename]

pip2.7install--upgrade[packagename]

pip2.7uninstall[packagename]

LAMP 配置截图

升级 3 —— httpd(apache server)

$ vi /etc/yum.repos.d/centalt.repo
[CentALT]
name=CentALT Packages for Enterprise Linux 6 - $basearch
baseurl=http://centos.alt.ru/repository/centos/6/$basearch/
enabled=1
gpgcheck=0

yum update httpd

参考: Upgrade apache/httpd to 2.2.23 in CentOS

安装 Git

通过命令 yum  install  git 安装的是老版本(1.7.1)

想安装最新的git,步骤如下:

1) yum install perl-DBI -y

2) wget http://pkgs.repoforge.org/git/git-1.7.10-1.el6.rfx.x86_64.rpm

wget http://pkgs.repoforge.org/git/perl-Git-1.7.10-1.el6.rfx.x86_64.rpm

3) rpm -i git-1.7.10-1.el6.rfx.x86_64.rpm perl-Git-1.7.10-1.el6.rfx.x86_64.rpm

4) git --version

git version 1.7.10

参考: 参考1参考2, github要求git在版本 1.7.6以上

 

安装 Subversion

1) 安装客户端, 命令: yum install subversion

Install SVN server in Centos 6.x

 

 

参考推荐:

Linux安装配置php

Ubuntu安装配置MySQL

CentOS 5.5使用yum来安装LAMP

Win7下安装Apache+PHP+MySQL

MySQL赋值用户权限GRANT用法(推荐)

WordPress的安装过程

WordPress数据库及各表结构

2) wget http://pkgs.repoforge.org/git/git-1.7.10-1.el6.rfx.x86_64.rpm

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net

原文地址:https://www.cnblogs.com/siwnckhhw/p/10525478.html

时间: 2024-07-30 08:19:27

CentOS 安装 PHP的相关文章

CentOS 安装redis 2.8.7

波折了好几下才装上 1.下载 wget http://download.redis.io/releases/redis-2.8.7.tar.gz 下载后的文件在当前目录里 redis-2.8.7.tar.gz 2.编译安装 tar xf redis-2.8.7.tar.gz cd redis-2.8.7 make make install 如果没有安装gcc的话会提示gcc not found 于是就需要安装一下gcc: yum -y install gcc 因为刚开始把yum的源换成163的了

centos安装gearman

centos安装gearman post by rocdk890 / 2012-8-4 1:11 Saturday linux技术 发表评论 今天公司让我在服务器上安装gearman,服务器环境是lamp,那gearman是什么?其实这个gearman是一个处理分布式过程通信的健壮系统.它提供了一个通用的应用程序框架,主要用来把任务转发给到其他机器或进程.使用Gearman 能让程序实现并行工作.负载均衡和跨语言调用.它能够用于不同类型的应用程序,从高可用的web站点到数据库复制传输. 系统:c

Centos 安装 禅道

Centos 安装  禅道 一.环境准备: 1.服务器:Centos6.7 新系统 2.查看对应的系统版本:uname -a和cat /etc/redhat CentOS release 6.7 (Final) 二.安装: 1.下载对应系统版本的zbox禅道一键安装包,解压至/opt目录下 从window  电脑 到下面的地址下载最新的禅道版本 https://sourceforge.net/projects/zentao/files/9.0.1/ZenTaoPMS.9.0.1.zbox_64.

centos安装net-speeder

以前介绍过VPS上安装锐速对VPS的加速效果,但是这货对 Linux 内核有要求,一般就只能在XEN或者KVM的机子上安装.不过还好锐速有一个免费的代替品:net-speeder,所以这里介绍一下 Debian/Ubuntu 上安装 net-speeder 并对 net-speeder 的夸张带宽占用做一些优化. 软件 Github 地址:net-speeder 安装过程: CentOS安装 wget --no-check-certificate https://gist.github.com/

CentOS安装桌面环境

相信很多人在学习linux的时候,看的教程(书,或视频),很多都是说,在安装系统的时候, 选择最小化安装,装好系统之后,需要什么软件就装什么软件.不去好好找找,是不会知道系统 默认会安装多少软件,软件安装的位置...当然,作为图形界面的桌面环境,服务器上是绝对 不会安装的,因为图像处理是最消耗计算机性能的软件,windows慢,也是因为这个原因了(这 句是发闹骚) 当然,在一个伟大的linux系统工程师,刚接触linux的时候,把linux作为自己日常使用的计算机( 特别是从winddow转过来

centos 安装memcache服务后memcahce本机连接Permission

自己手动在虚拟机下装了下memcache,整个过程真是充满波折,本身用php5.3安装memcache扩展就麻烦很多,无法通过yum直接安装,安装方法详见http://chenwei.me/blog/server/69.html,接下来安装memcache服务,安装成功后,telnet可以成功,不过好像不是立即成功生效,过一会用stats才会有详细显示. 本机用 <?php $mem = new Memcache; $mem->connect(‘192.168.124.129′,11211)

CentOS 安装软件时,错误Transaction check error ... file...conflicts with file from package zzz的解决

CentOS 安装软件时(比如:# yum install subversion),有时候会碰到类似如下的错误: Transaction check error: file /usr/lib64/libsvn_client-1.so.0.0.0 from install of subversion-1.8.11-1.x86_64 conflicts with file from package subversion-libs-1.7.14-7.el7_0.x86_64 file /usr/lib

centos 安装视频播放器mplayer

centos 桌面安装mplayer播放器看视频今天安装上centos 6.3 的 桌面环境来搭配 java开发环境.   完事之后,发现centos6.3 桌面程序应用中的 电视播放器 无法播放AVI 等视频(原来都是命令行) 本身centos 属于服务器系统 对于影音软件的集成 就比较 含蓄来.那我们就使用常用的mplayer 播放器来作为我们的视频播放器吧. 因为我装的系统是 64位的 所以 一下链接 都是64位的 第一: rpm -ivh [url=http://tree.repofor

CentOS安装MySQL问题汇总

遇到的错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) denied for user 'root'@'localhost' (using password: NO) 描述:刚安装完MySQL,第一次登陆. [[email protected] ~]$ mysql -u root -p Enter password: #我记得root初始是没密码的,这句直接回车 ERROR

centos 安装 pcre

#rpm -qa | grep pcre              //查询系统中有没有安装PCRE,一般装系统是默认装有,所以我们要删掉系统自带的 #cp /lib/libpcre.so.0 /            //在删除系统自带的PCRE之前,要先备份一下libpcre.so.0这个文件,因为RPM包的关联性太强,在删除后没libpcre.so.0这个文件时我们装PCRE是装不上的 #rpm -e --nodeps pcre-6.6-1.1           //删除系统自带的PCR