CentOS下YUM安装apache+php+mysql

6 篇文章 0 订阅
3 篇文章 0 订阅

首先安装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 root@localhost
         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





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值