1. 程式人生 > >lamp+phpmyadmin伺服器配置

lamp+phpmyadmin伺服器配置

1、安裝apache

[[email protected] ~]# yum -y install httpd 

直到返回

......
Installed:
  httpd.x86_64 0:2.4.6-40.el7.centos.4                                          

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                      apr-util.x86_64 0:1.5.2-6.el7   
  httpd-tools.x86_64 0:2.4.6-40.el7.centos.4    mailcap.noarch 0:2.1.41-2.el7   

Complete!

表示安裝成功!
2、安裝Php

[[email protected] ~]# yum -y install php

直到返回:

......
Installed:
  php.x86_64 0:5.4.16-36.3.el7_2                                                

Dependency Installed:
  libzip.x86_64 0:0.10.1-8.el7             php-cli.x86_64 0:5.4.16-36.3.el7_2   
  php-common.x86_64 0:5.4.16-36.3.el7_2   

Complete!

3、安裝php-fpm

[[email protected] ~]# yum -y install php-fpm

直到返回:

Installed:
  php-fpm.x86_64 0:5.4.16-36.3.el7_2                                            

Complete!

4、安裝Mysql

[[email protected]calhost ~]# yum -y install mysql

直到返回:

Installed:
  mariadb.x86_64 1:5.5.50-1.el7_2                                               

Dependency Updated:
  mariadb-libs.x86_64 1:5.5.50-1.el7_2                                          

Complete!

7.2版本的Centos已經把mysql更名為mariadb,表示安裝成功!
5、安裝 mysql-server

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum install mysql-community-server

然後需要確定,輸入y回車即可

Install  3 Packages (+8 Dependent packages)

Total download size: 82 M
Is this ok [y/d/N]: 

一直選擇輸入 y ,有兩次選擇,直到返回:

Replaced:
  mariadb.x86_64 1:5.5.50-1.el7_2      mariadb-libs.x86_64 1:5.5.50-1.el7_2     

Complete!

安裝成功!!!
6、安裝 php-mysql

[[email protected] ~]# yum -y install php-mysql

直到返回:

Installed:
  php-mysql.x86_64 0:5.4.16-36.3.el7_2                                          

Dependency Installed:
  php-pdo.x86_64 0:5.4.16-36.3.el7_2                                            

Complete!

安裝成功!!!

三、安裝基本常用擴充套件包

1、安裝Apache擴充套件包

yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql 

返回

......
Installed:
  httpd-manual.noarch 0:2.4.6-40.el7.centos.4                                   
  mod_ssl.x86_64 1:2.4.6-40.el7.centos.4                                        

Complete!

安裝成功!!!
2、安裝PHP擴充套件包

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

返回:

......
Dependency Updated:
  pcre.x86_64 0:8.32-15.el7_2.1                                                 

Complete!

安裝成功!!!
3、安裝Mysql擴充套件包

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

返回:

......
Dependency Installed:
  libdbi.x86_64 0:0.8.4-6.el7         libdbi-drivers.x86_64 0:0.8.3-16.el7     
  unixODBC.x86_64 0:2.3.1-11.el7     

Complete!

安裝成功!!!

四、配置Apache、mysql開機啟動

重啟Apache、mysql服務(注意這裡和centos6有區別,Cenots7+不能使用6的方式)

systemctl enable httpd.service #設定apache開機啟動

如果是採用方法一安裝的mariadb,安裝完成以後使用下面的命令開啟資料庫服務:

#啟動MariaDB

[[email protected] ~]# systemctl start mariadb.service   

#停止MariaDB

[[email protected] ~]# systemctl stop mariadb.service   

#重啟MariaDB

[[email protected] ~]# systemctl restart mariadb.service  

#設定開機啟動

[[email protected] ~]# systemctl enable mariadb.service  

重啟對應服務

service mysqld restart

service php-fpm start

service httpd restart

五、配置Mysql

初次安裝mysql是沒有密碼的,我們要設定密碼,mysql的預設賬戶為root

設定 MySQL 資料 root 賬戶的密碼:


 

mysql>mysql -u root

  mysql> use mysql;

  mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';

  mysql> FLUSH PRIVILEGES;


 

六 安裝phpmyadmi

yum install phpmyadmin

修改配置

<Directory /usr/share/phpMyAdmin/>

AddDefaultCharset UTF-8 <IfModule mod_authz_core.c>

# Apache 2.4 <RequireAny>

# Require ip 127.0.0.1 #註釋掉

# Require ip ::1 #註釋掉

Require all granted #新新增

</RequireAny> </IfModule>



complete!!!