行使三种软件的缩短包举行安装
Tagged Tags:

  linux下安插php项目条件足以分为二种,黄金时代种采用Apache,php,mysql的压缩包安装,后生可畏种用yum命令实行设置。

应用两种软件的降低包进行安装,供给手动配置三者之间的涉嫌。apache和php之间的布局未有啥样难度,不过和mysql进行布置的时候就供给对php的问询了。

以下是用yum在linux中布局php境况:

 

MySql

 

  1.mysql和apache最棒是第意气风发实行设置的,因为在安顿php的时候供赋予mysql和apache实行关联配置和测量检验

第一下载mysql-sever文件,因为博主linux情况是CentOS版本,yum源中平常未有例行安装mysql时的mysql-sever文件,要求去官网络下载

1.下载mysql-service文件

[root@tele-1 ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

2.安装mysql-service文件

[root@tele-1 ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

 

   2.安装mysql

[root@tele-1 ~]# yum install mysql-community-server

 

   3.安装收尾之后运行mysql服务

[root@tele-1 ~]# service mysqld restart

 

  4.
起来安装的mysql是从未密码的,客户名默许是root。所以大家需求修改密码,用mysql命令行举办改变

 1.进入mysql命令行

[root@tele-1 ~]# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 474801
Server version: 5.6.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> 

2.使用命令进行密码修改

mysql> set password for 'root'@'localhost' = password('你要修改的密码');
Query OK, 0 rows affected (0.06 sec)

 

  5.因为博主是用本地navicat软件来连接linux下的mysql的,所以风度翩翩旦要在地头访谈的话,就需求改一下mysql数据库中的user表了

1.操作mysql数据库表

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> 


2.查看user表中的数据(在mysql命令行中可以直接进行sql语句编写)

mysql> select * from user;
+-----------+------+-----------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+
| Host      | User | Password                                  | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin                | authentication_string | password_expired |
+-----------+------+-----------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+
| %         | root | *3ce8dad2446975d8b0c771bd7e48d15b | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password |                       | N                |
| localhost | root | *3ce8dad2446975d8b0c771bd7e48d15b | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password |                       | N                |
| 127.0.0.1 | root | *3ce8dad2446975d8b0c771bd7e48d15b | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password |                       | N                |
| ::1       | root | *3ce8dad2446975d8b0c771bd7e48d15b | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password |                       | N                |
| tele-1    |      |                                           | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      |          |            |             |              |             0 |           0 |               0 |                    0 | mysql_native_password | NULL                  | N                |
+-----------+------+-----------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+
5 rows in set (0.00 sec)

mysql> 

 

  3.博主的表中是修改现在的表了,想要远程访谈,就必要上面普鲁士蓝申明的数据了,Host指的是可以访谈此数据库的ip地址,%代表的是兼备的伸手都足以连绵不断进来。

大家能够修改一条数据,也得以增多一条数据。不过最为不要涂改上面大青标明的数目,修改语句正是下边包车型地铁格式

mysql> update user set Host = '%' where ???

 

  4.终极推出exit大概\q都以退出mysql命令行的格局

mysql> \q
Bye

 

 

 

 安装Apache

 

  1.apache装置方式绝对轻便

[root@tele-2 ~]# yum install httpd

 

  2.外网访谈虚构机中的地址,大家就必要修改一下apache的陈设文件/etc/httpd/conf/httpd.conf

 

图片 1

 找到  #ServerName
www.example.com:80            改为  ServerName
localhost:80

   如右图所示:

 

 

 

 

图片 2

 找到  #Listen  
                              改为  Listen:8080(linux中怒放的端口号80XX)

 如右图所示:

   

 

 

 

 

 

行使三种软件的缩短包举行安装。  

  3.修改达成现在我们须求重新启航httpd服务,并查阅运行状态

[root@tele-2 ~]# service httpd start
Redirecting to /bin/systemctl start  httpd.service
[root@tele-2 ~]# service httpd status
Redirecting to /bin/systemctl status  httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2017-06-05 15:57:34 CST; 5s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 54532 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
  Process: 39046 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
 Main PID: 54573 (httpd)
   Status: "Processing requests..."
   Memory: 15.8M
   CGroup: /system.slice/httpd.service
           ├─54573 /usr/sbin/httpd -DFOREGROUND
           ├─54576 /usr/sbin/httpd -DFOREGROUND
           ├─54577 /usr/sbin/httpd -DFOREGROUND
           ├─54578 /usr/sbin/httpd -DFOREGROUND
           ├─54579 /usr/sbin/httpd -DFOREGROUND
           └─54580 /usr/sbin/httpd -DFOREGROUND

Jun 05 15:57:34 tele-2 systemd[1]: Starting The Apache HTTP Server...
Jun 05 15:57:34 tele-2 systemd[1]: Started The Apache HTTP Server.

 

  4.那儿您就足以访谈你的服务器了,输入localhost也许ip地址,现身一个Apache
test page powered by centos的测量检验页面

 

PHP

 

  1.php安装命令

[root@tele-2 ~]# yum install php

 

  2.一向一路安装,安装实现今后重新重启httpd服务

[root@tele-2 ~]# service httpd start
Redirecting to /bin/systemctl start  httpd.service

行使三种软件的缩短包举行安装。 

  3.重启之后大家实行测量检验PHP相关新闻,我们新建二个PHP分界面进行测验

在apache暗中认可页面路径/``var``/www/html下新建一个test.php页面,增多代码

<?php
 phpinfo();
?>

     

图片 3

 

  4.寻访这些页面,输入localhost/test.php,只怕

ip:端口号/test.php就足以看到php意况的配置新闻了。如右图:

 

 

 

 

 

 

 

 

 

 

 

 

 

行使三种软件的缩短包举行安装。 

 

 

 

 

 

关联php和mysql

 

  1.寻觅模块

[root@tele-2 ~]# yum search php

 

  2.装置相关模块

[root@tele-2 ~]# yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml  php-xmlrpc

 

图片 4

  3.装置完成,重启mysqld,重启httpd

再一次访谈刚才的info.php,大家发现已经多了MySQL的连带音讯。如右图:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

   至此,php在linux中的运转条件就已经成功布署实现了。

 

  1.mysql
yum安装暗中同意文件夹及相关命令

数据库目录:/var/lib/mysql/

配置文件:/usr/share/mysql(mysql.server命令及配置文件)

相关命令:/usr/bin(mysqladmin mysqldump等命令)

my.cnf: /etc/my.cnf

启动脚本:/etc/rc.d/init.d/(启动脚本文件mysql的目录)

启动命令:service mysql start

停止命令:service mysql stop

运行状态:service mysql status

 

 

  2.apache

配置文件路径:/etc/httpd/conf/httpd.conf

启动命令:service httpd start

停止命令:service httpd stop

运行状态:service httpd status

 

 

  3.php

php默认页面路径:/var/www/html

 

 

 

有关链接:

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注