安装实战Linux_Nginx_PHP_MYSQl安装教程本人亲测可用,只要你按照步揍一步一步来一定能安装成功

php安装  时间:2021-02-23  阅读:()

安装步骤

系统要求 Linux 2.6+内核本文中的Linux操作系统为CentOS 5.3另在RedHat AS4上也安装成功

一、获取相关开源程序

1、【适用CentOS操作系统】利用CentOS Linux系统自带的yum命令安装、升级所需的程序库RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包进行安装 sudo-s

LA N G=Cyum-y install gcc gcc-c++autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devellibxml2 l ibxml2-devel zl ib zl ib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncursesncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel opensslopenssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

2、 【适用RedHat操作系统】 RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包事先可通过类似“rpm-qa |grep libjpeg”的命令查看所需的RPM包是否存在通常是“xxx-devel”不存在需要安装 。 Re d H at可以直接利用Ce nt OS的RP M包安装 以下是RP M包下载网址

①、 RedHat AS4&CentOS 4http://m irro rs.163.co m/ce ntos/4/os/i386/Ce nt OS/RP MS/http://m irro rs.163.co m/ce ntos/4/os/x86_64/Cent OS/RP MS/

②、 RedHat AS5&CentOS 5http://m irro rs.163.co m/ce ntos/5/os/i386/Ce nt OS/http://m irro rs.163.co m/ce ntos/5/os/x86_64/Cent OS/

③、 RP M包搜索网站h ttp://rp m.p bo ne.net/http://www.rp mfin d.n et/

④、 RedHat AS4系统环境通常情况下缺少的支持包安装

Ⅰ 、 i386系统wget http://blog.s135.com/soft/linux/nginx_php/rpm/i386/libjpeg-devel-6b-33. i386.rpmrpm-ivh l ibjpeg-devel-6b-33. i386.rpmw get htt p://b log.s135.co m/soft/lin ux/ng inx_ph p/rp m/i386/freetype-deve l-2.1.9-1. i386.rpmrp m-ivh freetype-deve l-2.1.9-1. i386.rp mwget http://blog.s135.com/soft/linux/nginx_php/rpm/i386/libpng-devel-1.2.7-1. i386.rpmrpm-ivh l ibpng-devel-1.2.7-1. i386.rpm

Ⅱ、 x86_64系统wget http://blog.s135.com/soft/linux/nginx_php/rpm/x86_64/libjpeg-devel-6b-33.x86_64.rpmrpm-ivh l ibjpeg-devel-6b-33.x86_64.rpmw get htt p://b log.s135.co m/soft/lin ux/ng inx_ph p/rp m/x86_64/freetype-d eve l-2.1.9-1.x86_64.rp mrp m-ivh freetype-deve l-2.1.9-1.x86_64.rpm

wget http://blog.s135.com/soft/linux/nginx_php/rpm/x86_64/libpng-devel-1.2.7-1.x86_64.rpmrpm-ivh l ibpng-devel-1.2.7-1.x86_64.rpm

3、 【适用Ce ntOS、 Red Hat及其它Lin ux操作系统】下载程序源码包

本文中提到的所有开源软件为截止到2010年07月26日的最新稳定版。

①、从软件的官方网站下载m kd ir -p/d at a0/softw a recd/data0/softwarewget http://sysoev.ru/nginx/nginx-0.8.46.tar.gzw get htt p://www.p h p.net/get/p h p-5.2.14.t a r.g z/fro m/t h is/m irro rwget htt p://php-fpm.org/dow n loads/ph p-5.2.14-fpm-0.5.14.d iff.gzw get htt p://dev.mysq l.co m/get/Dow n load s/MySQ L-5.5/mysq l-5.5.3-m3.tar.gz/fro m/http://mysq l.he.net/wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gzwget "htt p://dow n loads.sou rceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modt ime=&big_mirror=0"w get "htt p://dow n load s.so u rcefo rg e.net/mc rypt/mc rypt-2.6.8.tar.gz?modt ime=&big_mirro r=0"w get htt p://pecl.php.net/get/me mcache-2.2.5.tgzw get "htt p://dow n load s.so u rcefo rge.net/mhash/mhash-0.9.9.9.tar.gz?modt ime=&big_mirro r=0"wget ft p://ft p.csx.cam.ac.u k/pub/software/prog ramming/pcre/pcre-8.10.tar.gzw get htt p://bart.eacce le rator.net/sou rce/0.9.6.1/eacce le rato r-0.9.6.1.tar.bz2w get htt p://pe c l.p hp.net/get/P DO_MY SQ L-1.0.2.t g zwget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gzw get htt p://pecl.p hp.net/get/imag ick-2.3.0.tgz

