CentOS下YUM安装apache+php+mysql

By | 08月19日
Advertisement

首先安装apache

使用以下命令列出可安装的资源:

yum list httpd*

#=>
Loading "installonlyn" plugin
Setting up repositories
Reading repository metadata in from local files
Available Packages
httpd.x86_64                                  2.2.6-jason.2               utterramblings  
httpd-devel.i386                              2.2.3-7.el5.centos          updates         
httpd-devel.x86_64                            2.2.6-jason.2               utterramblings  
httpd-manual.x86_64                           2.2.6-jason.2               utterramblings

# 安装(2.2.6):
yum install httpd.x86_64

# 控制命令:
service httpd status
service httpd start
service httpd stop
service httpd restart
service httpd graceful

# httpd配置文件:
/etc/httpd/conf/httpd.conf
# 修改记录:
# 在出现错误页的时候不显示服务器操作系统的名称,在HTTP_SERVER只显示“Apache”,之前是“Apache/2.2.6 (EL)”
ServerTokens Prod
Timeout 300
KeepAlive On
# 在错误页中不显示Apache的版本
ServerSignature Off

# 默认工作模式为prefork:
apachectl -l
Compiled in modules:
       core.c
       prefork.c
       http_core.c
       mod_so.c

# 推荐用worker MPM 模式:http://markmaunder.com/2007/configuring-apache-224-mod_perl-20-php-523-libapreq-with-a-worker-mpm/
# 参数调整 参考:
http://hi.baidu.com/rainchen/blog/item/095f0a551fa802c5b645ae46.html

# 默认加载模块:
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule cgi_module modules/mod_cgi.so

# 默认文件存放目录:
DocumentRoot "/var/www/html"

