centos7如何安装php环境

答案 Centos7下面安装PHP环境用yum快速搭建LAMP平台实验环境:[root@nmserver-7 html]# cat /etc/redhat-release CentOS release 7.3.1611 (AltArch) [root@nmserver-7 html]# uname -aLinux nmserver-7.test 3.10.0-514.el7.centos.plus.i686 #1 SMP Wed Jan 25 12:55:04

centos7如何安装php环境

Centos7下面安装PHP环境

用yum快速搭建LAMP平台

实验环境:

[root@nmserver-7 html]# cat /etc/redhat-release

CentOS release 7.3.1611 (AltArch)

[root@nmserver-7 html]# uname -a

Linux nmserver-7.test 3.10.0-514.el7.centos.plus.i686 #1 SMP Wed Jan 25 12:55:04 UTC 2017 i686 i686 i386 GNU/Linux1、安装apache

1.1 安装apache

[root@nmserver-7 ~]# yum install httpd httpd-devel1.2 启动apache服务

[root@nmserver-7 ~]# systemctl start httpd1.3 设置httpd服务开机启动

[root@nmserver-7 ~]# systemctl enable httpd

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.1.4 查看服务状态

[root@nmserver-7 ~]# systemctl status httpd

● httpd.service - The Apache HTTP Server

Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)

Active: active (running) since 五 2017-07-21 17:21:37 CST; 6min ago

Docs: man:httpd(8)

man:apachectl(8)

Main PID: 2449 (httpd)

Status: "Total requests: 11; Current requests/sec: 0; Current traffic: 0 B/sec"

CGroup: /system.slice/httpd.service

├─2449 /usr/sbin/httpd -DFOREGROUND

├─2450 /usr/sbin/httpd -DFOREGROUND

├─2451 /usr/sbin/httpd -DFOREGROUND

├─2452 /usr/sbin/httpd -DFOREGROUND

├─2453 /usr/sbin/httpd -DFOREGROUND

├─2454 /usr/sbin/httpd -DFOREGROUND

├─2493 /usr/sbin/httpd -DFOREGROUND

├─2494 /usr/sbin/httpd -DFOREGROUND

└─2495 /usr/sbin/httpd -DFOREGROUND

7月 21 17:21:35 nmserver-7.test systemd[1]: Starting The Apache HTTP Server...

7月 21 17:21:36 nmserver-7.test httpd[2449]: AH00558: httpd: Could not reliably determine the server's fully q...ssage

7月 21 17:21:37 nmserver-7.test systemd[1]: Started The Apache HTTP Server.

Hint: Some lines were ellipsized, use -l to show in full.1.5 防火墙设置开启80端口

[root@nmserver-7 ~]# firewall-cmd --permanent --zone=public --add-service=http

success

[root@nmserver-7 ~]# firewall-cmd --permanent --zone=public --add-service=https

success

[root@nmserver-7 ~]# firewall-cmd --reload

success1.6确认80端口监听中

[root@nmserver-7 ~]# netstat -tulp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 1084/sshd

tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN 1486/master

tcp6 0 0 [::]:ssh [::]:* LISTEN 1084/sshd

tcp6 0 0 localhost:smtp [::]:* LISTEN 1486/master

tcp6 0 0 [::]:http [::]:* LISTEN 2449/httpd

udp 0 0 localhost:323 0.0.0.0:* 592/chronyd

udp6 0 0 localhost:323 [::]:* 592/chronyd1.8 查服务器IP

[root@nmserver-7 ~]# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether 00:0c:29:56:bc:cf brd ff:ff:ff:ff:ff:ff

inet 192.168.8.9/24 brd 192.168.8.255 scope global ens33

valid_lft forever preferred_lft forever

inet6 fe80::20c:29ff:fe56:bccf/64 scope link

valid_lft forever preferred_lft forever

3: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000

link/ether ea:89:d5:c7:32:73 brd ff:ff:ff:ff:ff:ff1.9 浏览器登陆