②、从blog.s135.com下载比较稳定只允许在本站或者在Linux/Unix下通过Wget、 Cu rl等命令下载以下软件 m kd ir -p/d at a0/softw a recd/data0/softwarewget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.46.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.14.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gzwget http://blog.s135.com/soft/linux/nginx_php/mysq l/mysq l-5.5.3-m3.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.1.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgzwget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgzwget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.3.0.tgz

二、安装PHP 5.2.14FastCGI模式

1、编译安装PHP5.2.14所需的支持库tar zxvf libiconv-1.13.1.tar.gzcd libiconv-1.13.1/

./co n fig u re--p re fix=/u sr/loca lm a kemake installcd . ./tar zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8/

./co nfig u rem a kemake install

/sbin/ldconfigcd libltdl/

./config u re--e nable-ltd l-installm a kemake installcd . ./. ./tar zxvf mhash-0.9.9.9.tar.gzcd mhash-0.9.9.9/

./co nfig u rem a kemake installcd . ./ln -s/usr/local/l ib/l ibmcrypt. la/usr/lib/libmcrypt. laln -s/usr/local/l ib/l ibmcrypt.so/usr/lib/libmcrypt.soln -s/usr/local/l ib/l ibmcrypt.so.4/usr/lib/libmcrypt.so.4ln -s/usr/local/l ib/l ibmcrypt.so.4.4.8/usr/lib/l ibmcrypt.so.4.4.8ln -s/usr/local/l ib/l ibmhash.a/usr/lib/l ibmhash.aln -s/usr/local/l ib/l ibmhash. la/usr/l ib/l ibmhash. laln -s/usr/local/l ib/l ibmhash.so/usr/lib/l ibmhash.soln -s/usr/local/l ib/l ibmhash.so.2/usr/lib/l ibmhash.so.2ln -s/usr/local/l ib/l ibmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1ln -s/usr/local/bin/l ibmcrypt-config/usr/bin/libmcrypt-configtar zxvf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8/

/sbin/ldconfig

./co nfig u re

m a kemake installcd . ./

2、编译安装MySQL 5.5.3-m3

/usr/sbin/groupadd mysql

/usr/sbin/use radd -g mysq l mysq ltar zxvf mysql-5.5.3-m3.tar.gzcd mysql-5.5.3-m3/

./co nfig u re--p refix=/u sr/local/w ebse rve r/mysq l/ --enab le-asse m b le r --w it h-ext ra-c harsets=co m p lex--e nable-t h read-safe-clie nt --w it h-big-tab les--w it h-read line--w it h-ssl --w it h-e mbedded-se rve r--enable-local-infi le--with-plugins=partition,innobase,myisammrgmake&&make installch mod+w/usr/local/webse rve r/mysq lchown -R mysql :mysq l/usr/local/webserver/mysqlcd . ./

附 以下为附加步骤如果你想在这台服务器上运行MySQL数据库则执行以下几步。如果你只是希望让PHP支持MySQL扩展库能够连接其他服务器上的MySQL数据库那么 以下两步无需执行。

①、创建MySQL数据库存放目录mkdir -p/data0/mysql/3306/data/mkdir -p/data0/mysql/3306/binlog/mkdir -p/data0/mysq l/3306/relaylog/chown -R mysql :mysq l/data0/mysql/

②、 以mysq l用户帐号的身份建立数据表

/usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql

--datadir=/data0/mysql/3306/data --user=mysql

③、创建my.cnf配置文件vi/data0/mysq l/3306/my.cnf

输入以下内容

引用

[client]c h a racte r-set-se rve r=ut f8port =3306

so c ket =/t m p/mysq l.soc k

[mysq ld]c h a racte r-set-se rve r=ut f8re plicate-ig nore-db=mysq lreplicate-ig nore-db=testre plicate-ig nore-db=information_sche mau se r =mysq lport =3306so c ket =/t m p/mysq l.soc kbasedir=/usr/local/webserver/mysqldatadir=/data0/mysql/3306/datalog-e rro r=/d ata0/mysq l/3306/mysq l_e rro r. logpid-fi le=/data0/mysq l/3306/mysq l.pidope n_files_lim it = 10240back_log=600max_connections=5000max_connect_errors=6000table_cache=614external-locking=FALSEmax_al lowed_packet=32Mso rt_b u ffe r_size=1 Mjoin_buffer_size= 1 Mthread_cache_size=300

#thread_concurrency=8query_cache_size=512Mquery_cache_lim it=2Mquery_cache_min_res_unit=2kdefau lt-storage-eng ine=MyISAMthread_stack=192Kt ransact io n_iso lat io n=READ-CO MMITTEDt m p_tab le_size=246 Mmax_heap_tab le_size=246 Mlong_query_time=3log-slave-u pdateslog-bin=/data0/mysql/3306/binlog/binlogbin log_cache_size=4Mbin log_format=MIXEDmax_bin log_cache_size=8Mmax_bin log_size= 1 Gre lay-log-ind ex=/d ata0/mysq l/3306/re laylog/re laylogre lay-log-info-fi le=/d ata0/mysq l/3306/re laylog/re laylogre lay-log=/d ata0/mysq l/3306/re laylog/re laylogexpire_logs_days=30

