centos php mysql 扩展(centos 安装python)
centos怎么运行perl脚本
同样的网站程序在Linux下运行要比在windows下快出不少,所以决定使用Linux的发行版CentOS,本文主要讲解在CentOS下使用yum命令安装LAMP详细过程。我们使用的软件是CentOS的最新版本CentOS6.3,其他版本的也基本类似。第一步:更新系统内核(如果不想更新可以跳过本步)。首先更新系统内核到最新,因为最新版的CentOS6.3的php版本为5.3,早起版本的CentOS的php版本也比较低。执行命令:yum-yupdate注意:如果执行失败报错,可以执行修复命令:rpm–import/etc/pki/rpm-gpg/RPM-GPG-KEY*第二步:安装Apahce、Mysql、PHP及其基础扩展。执行命令:yum-yinstallhttpdphpphp-mysqlmysqlmysql-server第三步:安装PHP的其他常用扩展执行命名:yum-yinstallphp-gdphp-xmlphp-mbstringphp-ldapphp-pearphp-xmlrpc第四步:安装Apache的扩展执行命令:yum-yinstallhttpd-manualmod_sslmod_perlmod_auth_mysql执行完这四步软件就安装完成了,接下来要做一些常规的设置。第五步:设置apache/mysql-server环境开机自动启动执行命令:#设置apache为开机自启动/sbin/chkconfighttpdon#添加mysql服务/sbin/chkconfig--addmysqld#设置mysql为开机自启动/sbin/chkconfigmysqldon第六步:启动apache与msyql分别执行命令:servicehttpdstartservicemysqldstart第七步:设置mysql数据库root帐号密码mysqladmin-urootpassword'mysql的管理员密码'第八步:安装phpmyadmin从phpmyadmin官方网站:/下。解压phpmyadmin压缩包后,找到config.sample.inc.php重命名为config.inc.php,修改配置,就安装完成了。
CentOSyumphpmcrypt扩展安装方法
使用 yum install php-mcrypt安装mcrypt扩展时会提示没有安装包
Setting up Install Process
No package php-mcrypt available.
Error: Nothing to do
mcrypt是加密扩展库,加载了它可以用他里面自带的22种加密解密算法
CentOS6默认安装的是php5.3.2
默认的 redhat repos php中是没有 mcrypt扩展的
根据红帽的官方消息()RHEL不打算添加PHP的mcrypt的支持
Joe Orton 2010-08-05 04:47:17 EDT
Thanks for the report.
We are not planning to ship mcrypt support for PHP.
解决方法:
从php官网下载新的php 5.3源码包后,解压到本地目录
进入解压目录下的 ext目录后会发现有 mcrypt,
进入 mcrypt目录
#cd/ext/mcrypt
#phpize
注意:如果报-bash:phpize not Found那么 yum install php-devel就可以使phpize进行动态编译安装扩展
#./configure-with-php-config=/usr/sbin/php/bin/php-config
#make&& make install
出现:
----------------------------------------------------------------------
Libraries have been installed in:
/var/php-5.3.10/ext/mcrypt/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath-Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run'make test'.
Installing shared extensions:/usr/lib64/php/modules/
查看:
# php-m
...
libxml
mbstring
mcrypt
mysql
...
[Zend Modules]
已安装成功!
再次查看 phpinfo,可以看到mcrypt扩展详情。
centos5 源码安装Nginx + mysql + apache + php的方法
主要依照的是张宴的一篇博文《》,安装的软件是也是从他提供的列表中下载,这里都是tar.gz格式,如果更希望是rpm格式的话,提供一个网址《》这里列出了比较完全的下载包。
我安装的系统:Centos5
1、下载;
我安装的下载来自张宴博文下的地址,下载保存的是home下自己目录的一个文件夹下:
复制代码
代码如下:
cd/home/xuxx/software
wget
wget
wget
wget
wget
wget
wget
wget
wget
wget
wget
wget
wget
wget
2、准备编译安装环境,需要编译源码用到gc++
建议如果是新安装的系统,使用yum upgrade更新下系统。
复制代码
代码如下:
sudo-s
LANG=C
yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel
glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
openldap openldap-devel nss_ldap openldap-clients openldap-servers
注意:这里所有的命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符
确保安装成功!才能正确使用编译。
3、安装:
一、安装PHP 5.2.8(FastCGI模式)
1、编译安装PHP 5.2.8所需的支持库:
1] libiconv库
复制代码
代码如下:
tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure--prefix=/usr/local
make
make install
make clean
make distclean
cd../
make clean和make distclean都是删除安装过程中生成的缓存文件。当然如果你不介意放着也可以跳过这两步清理操作。
2]libmcrypt库
复制代码
代码如下:
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
make clean
make distclean
/sbin/ldconfig
cd libltdl/
./configure--enable-ltdl-install
make
make install
make clean
make distclean
cd
3] mhash库
复制代码
代码如下:
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd../
4]mcrypt库
注意:因为该库和libmcrypt有依赖性,所以在安装前必须知道libmcrypt,否则的话会出现:
错误
复制代码
代码如下:
checking for libmcrypt– version= 2.5.0…
***‘libmcrypt-config–version’ returned 2.4.0, but LIBMCRYPT(2.5.8)
*** was found! If libmcrypt-config was correct, then it is best
*** to remove the old version of LIBMCRYPT. You may also be able to fix the error
*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing
***/etc/ld.so.conf. Make sure you have run ldconfig if that is
*** required on your system.
*** If libmcrypt-config was wrong, set the environment variable LIBMCRYPT_CONFIG
*** to point to the correct copy of libmcrypt-config, and remove the file config.cache
*** before re-running configure
configure: error:*** libmcrypt was not found
是因为path的问题,所以执行:
复制代码
代码如下:
ln-s/usr/local/lib/libmcrypt.la/usr/lib/libmcrypt.la
ln-s/usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.so
ln-s/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4
ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.4.8
ln-s/usr/local/lib/libmhash.a/usr/lib/libmhash.a
ln-s/usr/local/lib/libmhash.la/usr/lib/libmhash.la
ln-s/usr/local/lib/libmhash.so/usr/lib/libmhash.so
ln-s/usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2
ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1
ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
然后再安装:
复制代码
代码如下:
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd../
二、安装mysql
复制代码
代码如下:
/usr/sbin/groupadd mysql
/usr/sbin/useradd-g mysql xxx
unzip mysql-5.1.33.zip
cd mysql-5.1.33/
./configure--prefix=/usr/local/webserver/mysql/--enable-assembler--with-extra-charsets=complex--enable-thread-safe-client--with-big-tables
--with-readline--with-ssl--with-embedded-server--enable-local-infile--with-plugins=innobase
make
make install
make clean
make distclean
chmod+w/usr/local/webserver/mysql
chown-R xxx:mysql/usr/local/webserver/mysql
cp support-files/my-medium.cnf.sh/usr/local/webserver/mysql/my.cnf
cd../
注意:这里编译./configure命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符
在最后一步拷贝的时候,我安装完在support-files下没有my-medium.cnf而只有my-medium.cnf.sh所以将这个文件拷贝过去。
@张宴原文:
附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,则执行以下两步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下两步无需执行。
①、以xxx用户帐号的身份建立数据表:
复制代码
代码如下:
/usr/local/webserver/mysql/bin/mysql_install_db--basedir=/usr/local/webserver/mysql--datadir=/usr/local/webserver/mysql/data--user=xxx
②、启动MySQL(最后的表示在后台运行)
复制代码
代码如下:
/bin/sh/usr/local/webserver/mysql/bin/mysqld_safe--defaults-file=/usr/local/webserver/mysql/my.cnf
3、编译安装PHP(FastCGI模式)
复制代码
代码如下:
tar zxvf php-5.2.8.tar.gz
gzip-cd php-5.2.8-fpm-0.5.10.diff.gz| patch-d php-5.2.8-p1
cd php-5.2.8/
./configure--prefix=/usr/local/webserver/php--with-config-file-path=/usr/local/webserver/php/etc--with-mysql=/usr/local/webserver/mysql
--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config--with-iconv-dir=/usr/local--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib
--with-libxml-dir=/usr--enable-xml--disable-rpath--enable-discard-path--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem
--enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--enable-fastcgi--enable-fpm--enable-force-cgi-redirect
--enable-mbstring--with-mcrypt--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-ldap
--with-ldap-sasl
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist/usr/local/webserver/php/etc/php.ini
cd../
注意:这里./configure命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符
4、编译安装PHP5扩展模块--可选安装
复制代码
代码如下:
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
make clean
make distclean
cd../
tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/webserver/php/bin/phpize
./configure--enable-eaccelerator=shared--with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
make clean
make distclean
cd../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config--with-pdo-mysql=/usr/local/webserver/mysql
make
make install
make clean
make distclean
cd../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
make clean
make distclean
cd../
tar zxvf imagick-2.2.2.tgz
cd imagick-2.2.2/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
make clean
make distclean
cd../
5、修改php.ini文件
STRONG手工修改:/STRONG查找/usr/local/webserver/php/etc/php.ini中的extension_dir="./"
修改为extension_dir="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
并在此行后增加以下几行,然后保存:
extension="memcache.so"
extension="pdo_mysql.so"
extension="imagick.so"
再查找output_buffering= Off
修改为output_buffering= On
6、配置eAccelerator加速PHP:
mkdir-p/usr/local/webserver/eaccelerator_cache
vi/usr/local/webserver/php/etc/php.ini
按shift+g键跳到配置文件的最末尾,加上以下配置信息:
复制代码
代码如下:
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
修改配置文件:
vi/etc/sysctl.conf
kernel.shmmax= 134217728
然后执行以下命令使配置生效:/sbin/sysctl-p
以下的步骤和张宴步骤中一样配置,不再赘诉