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真是太好用了。
Unable to load dynamic library '/usr/lib64/php/modules/gd.so
[iyunv@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
------------------------------------------------------------ 升级 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
$ 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