key_b u ffe r_size=256 Mread_buffe r_size= 1 Mre ad_rn d_b u ffe r_size=16 Mbu lk_inse rt_buffe r_size=64Mmyisa m_so rt_buffe r_size= 128 Mmyisa m_max_so rt_file_size=10Gmyisa m_repair_threads= 1myisam_recoverinte ract ive_t imeout= 120w ait_t imeo ut= 120skip-n a me-re so lve

#master-connect-retry=10slave-skip-e rro rs= 1032,1062,126,1114,1146,1048,1396#master-host = 192.168.1.2

#master-user = username

#maste r-passw o rd= passw o rd

#master-port = 3306se rve r-id= 1innodb_additional_mem_pool_size= 16Minnod b_buffer_pool_size=512 Minnodb_data_file_path=ibdata1:256M:autoextendinnodb_file_io_threads=4innodb_thread_concurrency=8innodb_flush_log_at_trx_commit=2innod b_log_buffer_size= 16Min nod b_log_file_size= 128Minnodb_log_files_in_group=3innodb_max_dirty_pages_pct=90innodb_lock_wait_timeout= 120innodb_file_per_table=0

#log-slow-q ue ries=/data0/mysq l/3306/slow. log#long_query_time=10

[mysq ld u mp]q u ic kmax_al lowed_packet=32M

④、创建管理MySQL数据库的shell脚本vi/data0/mysq l/3306/mysq l

输入以下内容这里的用户名admin和密码接下来的步骤会创建 

#!/bin/shmysq l_port=3306mysql_username="admin"mysq l_passw o rd=""fu nct io n_start_mysq l()

{printf "Starting MySQL. . .\n"

/bin/sh/usr/local/we bse rve r/mysq l/bin/mysq ld_safe

--defaults-file=/data0/mysql/${mysql_port}/my.cnf 2>&1>/dev/null&

}fu nct io n_sto p_mysq l()

{printf "Stoping MySQL. . .\n"

/usr/local/we bse rve r/mysq l/bin/mysq lad min -u ${mysq l_use rname}-p${mysq l_password}-S/t mp/mysq l.sock sh utdow n

}fu n ct io n_re st art_mysq l()

{printf "Restarting MySQL. . .\n"function_stop_mysq lsleep 5function_start_mysq l

}fu nction_kill_mysq l()

{kill -9$(ps-ef|g rep'bin/mysq ld_safe' |g re p${mysq l_po rt} |aw k'{printf$2}')kill -9$(ps-ef|g rep' libexec/mysq ld' |g rep${mysq l_port} |aw k'{printf$2}')}if [ "$1"="start" ]; thenfunction_start_mysq le lif [ "$1"="sto p" ]; t he nfunction_stop_mysq l

e lif [ "$1"="restart" ]; t he nfu n ct io n_re st art_mysq lelif [ "$1"="kill" ]; thenfu nction_kill_mysq le lseprintf "Usage: /data0/mysq l/${mysq l_port}/mysq l{start|stop|restart|kill}\n"fi

⑤、赋予shell脚本可执行权限ch mod+x/data0/mysq l/3306/mysq l

⑥、启动MySQL

/data0/mysq l/3306/mysq l start

⑦、通过命令行登录管理MySQL服务器提示输入密码时直接回车 

/usr/local/webserver/mysq l/bin/mysq l -u root -p-S/tmp/mysql.sock

⑧、输入以下SQL语句创建一个具有root权限的用户admin和密码  

GRANT ALL PRIVILEGES ON*.*TO'admin'@' localhost' IDENTIFIED BY'';

GRANT ALL PRIVILEGES ON*.*TO'admin'@'127.0.0.1' IDENTIFIED BY' ';

⑨、 可选停止MySQL

/data0/mysq l/3306/mysq l stop

3、编译安装PHP FastCGI模式tar zxvf php-5.2.14.tar.gzgzip-cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14-p1cd php-5.2.14/

./config u re--prefix=/usr/local/webse rve r/ph p--w ith-config-file-pat h=/usr/local/webse rve r/ph p/etc--w it h-mysq l=/usr/local/we bse rve r/mysq l --w it h-mysq li=/usr/local/webse rve r/mysq l/bin/mysq l_config--w ith-iconv-d ir=/usr/local --w ith-freetype-d ir --w ith-jpeg-dir --w ith-png-d ir --w ith-zl ib

