linux下安顿php项目条件能够分为二种,一种选择Apache,php,mysql的压缩包安装,一种用yum命令实行设置。

  linux下布置php项目条件能够分为二种,一种接纳Apache,php,mysql的压缩包安装,一种用yum命令进行设置。

linux下部署php项目-Apache、php、mysql关联,-apachemysql

  linux下布署php项目环境能够分为三种,一种选择Apache,php,mysql的压缩包安装,一种用yum命令举办设置。

动用三种软件的削减包举办设置,须求手动配置三者之间的涉及。apache和php之间的安插没有啥样难度,可是和mysql举办安顿的时候就必要对php的刺探了。

以下是用yum在linux中配备php环境:

 

本文实例讲述了CentOS搭建PHP服务器环境的措施。分享给大家供我们参考,具体如下:

动用两种软件的减弱包实行设置,供给手动配置三者之间的涉及。apache和php之间的安排没有何样难度,可是和mysql举行配置的时候就要求对php的明白了。

动用三种软件的压缩包实行设置,供给手动配置三者之间的涉嫌。apache和php之间的配备没有何难度,可是和mysql进行安插的时候就必要对php的了然了。

MySql

 

  1.mysql和apache最佳是首先举行设置的,因为在配备php的时候必要与mysql和apache实行关联配置和测试

率先下载mysql-sever文件,因为博主linux环境是CentOS版本,yum源中一般没有例行安装mysql时的mysql-sever文件,须求去官网上下载

1.下载mysql-service文件

