> CentOS > CentOS教程 >

CentOS 7 安装 PHP 7

 
  1. 安装Apache, PHP, MySQL以及php连接mysql库组件。

    yum -y install httpd php mysql mysql-server php-mysql

    CentOS 7.0 yum安装Apache、PHP和MySQL
  2.  

    安装apache扩展

    yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

    CentOS 7.0 yum安装Apache、PHP和MySQL
  3.  

    安装php的扩展

    yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

    CentOS 7.0 yum安装Apache、PHP和MySQL
  4.  

    安装MySQL的扩展

    yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

    CentOS 7.0 yum安装Apache、PHP和MySQL
  5.  

    配置开机启动服务

     

    #/sbin/chkconfig httpd on             [设置apache服务器httpd服务开机启动]

     

     

    #/sbin/service httpd start            [启动httpd服务,与开机启动无关]

     

     

    #/sbin/service mysqld start           [启动mysqld服务,与开机启动无关]

     

     

    说明:

    apache的配置文件是/etc/httpd/conf下modules放在/usr/lib/httpd下php的配置文件在/etc/php.d/下 和/etc/php.iniphp的modules放在/usr/lib/php/modules下

    CentOS 7.0 yum安装Apache、PHP和MySQL
  6.  

    绑定域名

    在/etc/httpd/conf/httpd.conf配置文件中,提供了范例:

     

    #

    # VirtualHost example:

    # Almost any Apache directive may go into a VirtualHost container.

    # The first VirtualHost section is used for requests without a known

    # server name.

    #

    #<VirtualHost *:80>

    #    ServerAdmin webmaster@dummy-host.example.com

    #    DocumentRoot /www/docs/dummy-host.example.com

    #    ServerName dummy-host.example.com

    #    ErrorLog logs/dummy-host.example.com-error_log

    #    CustomLog logs/dummy-host.example.com-access_log common

    #</VirtualHost>

     

    所以绑定域名可以跟着提供的范例来配置即可。

     

    说明:

    MySQL默认安装的后,root密码为空.

    CentOS 7.0 yum安装Apache、PHP和MySQL
     




(责任编辑:IT)