设为首页 收藏本站
查看: 570|回复: 0

[经验分享] Centos 6安装完美搭建mysql、php、apache之旅

[复制链接]

尚未签到

发表于 2015-10-15 09:34:01 | 显示全部楼层 |阅读模式
安装apache
  [iyunv@centos share]# yum -y install httpd
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.yun-idc.com
* updates: mirrors.pubyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.i686 0:2.2.15-31.el6.centos set to be updated
--> Processing Dependency: httpd-tools = 2.2.15-31.el6.centos for package: httpd-2.2.15-31.el6.centos.i686
--> Running transaction check
---> Package httpd-tools.i686 0:2.2.15-31.el6.centos set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
Package                     Arch                 Version                                 Repository               Size
========================================================================================================================
Updating:
httpd                       i686                 2.2.15-31.el6.centos                    updates                 828 k
Updating for dependencies:
httpd-tools                 i686                 2.2.15-31.el6.centos                    updates                  74 k

Transaction Summary
========================================================================================================================
Install       0 Package(s)
Upgrade       2 Package(s)

Total download size: 902 k
Downloading Packages:
(1/2): httpd-2.2.15-31.el6.centos.i686.rpm                                                       | 828 kB     00:03     
(2/2): httpd-tools-2.2.15-31.el6.centos.i686.rpm                                                 |  74 kB     00:00     
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   261 kB/s | 902 kB     00:03     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : httpd-tools-2.2.15-31.el6.centos.i686                                                            1/4
  Updating       : httpd-2.2.15-31.el6.centos.i686                                                                  2/4
  Cleanup        : httpd-2.2.15-5.el6.centos.i686                                                                   3/4
  Cleanup        : httpd-tools-2.2.15-5.el6.centos.i686                                                             4/4

Updated:
  httpd.i686 0:2.2.15-31.el6.centos                                                                                    

Dependency Updated:
  httpd-tools.i686 0:2.2.15-31.el6.centos                                                                              

Complete!
  安装mysql
  [iyunv@centos etc]# whereis mysql
mysql: /usr/lib/mysql /usr/share/mysql
[iyunv@centos etc]# rpm -qa|grep mysql
mysql-libs-5.1.73-3.el6_5.i686
[iyunv@centos etc]# rpm -e mysql-libs-5.1.73-3.el6_5.i686 --nodeps 强制删除

  [iyunv@centos etc]# whereis mysql
  mysql:
  [iyunv@centos httpd]# yum -y install mysql-server
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.yun-idc.com
* updates: mirrors.pubyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.i686 0:5.1.73-3.el6_5 set to be updated
--> Processing Dependency: mysql = 5.1.73-3.el6_5 for package: mysql-server-5.1.73-3.el6_5.i686
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-3.el6_5.i686
--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16) for package: mysql-server-5.1.73-3.el6_5.i686
--> Processing Dependency: libmysqlclient_r.so.16 for package: mysql-server-5.1.73-3.el6_5.i686
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16) for package: mysql-server-5.1.73-3.el6_5.i686
--> Processing Dependency: libmysqlclient.so.16 for package: mysql-server-5.1.73-3.el6_5.i686
--> Running transaction check
---> Package mysql.i686 0:5.1.73-3.el6_5 set to be updated
---> Package mysql-libs.i686 0:5.1.73-3.el6_5 set to be updated
---> Package perl-DBD-MySQL.i686 0:4.013-3.el6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
Package                         Arch                  Version                           Repository                Size
========================================================================================================================
Installing:
mysql-server                    i686                  5.1.73-3.el6_5                    updates                  8.8 M
Installing for dependencies:
mysql                           i686                  5.1.73-3.el6_5                    updates                  903 k
mysql-libs                      i686                  5.1.73-3.el6_5                    updates                  1.2 M
perl-DBD-MySQL                  i686                  4.013-3.el6                       base                     134 k

Transaction Summary
========================================================================================================================
Install       4 Package(s)
Upgrade       0 Package(s)

Total download size: 11 M
Installed size: 31 M
Downloading Packages:
(1/4): mysql-5.1.73-3.el6_5.i686.rpm                                                             | 903 kB     00:03     
(2/4): mysql-libs-5.1.73-3.el6_5.i686.rpm                                                        | 1.2 MB     00:04     
(3/4): mysql-server-5.1.73-3.el6_5.i686.rpm                                                      | 8.8 MB     00:32     
(4/4): perl-DBD-MySQL-4.013-3.el6.i686.rpm                                                       | 134 kB     00:00     
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   276 kB/s |  11 MB     00:40     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : mysql-libs-5.1.73-3.el6_5.i686                                                                   1/4
  Installing     : mysql-5.1.73-3.el6_5.i686                                                                        2/4
  Installing     : perl-DBD-MySQL-4.013-3.el6.i686                                                                  3/4
  Installing     : mysql-server-5.1.73-3.el6_5.i686                                                                 4/4

Installed:
  mysql-server.i686 0:5.1.73-3.el6_5                                                                                    

