apache支持 php centos centos怎么用
如何在CentOS6下实现Apache+PHP+MySQL的快速安装
LAMP是一个免费、开源的解决方案,代表了Linux、Apache、MySQL、PHP,主要用作建立可行的通用的web服务器。那么如何在CentOS6下实现安装Apache+php+Mysql的快速安装?其具体安装配置步骤可以如下进行:
1.准备工作
使用yum进行安装,为了提高速度,最好先是修改为中国CentOS镜像服务器。目前国内有三个镜像可以选择,分别是:中国科学技术大学、163和Sohu的镜像,建议教育网用户选择中科大,电信用户选择163,他们的repo文件本博客作了备份如下:
下面命令是备份CentOS-Base.repo文件,并修改使用163镜像作为yum源:
mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.save
wget
mv CentOS6-Base-163.repo/etc/yum.repos.d/CentOS-Base.repo
2.更新系统内核
yum-y update
3.安装Apahce、Mysql、PHP
yum-y install httpd php mysql mysql-server
默认情况下,mysql数据目录位于/var/lib/mysql
4.安装相关组件:
yum install php-mysql php-gd php-imap php-ldap php-odbc
php-pear php-xml php-xmlrpc
5.安装MySQL管理工具phpMyAdmin
yum-y install phpMyAdmin
6.配置Apache随系统启动
chkconfig--levels 235 httpd on
/etc/init.d/httpd start
7.配置MySQL随系统启动
chkconfig--levels 235 mysqld on
/etc/init.d/mysqld start
8.设置数据库root密码
/usr/bin/mysqladmin-u root password'New+Password#www.yupengyan.com'
9.测试PHP是否安装成功
在 CentOS中 Apache的默认根目录是/var/www/html,配置文件/etc/httpd/conf/httpd.conf。其他配置存储在/etc/httpd/conf.d/目录。
apache怎么支持phpapache如何使用
如何配置apache来支持php
编译安装php,将php模块放在apahce中,然后将php模块添加到apacheconf中配置apache打开模块加载模式#。/configure-prefix=/usr/Apache2-enable-module=so-enable-SSL配置文件并添加loadmodulePHP5_modulemodules/lib5.sopp将模块编译到modules目录#。/configure-prefix=/usr/PHP5-with-APXS2=/usr/Apache2/bin/apxs-with-MySQL=/usr/MySQL-with-curl=/usr/include/curl-with。
apache基于什么语言?
apache是基于c语言开发的。
Apache是用C语言开发的基于模块设计的web应用,总体上看起来代码的可读性高于php代码,他的核心代码并不多,大多数的功能都被分割到各种模块中,各模块在系统启动时按需载入。
Apache支持SSL,支持多个虚拟主机,Apache是以进程的profork模式(还有基于线程的worker模式)为基础的结构,进程要比线程消耗更多的系统开支,不太适合与多处理器环境,因此,在一个Apacheweb站点扩容时,通常是增加服务器或者扩充群节点而不是增加处理器
为什么我本地在apache下运行php文件总是出现下载呢?
原因是少设置了一段文字。具体分析如下:
怎么搭建php服务器?
目前主流的php服务器端架构是linux+nginx+php-fpm。
linux的选择可以是centos,ubuntuserver,debian都可以,如果安装比较新的版本。
nginx也安装最新稳定版本。
php如果是新项目建议php7以上的版本。一般公司选在php部署方案的时候会现在自己编译一个可用版本,这样子可用把相关需要的php拓展一次装好,
相关的配置想也都预先配好,在部署的时候只需要做一次文件拷贝。
apache和nginx的区别?
1、二者最核心的区别在于apache是同步多进程模型,一个连接对应一个进程;nginx是异步的,多个连接(万级别)可以对应一个进程。nginx处理静态文件好,耗费内存少.但无疑apache仍然是目前的主流,有很多丰富的特性.所以还需要搭配着来.当然如果能确定nginx就适合需求,那么使用nginx会是更经济的方式。
2、nginx的负载能力比apache高很多。最新的服务器也改用nginx了。而且nginx改完配置能-t测试一下配置有没有问题。
3、apache重启的时候发现配置出错了,会很崩溃,改的时候都会非常小心翼翼现在看有好多集群站,前端nginx抗并发,后端apache集群,配合的也不错。
4、nginx处理动态请求是鸡肋,一般动态请求要apache去做,nginx只适合静态和反向。
5、从经验来看,nginx是很不错的前端服务器,负载性能很好,nginx,用webbench模拟10000个静态文件请求毫不吃力。apache对php等语言的支持很好,此外apache有强大的支持网络,发展时间相对nginx更久,bug少但是apache有先天不支持多核心处理负载鸡肋的缺点,建议使用nginx做前端,后端用apache。大型网站建议用nginx自代的集群功能。
6、大部分情况下nginx都优于APACHE,比如说静态文件处理、PHP-CGI的支持、反向代理功能、前端Cache、维持连接等等。在Apache+PHP(prefork)模式下,如果PHP处理慢或者前端压力很大的情况下,很容易出现Apache进程数飙升,从而拒绝服务的现象。
7、Apache在处理动态有优势,Nginx并发性比较好,CPU内存占用低,如果rewrite频繁,那还是Apache吧!
8、一般来说,需要性能的web服务,用nginx。如果不需要性能只求稳定,那就apache吧。
Apache与Tomcat有什么关系和区别?
apache一般跑PHP,Tomcat跑JSP。可以整合使用,同时支持PHP+JSP,我一般是用护卫神.apache大师安装apache+tomcat+php+jsp+mysql+ftp
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
以下的步骤和张宴步骤中一样配置,不再赘诉