[[email protected] ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

2.安装mysql-service文件

[[email protected] ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

 

   2.安装mysql

[[email protected] ~]# yum install mysql-community-server

 

   3.安装完成之后运转mysql服务

[[email protected] ~]# service mysqld restart

 

  4.
上马安装的mysql是不曾密码的,用户名暗中同意是root。所以大家必要修改密码,用mysql命令行举办改动

 1.进入mysql命令行

[[email protected] ~]# 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

 

 

 

1. 先安装apache:

以下是用yum在linux中配备php环境:

以下是用yum在linux中布署php环境:

 安装Apache

 

  1.apache装置方式相对简便易行

[[email protected] ~]# yum install httpd

 

  2.外网访问虚拟机中的地址,大家就需求修改一下apache的配备文件/etc/httpd/conf/httpd.conf

 

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

   如右图所示:

 

 

 

 

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

 如右图所示:

   

 

 

 

 

 

  

  3.修改实现之后大家须求再一次启航httpd服务,并查阅运行状态

[[email protected] ~]# service httpd start
Redirecting to /bin/systemctl start  httpd.service
[[email protected]-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的测试页面

 

yum install httpd

 

 

PHP

配置ServerName

MySql

 

  1.mysql和apache最棒是首先实行安装的,因为在布局php的时候供给与mysql和apache实行关联配置和测试

第3下载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

 

 

 

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

【澳门金沙国际】CentOS搭建PHP服务器环境鲜明教程。 

  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

 

 

 

 

  1.php安装命令

[[email protected] ~]# yum install php

 

  2.直接一路装置,安装到位之后再度重启httpd服务

[[email protected] ~]# service httpd start
Redirecting to /bin/systemctl start  httpd.service

 

  3.重启之后大家进行测试PHP相关音讯,大家新建二个PHP界面进行测试

在apache默许页面路径/``var``/www/html下新建四个test.php页面,添加代码

<?php
 phpinfo();
?>

     

 

  4.拜访这一个页面,输入localhost/test.php,大概

ip:端口号/test.php就能够看见php环境的配置新闻了。如右图:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

vi /etc/httpd/conf/httpd.conf

 安装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的测试页面

 

 安装Apache

 

  1.apache安装方式相对简便易行

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

 

  2.外网访问虚拟机中的地址,我们就要求修改一下apache的布局文件/etc/httpd/conf/httpd.conf

 

澳门金沙国际 3

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

   如右图所示:

 

 

 

 

澳门金沙国际 4

 找到  #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的测试页面

 

 

将#ServerName
www.example.com:80修改为ServerName
localhost:80

PHP

PHP

 

外表机器此时输入服务器的IP地址,应该看到apache的劳动页面,端口不用输,apache私下认可正是应用80端口

 

  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相关消息,大家新建3个PHP界面实行测试

在apache暗许页面路径/``var``/www/html下新建1个test.php页面,添加代码

<?php
 phpinfo();
?>

     

澳门金沙国际 5

 

  4.做客这些页面,输入localhost/test.php,或然

ip:端口号/test.php就能够望见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();
?>

     

澳门金沙国际 6

 

  4.走访这几个页面,输入localhost/test.php,也许

ip:端口号/test.php就足以瞥见php环境的布署音讯了。如右图:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

关联php和mysql

 

  1.摸索模块

[[email protected] ~]# yum search php

 

  2.安装相关模块

[[email protected] ~]# yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml  php-xmlrpc

 

  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

 

 

 

有关链接:

 

linux下布置php项目环境足以分成三种,一种采纳Apache,php,mysql的压缩包安装,一种用yu…

如打不开可能端口80未打开外部访问,检查:

 

 

/etc/init.d/iptables status

 

 

末尾是还是不是有80等音信,无则开启之,注意地点及言语state,deport前面是两个中横杠–:

关联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

 

澳门金沙国际 7

  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

 

 

 

连锁链接:

 

关联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

 

澳门金沙国际 8

  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

 

 

 

相关链接:

 

vim /etc/sysconfig/iptables

加入:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

澳门金沙国际 9

然后重启并保存 防火墙:

service iptables restart
/etc/rc.d/init.d/iptables save

再查一下是还是不是打开:

/etc/init.d/iptables status

启动apache:

/etc/init.d/httpd start

2. 安装mysql:

yum install mysql mysql-server

启动mysql:

/etc/init.d/mysqld start

3. 安装php

yum install php php-devel

重启apache使php生效

/etc/init.d/httpd restart

那儿能够在目录:/var/www/html/下树立多个PHP文件

代码:

<?php phpinfo(); ?>

然后访问这一个文件,就能见到PHP的一些消息,php.ini配置文件的不二法门能够在那一个页面上阅览

安装php的扩展

复制代码 代码如下:

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml
php-xmlrpc

安装完扩充之后需求再行重启apache

/etc/init.d/httpd restart

测试mysql是不是链接成功的php代码

<?php
$con = mysql_connect("10.0.@.@@","@@","@@");
if (!$con)
{
 die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydb", $con);
$result = mysql_query("SELECT * FROM sys_user");
while($row = mysql_fetch_array($result))
{
 echo $row['UserName'] . " " . $row['PassWord'] . " " . $row['id'];
 echo "<br />";
}
mysql_close($con);
?>

能够把上边的代码传入目录/var/www/html/
就足以观望实市价况

设置目录介绍

Apache暗中同意将网站的根目录指向/var/www/html
目录
暗中同意的主配置文件是/etc/httpd/conf/httpd.conf
安插存款和储蓄在的/etc/httpd/conf.d/目录

希望本文所述对我们CentOS服务器维护有着辅助。

你只怕感兴趣的篇章:

  • CentOS
    5.5使用yum来安装LAMP(php运维条件)
  • 在CentOS 6 中安装WordPress(一) 安装Apache,Mysql,
    PHP环境
  • Centos6.5和Centos7
    php环境搭建方法
  • CentOS+Nginx+PHP+MySQL标准生产条件安排方式
  • Linux+php+apache+oracle环境搭建之CentOS下源码编写翻译安装PHP
  • 阿里云CentOS7搭建Apache+PHP+MySQL环境
  • centos下yum搭建筑和安装装linux+apache+mysql+php环境的不二法门
  • centos下yum搭建筑和安装装linux+apache+mysql+php环境教程
  • Centos
    6.8编写翻译安装LNMP环境(Nginx+MySQL+PHP)教程
  • Linux+php+apache+oracle环境搭建之CentOS下安装Oracle数据库
  • Centos7下编写翻译安装配备Nginx+PHP+MySql环境

相关文章