如果浏览器访问不了,配置阿里云控制台的安全组80

2、安装mysql

2.1安装mysql

[root@nmserver-7 ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel

root@nmserver-7 ~]# rpm -qa |grep maria

mariadb-libs-5.5.52-1.el7.i686

mariadb-5.5.52-1.el7.i686

mariadb-server-5.5.52-1.el7.i686

mariadb-devel-5.5.52-1.el7.i6862.2 开启mysql服务,并设置开机启动,检查mysql状态

[root@nmserver-7 ~]# systemctl start mariadb

[root@nmserver-7 ~]# systemctl enable mariadb

Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

[root@nmserver-7 ~]# systemctl status mariadb

● mariadb.service - MariaDB database server

Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)

Active: active (running) since 六 2017-07-22 21:19:20 CST; 21s ago

Main PID: 9603 (mysqld_safe)

CGroup: /system.slice/mariadb.service

├─9603 /bin/sh /usr/bin/mysqld_safe --basedir=/usr

└─9760 /usr/libexec/mysqld --basedir=/usr --datadir=/v...

7月 22 21:19:15 nmserver-7.test mariadb-prepare-db-dir[9524]: ...

7月 22 21:19:15 nmserver-7.test mariadb-prepare-db-dir[9524]: ...

7月 22 21:19:15 nmserver-7.test mariadb-prepare-db-dir[9524]: ...

7月 22 21:19:15 nmserver-7.test mariadb-prepare-db-dir[9524]: ...

7月 22 21:19:15 nmserver-7.test mariadb-prepare-db-dir[9524]: ...

7月 22 21:19:15 nmserver-7.test mariadb-prepare-db-dir[9524]: ...

7月 22 21:19:15 nmserver-7.test mariadb-prepare-db-dir[9524]: ...

7月 22 21:19:16 nmserver-7.test mysqld_safe[9603]: 170722 21...

7月 22 21:19:16 nmserver-7.test mysqld_safe[9603]: 170722 21...

7月 22 21:19:20 nmserver-7.test systemd[1]: Started MariaDB ...[root@nmserver-7 ~]# netstat -tulp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 1084/sshd

tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 9760/mysqld

tcp6 0 0 [::]:ssh [::]:* LISTEN 1084/sshd

tcp6 0 0 [::]:http [::]:* LISTEN 2449/httpd

udp 0 0 localhost:323 0.0.0.0:* 592/chronyd

udp6 0 0 localhost:323 [::]:* 592/chronyd2.3 数据库安全设置