--w ith-libxml-dir=/usr --enable-xml --d isab le-rpath --enable-discard-path--enable-safe-mode--enable-bcmath --enable-shmop--enable-sysvsem--enable-inl ine-optimization --w ith-curl--w it h-cu rlw rap pe rs--e nable-mb regex--e nable-fastcg i --e nab le-fpm--e nable-fo rce-cg i-red irect--e nable-mbst ring --w ith-mcrypt --w ith-gd --enable-gd-nat ive-ttf--w ith-ope nssl --w it h-mhash--enable-pcntl --enable-sockets--w ith-ldap--w ith-ldap-sasl --w ith-xmlrpc --enable-zip--enable-soapmake ZEND_EXTRA_LIBS='-liconv'make install

cp php. ini-dist /usr/local/webserver/php/etc/php. inicd . ./

4、编译安装P H P5扩展模块tar zxvf memcache-2.2.5.tgzcd memcache-2.2.5/

/usr/local/webserver/php/bin/phpize

./configure--with-php-config=/usr/local/webserver/php/bin/php-configm a kemake installcd . ./tar jxvf eaccele rator-0.9.6.1.tar.bz2cd eaccelerator-0.9.6.1/

/usr/local/webserver/php/bin/phpize

./config u re--e nable-eacce le rator=shared --w it h-php-config=/usr/local/webse rve r/ph p/bin/ph p-configm a kemake installcd . ./tar zxvf PDO_MYSQL-1.0.2.tgzcd PDO_MYSQL-1.0.2/

/usr/local/webserver/php/bin/phpize

./configure--with-php-config=/usr/local/webserver/php/bin/php-config

--w it h-pdo-mysq l=/usr/local/we bse rve r/mysq lm a kemake installcd . ./tar zxvf ImageMagick.tar.gzcd ImageMagick-6.5.1-2/

./co nfig u rem a kemake installcd . ./tar zxvf imagick-2.3.0.tgzcd imagick-2.3.0/

/usr/local/webserver/php/bin/phpize

./configure--with-php-config=/usr/local/webserver/php/bin/php-configm a ke

Vultr新用户省钱福利,最新可用优惠码/优惠券更新

如今我们无论线上还是线下选择商品的时候是不是习惯问问是不是有优惠活动,如果有的话会加速购买欲望。同样的,如果我们有准备选择Vultr商家云服务器的时候,也会问问是不是有Vultr优惠码或者优惠券这类。确实,目前Vultr商家有一些时候会有针对新注册用户赠送一定的优惠券活动。那就定期抽点时间在这篇文章中专门整理最新可用Vultr优惠码和商家促销活动。不过需要令我们老用户失望的,至少近五年我们看到Vu...

无忧云( 9.9元/首月),河南洛阳BGP 2核 2G,大连BGP线路 20G高防 ,

无忧云怎么样?无忧云服务器好不好?无忧云值不值得购买?无忧云,无忧云是一家成立于2017年的老牌商家旗下的服务器销售品牌,现由深圳市云上无忧网络科技有限公司运营,是正规持证IDC/ISP/IRCS商家,自营有国内雅安高防、洛阳BGP企业线路、香港CN2线路、国外服务器产品等,非常适合需要稳定的线路的用户,如游戏、企业建站业务需求和各种负载较高的项目,同时还有自营的高性能、高配置的BGP线路高防物理...

香港服务器促销:香港华为云混合服务器、高防服务器首月半价,普通110M大带宽服务器月付799,付5用6,付10用13

博鳌云是一家以海外互联网基础业务为主的高新技术企业,运营全球高品质数据中心业务。自2008年开始为用户提供服务,距今11年,在国人商家中来说非常老牌。致力于为中国用户提供域名注册(国外接口)、免费虚拟主机、香港虚拟主机、VPS云主机和香港、台湾、马来西亚等地服务器租用服务,各类网络应用解決方案等领域的专业网络数据服务。商家支持支付宝、微信、银行转账等付款方式。目前香港有一款特价独立服务器正在促销,...

php安装为你推荐
个性qq资料QQ个性资料网站联盟网站联盟的运作流程申请证书手机申请证书网易公开课怎么下载如何将网易公开课下载到电脑上?godaddyGO DADDY服务器空间域名怎么样qq空间打扮QQ空间怎么打扮如何打扮lockdowndios8.1怎么激活内置卡贴宕机宕机是什么意思?如何清理ie缓存怎么样清理IE缓存?微信怎么看聊天记录微信在手机上怎么查看聊天记录
备案域名查询 php主机租用 免费动态域名解析 什么是域名地址 512m debian源 dropbox网盘 服务器架设 我爱水煮鱼 数字域名 老左来了 服务器是干什么的 爱奇艺vip免费试用7天 中国电信宽带测速网 流媒体加速 卡巴斯基是免费的吗 银盘服务 linode支付宝 lamp怎么读 lamp是什么意思 更多