# 安装PHP(5.2.4):
# 列出:
yum list php*
Loading "installonlyn" plugin
Setting up repositories
Reading repository metadata in from local files
Available Packages
php.x86_64                                    5.2.4-jason.2               utterramblings  
php-acid.noarch                               0.9.6b22-1.2.el5.rf         dag             
php-adodb.noarch                              4.81-1.el5.rf               dag             
php-bcmath.x86_64                             5.2.4-jason.2               utterramblings  
php-cli.x86_64                                5.2.4-jason.2               utterramblings  
php-common.x86_64                             5.2.4-jason.2               utterramblings  
php-dba.x86_64                                5.2.4-jason.2               utterramblings  
php-dbase.x86_64                              5.2.4-jason.1               utterramblings  
php-devel.x86_64                              5.2.4-jason.2               utterramblings  
php-embedded.x86_64                           5.2.4-jason.2               utterramblings  
php-gd.x86_64                                 5.2.4-jason.2               utterramblings  
php-imap.x86_64                               5.2.4-jason.2               utterramblings  
php-jpgraph.noarch                            1.19-1.2.el5.rf             dag             
php-jpgraph-docs.noarch                       1.19-1.2.el5.rf             dag             
php-ldap.x86_64                               5.2.4-jason.2               utterramblings  
php-mbstring.x86_64                           5.2.4-jason.2               utterramblings  
php-mcrypt.x86_64                             5.2.4-jason.2               utterramblings  
php-mhash.x86_64                              5.2.4-jason.2               utterramblings  
php-mssql.x86_64                              5.2.4-jason.2               utterramblings  
php-mysql.x86_64                              5.2.4-jason.2               utterramblings  
php-ncurses.x86_64                            5.2.4-jason.2               utterramblings  
php-odbc.x86_64                               5.2.4-jason.2               utterramblings  
php-pdo.x86_64                                5.2.4-jason.2               utterramblings  
php-pear.noarch                               1:1.4.9-4                   base            
php-pear-Auth-SASL.noarch                     1.0.2-4.el5.centos          extras          
php-pear-DB.noarch                            1.7.6-7.el5.centos          extras          
php-pear-Date.noarch                          1.4.7-2.el5.centos          extras          
php-pear-File.noarch                          1.2.2-1.el5.centos          extras          
php-pear-HTTP-Request.noarch                  1.4.1-1.el5.centos          extras          
php-pear-Log.noarch                           1.9.11-1.el5.centos         extras          
php-pear-MDB2.noarch                          2.4.1-1.el5.centos          extras          
php-pear-MDB2-Driver-mysql.noarch             1.4.1-1.el5.centos          extras          
php-pear-Mail.noarch                          1.1.14-1.el5.centos         extras          
php-pear-Mail-Mime.noarch                     1.4.0-1.el5.centos          extras          
php-pear-Net-SMTP.noarch                      1.2.10-1.el5.centos         extras          
php-pear-Net-Sieve.noarch                     1.1.5-2.el5.centos          extras          
php-pear-Net-Socket.noarch                    1.0.8-1.el5.centos          extras          
php-pear-Net-URL.noarch                       1.0.15-1.el5.centos         extras          
php-pear-date.noarch                          1.4.6-1.el5.rf              dag             
php-pear-excel.noarch                         0.9.0-1.el5.rf              dag             
php-pear-file.noarch                          1.2.2-1.el5.rf              dag             
php-pear-log.noarch                           1.9.3-1.el5.rf              dag             
php-pear-mail_mime.noarch                     1.3.1-1.el5.rf              dag             
php-pear-ole.noarch                           0.5-2.el5.rf                dag             
php-pecl-Fileinfo.x86_64                      1.0.4-3.el5.centos          extras          
php-pecl-fileinfo.x86_64                      1.0.4-1.el5.rf              dag             
php-pecl-mailparse.x86_64                     2.1.1-1.el5.rf              dag             
php-pecl-memcache.x86_64                      2.1.2-1.el5.rf              dag             
php-pecl-session_mysql.x86_64                 1.9-1.el5.rf                dag             
php-pgsql.x86_64                              5.2.4-jason.2               utterramblings  
php-readline.x86_64                           5.1.6-12.el5.centos         extras          
php-rrdtool.x86_64                            1.0.50-3.el5.rf             dag             
php-snmp.x86_64                               5.2.4-jason.2               utterramblings  
php-soap.x86_64                               5.2.4-jason.2               utterramblings  
php-syck.x86_64                               0.55-4.el5.rf               dag             
php-tidy.x86_64                               5.2.4-jason.2               utterramblings  
php-xcache.x86_64                             5.2.4_1.2.1-jason.2         utterramblings  
php-xml.x86_64                                5.2.4-jason.2               utterramblings  
php-xmlrpc.x86_64                             5.2.4-jason.2               utterramblings  
phpmyadmin.noarch                             2.11.0-1.el5.rf             dag

# 安装:
yum install php.x86_64
# 相关依赖包:
=============================================================================
Package                      Arch            Version               Repository             Size

=============================================================================
Installing:
php                          x86_64          5.2.4-jason.2         utterramblings         3.9 M
Installing for dependencies:
php-cli                      x86_64          5.2.4-jason.2         utterramblings         2.7 M
php-common                   x86_64          5.2.4-jason.2         utterramblings         366 k

# 检查是否关联到apache中:
cat /etc/httpd/conf.d/php.conf

# 检查php是否可用:
vi /var/www/html/phpinfo.php
# 内容:
<?php phpinfo();
# 访问:http://ip/phpinfo.php
# OK,则删除phpinfo
rm /var/www/html/phpinfo.php