[root@nmserver-7 ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user. If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n

... skipping.

By default, MariaDB comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!2.4 登陆数据库测试

[root@nmserver-7 ~]# mysql -uroot -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or g.

Your MariaDB connection id is 11

Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

+--------------------+

3 rows in set (0.02 sec)

MariaDB [(none)]>3、安装PHP

3.1 安装php

[root@nmserver-7 ~]# yum -y install php

[root@nmserver-7 ~]# rpm -ql php

/etc/httpd/conf.d/php.conf

/etc/httpd/conf.modules.d/10-php.conf

/usr/lib/httpd/modules/libphp5.so

/usr/share/httpd/icons/php.gif

/var/lib/php/session3.2 将php与mysql关联起来

[root@nmserver-7 ~]# yum install php-mysql

[root@nmserver-7 ~]# rpm -ql php-mysql

/etc/php.d/mysql.ini

/etc/php.d/mysqli.ini

/etc/php.d/pdo_mysql.ini

/usr/lib/php/modules/mysql.so

/usr/lib/php/modules/mysqli.so

/usr/lib/php/modules/pdo_mysql.so3.3 安装常用PHP模块

[root@nmserver-7 ~]# yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath3.4 测试PHP

[root@nmserver-7 ~]# cd /var/www/html/

[root@nmserver-7 html]# ls

[root@nmserver-7 html]# pwd

/var/www/html

[root@nmserver-7 html]# vi info.php

<?php

phpinfo();

?>

~

~

~

~

~

~

~

~

:wq3.5重启apache服务器

[root@nmserver-7 html]# systemctl restart http

3.6测试PHP

在自己电脑浏览器输入 192.168.8.9/info.php,你可以看到已经安装的模块;

更多相关知识,请访问PHP中文网!

还要到空间的主机管理控制台中将域名和空间绑定。域名和主机两方面都要设置,一个设置解析,一个设置绑定。

建议你用模板建站系统做网站,完全可以自己动手制作网站。

有100多套网站模板可以选择,操作上和WORD差不多,管理和维护很方便,有学习视频,一般看半天就会做了。

速成网站-国际版(5G网页空间,不限流量,不需要备案,可做展示类、交易类网站,可免费试用):160元/年。

可以找咱们,现在在线。

免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理,本文部分文字与图片资源来自于网络,转载此文是出于传递更多信息之目的,若有来源标注错误或侵犯了您的合法权益,请立即通知我们,情况属实,我们会第一时间予以删除,并同时向您表示歉意,谢谢!

图片声明:本站部分配图来自人工智能系统AI生成,国外stocksnap摄影无版权图库。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!

内容声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。部分内容参考包括:(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供参考使用,不准确地方联系删除处理!本站为非盈利性质站点,本着为中国外贸事业出一份力,发布内容不收取任何费用也不接任何广告!
 

  • 热门焦点
  • 四川省眉山市仁寿县彰加镇梧桐街邮编是多少

    邮编查询为您提供四川省眉山市仁寿县彰加镇梧桐街邮编,四川省眉山市仁寿县彰加镇梧桐街的邮编,四川省眉山市仁寿县彰加镇梧桐街的邮政编码,四川省眉山市仁寿县彰加镇梧桐街的邮政编码是多少,四川省眉山市仁寿县彰加镇梧桐街的邮政编码查询,四川省眉山市仁寿县彰加镇梧桐街的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县里仁乡万春村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县里仁乡万春村邮编,四川省眉山市仁寿县里仁乡万春村的邮编,四川省眉山市仁寿县里仁乡万春村的邮政编码,四川省眉山市仁寿县里仁乡万春村的邮政编码是多少,四川省眉山市仁寿县里仁乡万春村的邮政编码查询,四川省眉山市仁寿县里仁乡万春村的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县付加镇青洋村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县付加镇青洋村邮编,四川省眉山市仁寿县付加镇青洋村的邮编,四川省眉山市仁寿县付加镇青洋村的邮政编码,四川省眉山市仁寿县付加镇青洋村的邮政编码是多少,四川省眉山市仁寿县付加镇青洋村的邮政编码查询,四川省眉山市仁寿县付加镇青洋村的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县禄加镇六皇村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县禄加镇六皇村邮编,四川省眉山市仁寿县禄加镇六皇村的邮编,四川省眉山市仁寿县禄加镇六皇村的邮政编码,四川省眉山市仁寿县禄加镇六皇村的邮政编码是多少,四川省眉山市仁寿县禄加镇六皇村的邮政编码查询,四川省眉山市仁寿县禄加镇六皇村的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县黑龙滩镇开元村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县黑龙滩镇开元村邮编,四川省眉山市仁寿县黑龙滩镇开元村的邮编,四川省眉山市仁寿县黑龙滩镇开元村的邮政编码,四川省眉山市仁寿县黑龙滩镇开元村的邮政编码是多少,四川省眉山市仁寿县黑龙滩镇开元村的邮政编码查询,四川省眉山市仁寿县黑龙滩镇开元村的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县洪峰乡金鸡村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县洪峰乡金鸡村邮编,四川省眉山市仁寿县洪峰乡金鸡村的邮编,四川省眉山市仁寿县洪峰乡金鸡村的邮政编码,四川省眉山市仁寿县洪峰乡金鸡村的邮政编码是多少,四川省眉山市仁寿县洪峰乡金鸡村的邮政编码查询,四川省眉山市仁寿县洪峰乡金鸡村的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县文宫镇文高路邮编是多少

    邮编查询为您提供四川省眉山市仁寿县文宫镇文高路邮编,四川省眉山市仁寿县文宫镇文高路的邮编,四川省眉山市仁寿县文宫镇文高路的邮政编码,四川省眉山市仁寿县文宫镇文高路的邮政编码是多少,四川省眉山市仁寿县文宫镇文高路的邮政编码查询,四川省眉山市仁寿县文宫镇文高路的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县彰加镇禹王村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县彰加镇禹王村邮编,四川省眉山市仁寿县彰加镇禹王村的邮编,四川省眉山市仁寿县彰加镇禹王村的邮政编码,四川省眉山市仁寿县彰加镇禹王村的邮政编码是多少,四川省眉山市仁寿县彰加镇禹王村的邮政编码查询,四川省眉山市仁寿县彰加镇禹王村的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县钟祥镇红旗路邮编是多少

    邮编查询为您提供四川省眉山市仁寿县钟祥镇红旗路邮编,四川省眉山市仁寿县钟祥镇红旗路的邮编,四川省眉山市仁寿县钟祥镇红旗路的邮政编码,四川省眉山市仁寿县钟祥镇红旗路的邮政编码是多少,四川省眉山市仁寿县钟祥镇红旗路的邮政编码查询,四川省眉山市仁寿县钟祥镇红旗路的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县江心街邮编是多少

    邮编查询为您提供四川省眉山市仁寿县江心街邮编,四川省眉山市仁寿县江心街的邮编,四川省眉山市仁寿县江心街的邮政编码,四川省眉山市仁寿县江心街的邮政编码是多少,四川省眉山市仁寿县江心街的邮政编码查询,四川省眉山市仁寿县江心街的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县视高镇油顶村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县视高镇油顶村邮编,四川省眉山市仁寿县视高镇油顶村的邮编,四川省眉山市仁寿县视高镇油顶村的邮政编码,四川省眉山市仁寿县视高镇油顶村的邮政编码是多少,四川省眉山市仁寿县视高镇油顶村的邮政编码查询,四川省眉山市仁寿县视高镇油顶村的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县先锋街邮编是多少

    邮编查询为您提供四川省眉山市仁寿县先锋街邮编,四川省眉山市仁寿县先锋街的邮编,四川省眉山市仁寿县先锋街的邮政编码,四川省眉山市仁寿县先锋街的邮政编码是多少,四川省眉山市仁寿县先锋街的邮政编码查询,四川省眉山市仁寿县先锋街的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县钟祥镇青山村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县钟祥镇青山村邮编,四川省眉山市仁寿县钟祥镇青山村的邮编,四川省眉山市仁寿县钟祥镇青山村的邮政编码,四川省眉山市仁寿县钟祥镇青山村的邮政编码是多少,四川省眉山市仁寿县钟祥镇青山村的邮政编码查询,四川省眉山市仁寿县钟祥镇青山村的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县禾加镇干井村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县禾加镇干井村邮编,四川省眉山市仁寿县禾加镇干井村的邮编,四川省眉山市仁寿县禾加镇干井村的邮政编码,四川省眉山市仁寿县禾加镇干井村的邮政编码是多少,四川省眉山市仁寿县禾加镇干井村的邮政编码查询,四川省眉山市仁寿县禾加镇干井村的邮政编码快速查询。
    08-09
  • 四川省眉山市仁寿县大化镇红塔村邮编是多少

    邮编查询为您提供四川省眉山市仁寿县大化镇红塔村邮编,四川省眉山市仁寿县大化镇红塔村的邮编,四川省眉山市仁寿县大化镇红塔村的邮政编码,四川省眉山市仁寿县大化镇红塔村的邮政编码是多少,四川省眉山市仁寿县大化镇红塔村的邮政编码查询,四川省眉山市仁寿县大化镇红塔村的邮政编码快速查询。
    08-09