Dependency Installed:
  mysql.i686 0:5.1.73-3.el6_5         mysql-libs.i686 0:5.1.73-3.el6_5         perl-DBD-MySQL.i686 0:4.013-3.el6        

Complete!

  [iyunv@centos httpd]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[iyunv@centos httpd]# whereis mysql
mysql: /usr/bin/mysql /usr/lib/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
[iyunv@centos httpd]# cd /var/lib/mysql
[iyunv@centos mysql]# ls -a
.  ..
[iyunv@centos mysql]# service mysqld restart
停止 mysqld:                                              [确定]
初始化 MySQL 数据库: Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h centos password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [确定]
正在启动 mysqld:                                          [确定]
[iyunv@centos mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
  mysql安装ok


  安装php
  [iyunv@centos etc]# yum install php
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.yun-idc.com
* updates: mirrors.pubyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php.i686 0:5.3.3-27.el6_5.2 set to be updated
--> Processing Dependency: php-common(x86-32) = 5.3.3-27.el6_5.2 for package: php-5.3.3-27.el6_5.2.i686
--> Processing Dependency: php-cli(x86-32) = 5.3.3-27.el6_5.2 for package: php-5.3.3-27.el6_5.2.i686
--> Running transaction check
---> Package php-cli.i686 0:5.3.3-27.el6_5.2 set to be updated
---> Package php-common.i686 0:5.3.3-27.el6_5.2 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
Package                      Arch                   Version                            Repository                 Size
========================================================================================================================
Installing:
php                          i686                   5.3.3-27.el6_5.2                   updates                   1.1 M
Installing for dependencies:
php-cli                      i686                   5.3.3-27.el6_5.2                   updates                   2.2 M
php-common                   i686                   5.3.3-27.el6_5.2                   updates                   527 k

Transaction Summary
========================================================================================================================
Install       3 Package(s)
Upgrade       0 Package(s)

Total download size: 3.9 M
Installed size: 13 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): php-5.3.3-27.el6_5.2.i686.rpm                                                             | 1.1 MB     00:04     
(2/3): php-cli-5.3.3-27.el6_5.2.i686.rpm                                                         | 2.2 MB     00:08     
(3/3): php-common-5.3.3-27.el6_5.2.i686.rpm                                                      | 527 kB     00:01     
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   259 kB/s | 3.9 MB     00:15     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
2:postfix-2.6.6-2.el6.i686 has missing requires of libmysqlclient.so.16
2:postfix-2.6.6-2.el6.i686 has missing requires of libmysqlclient.so.16(libmysqlclient_16)
2:postfix-2.6.6-2.el6.i686 has missing requires of mysql-libs
  Installing     : php-common-5.3.3-27.el6_5.2.i686                                                                 1/3
  Installing     : php-cli-5.3.3-27.el6_5.2.i686                                                                    2/3
  Installing     : php-5.3.3-27.el6_5.2.i686                                                                        3/3

Installed:
  php.i686 0:5.3.3-27.el6_5.2                                                                                          

Dependency Installed:
  php-cli.i686 0:5.3.3-27.el6_5.2                           php-common.i686 0:5.3.3-27.el6_5.2                          

Complete!
  

  配置apache
  web application 项目路径 /var/www/html
  apache配置文件路径 /etc/httpd/conf
  [iyunv@centos /]# cd /ect/httpd
[iyunv@centos httpd]# ls -a
.  ..  conf  conf.d  logs  modules  run
  [iyunv@centos conf.d]# vim README

  内容为:
  This directory holds Apache 2.0 module-specific configuration files;
any files in this directory which have the ".conf" extension will be
processed as Apache configuration files.

Files are processed in alphabetical order, so if using configuration
directives which depend on, say, mod_perl being loaded, ensure that
these are placed in a filename later in the sort order than "perl.conf".

  ".conf"结尾的文件将被服务所处理,所以创建一个网站域名为文件名的文件来实现域名绑定配置。
  [iyunv@centos conf.d]# vim git.com

  <VirtualHost *:80>
        ServerAdmin novalue@qq.com
        DocumentRoot /var/www/html/git
        ServerName www.gittest.com
        ServerAlias gittest.com

        RewriteEngine On
        RewriteCond %{HPPT_HOST} ^gittest.com$ [NC]
        RewriteRule ^(.*)$ http://www.gittest.com$1 [L,R=301]

        ErrorLog logs/dummy-www.gittest.com-error_log
        CustomLog logs/dummy-www.gittest.com-access_log common
</VirtualHose>

  

  启动httpd服务
[iyunv@centos conf.d]# service httpd start
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
                                                           [确定]



  
  访问 http://192.168.1.10/

DSC0000.jpg
  [iyunv@centos conf.d]# cd /var/www/html
[iyunv@centos html]# ls -a
.  ..
[iyunv@centos html]# vim index.php
  输入:
<?php
phpinfo();


  访问:http://192.168.1.10/

DSC0001.jpg
  ok,成功了

         版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-126988-1-1.html 上篇帖子: RHEL 6.4使用CentOS 6.4 yum源更新-i386的脚本 下篇帖子: 解决CentOS 6.2下安装ipvsadm-1.26报错
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表