# httpd添加vhost支持:
vi /etc/httpd/conf.d/vhost.conf
# 内容
ServerName localhost
NameVirtualHost *:80
Include conf.d/vhosts/*.conf
# 建目录
mkdir /etc/httpd/conf.d/vhosts
mkdir /usr/local/www
mkdir /usr/local/www/vhosts
ln -s /usr/local/www/vhosts /www

# add default host, make sure the filename is on top of dir list
vi /etc/httpd/conf.d/vhosts/0default.conf
# 内容:
Include /www/default/conf/httpd.conf
# 解除xxx域名绑定时则只需删掉 /etc/httpd/conf.d/vhosts/xxx.conf

# default目录结构(作为新增的虚拟主机模板):
mkdir /www/default
mkdir /www/default/conf
mkdir /www/default/htdocs
mkdir /www/default/logs

# default真正的配置文件:
vi /www/default/conf/httpd.conf
# 内容:
<VirtualHost *:80>
         ServerAdmin [email protected]
         DocumentRoot /www/default/htdocs
         ServerName localhost
         ServerAlias localhost
         ErrorLog /www/default/logs/error.log
         CustomLog /www/default/logs/access.log combined

<Directory />
           Options FollowSymLinks MultiViews
           AllowOverride None
           Order allow,deny
           Allow from all
         </Directory>
</VirtualHost>

# 现在访问所有没有绑定到主机的域名时都会转到default

# 安装mysql:
# 参考:http://www.centospub.com/make/mysql.html
# 查看可用版本:
yum list mysql*
#=>
Loading "installonlyn" plugin
Setting up repositories
Reading repository metadata in from local files
Available Packages
MySQL-python.x86_64                           1.2.1-1                     base            
mysql.x86_64                                  5.0.48-jason.1              utterramblings  
mysql.i386                                    5.0.22-2.1.0.1              updates         
mysql-bench.x86_64                            5.0.48-jason.1              utterramblings  
mysql-connector-odbc.x86_64                   3.51.12-2.2                 base            
mysql-devel.x86_64                            5.0.48-jason.1              utterramblings  
mysql-devel.i386                              5.0.22-2.1.0.1              updates         
mysql-server.x86_64                           5.0.48-jason.1              utterramblings  
mysql-test.x86_64                             5.0.48-jason.1              utterramblings

# 安装(5.0.48):
yum -y install mysql-server
# 相关依赖包:
Installing for dependencies:
mysql                        x86_64          5.0.48-jason.1        utterramblings         4.3 M
perl-DBD-MySQL               x86_64          3.0007-1.fc6          base                   147 k
perl-DBI                     x86_64          1.58-2.el5.rf         dag                    840 k
perl-Net-Daemon              noarch          0.43-1.el5.rf         dag                     44 k
perl-PlRPC                   noarch          0.2020-1.el5.rf       dag                     33 k

# 启动:
service mysqld start

# 查看phpinfo发现没有mysql驱动,装上:
yum -y install php-mysql.x86_64
# 依赖于: php-pdo,所以自动也会装上(包括mysqli,已经包含在内)
# 重启httpd使之生效:
service httpd restart

# 登录测试:
mysql -u root
# 加上密码:
SET PASSWORD FOR 'root'@localhost = PASSWORD('passwordhere');
# 常用MYSQL命令参考:
http://www.pantz.org/database/mysql/mysqlcommands.shtml
# 添加新超级用户:
GRANT ALL PRIVILEGES ON *.* TO 'rain'@ 'localhost' IDENTIFIED BY '****************'
# 添加普通用户参考:http://dev.mysql.com/doc/refman/5.0/en/adding-users.html

# 装上其他需要用到php扩展:
php-mbstring.x86_64
php-gd.x86_64

# 确定都没问题后,设置为随开机启动
chkconfig httpd on
chkconfig mysqld on

Similar Posts:

  • Fedora 10下用Yum安装Apache+PHP+MySQL环境

    Fedora 10下用Yum安装Apache+PHP+MySQL环境1. 安装Apahce PHP Mysql 以及php连接mysql库组件. yum -y install httpd php mysql mysql-server php-mysql 2. 配置开机启动服务 /sbin/chkconfig httpd on [设置apache服务器httpd服务开机启动] /sbin/chkconfig --add mysqld [在服务清单中添加mysql服务] /sbin/chkconfi

  • [置顶] linux下使用yum安装Apache+php+Mysql+phpMyAdmin

    linux下使用yum安装Apache+php+Mysql+phpMyAdmin 2009-10-27 11:59:57 分类: LINUX 适用redhat于32位及64位,前提架设好本地源.在这里不再赘述. 1 安装Apache+php+Mysql a.安装Apahce, PHP, Mysql, 以及php连接mysql库组件 yum -y install httpd php mysql mysql-server php-mysql b.安装mysql扩展 yum -y install my

  • Centos下Yum安装PHP5.5,5.6,7.0

    Centos下Yum安装PHP5.5,5.6,7.0 默认的版本太低了,手动安装有一些麻烦,想采用Yum安装的可以使用下面的方案: 1.检查当前安装的PHP包 yum list installed | grep php 如果有安装的PHP包,先删除他们 yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64

  • CentOS yum 安装 Apache + PHP + MySQL

    # 编写本地yum仓库 rm -rf /etc/yum.repos.d/* cd /etc/yum.repos.d/ cat > local.repo <<end [local] name=qiqi baseurl=file:///media/RHEL_6.1\ i386\ Disc\ 1/ enabled=1 gpgcheck=0 end # 检查并卸载 rpm -qa|grep httpd rpm -e httpd rpm -qa|grep mysql rpm -e mysql rp

  • centos linux上安装apache php mysql环境,并安装wordpress以及配置虚拟主机环境

    wordpress程序是运行在php + mysql环境上的,所以我们需要先安装php mysql apache的运行环境. 1. 我们使用yum install 命令安装php mysql apache这三个软件,命令分别是 yum install apache #安装apache yum install php #安装php yum install mysql #安装mysql客户端 yum install mysql-server #这两个命令是安装mysql的服务器端 yum insta

  • 使用yum安装apache,php,mysql及其配置

    当前系统redhat6 使用yum源是 http://mirrors.163.com/.help/CentOS6-Base-163.repo 1.安装apache yum list httpd* 查看yum库中所有相关文件 yum install httpd* 高兴就全部安装吧,我很懒所以全装了,省得以后缺文件 2.安装php yum list php* //老规矩先查看下 yum install php* //没问题就全装了,觉得有必要自定义安装自己选择或者有多个php版本,我这就一个5.33

  • CentOS下yum安装FFmpeg

    一.yum安装FFmpeg 1. 最偷懒的方式就是yum安装了,自动解决依赖.不过CentOS系统默认无FFmpeg源,企业版 Linux 附加软件包EPEL源也不包含,需要手动添加yum源配置/etc/yum.repos.d/dag.repo: [dag] name=Dag RPM Repository for Red Hat Enterprise Linux baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag gpgc

  • 阿里云CentOS下yum安装mysql,jdk以及tomcat

    分享自http://blog.csdn.net/renfufei/article/details/9733367

  • CENTOS 5.5安装APACHE+PHP5.5

    Centos下Yum安装apache + PHP 以及升级 实验环境: OS:Centos 5.5 内存:1024 MB PHP: php 2.1 Apache:apache 2.2.3 第一步: 通过HTTP方式安装系统,安装系统比较简单,详细步骤省略. 第二步: Yum安装Apache和PHP 1.准备编译环境(定制源码安装时所需要的开发环境) yum install gcc gcc-c++ make automake autoconf yum install qt4-sqlite qt4-

  • 如何在Fedora 8下使用Yum来安装Apache+PHP+MySQL环境

    今天上海快网教您如何在Fedora 8下使用Yum来安装Apache+PHP+MySQL环境 Fedora 8下用Yum安装Apache+PHP+MySQL环境 fedora8 用yum来管理安装Apache+PHP+Mysql的基本安装. 1. 安装Apahce, PHP, Mysql, 以及php连接mysql库组件. yum -y install httpd php mysql mysql-server php-mysql 2. 配置开机启动服务 /sbin/chkconfig httpd

Tags: