centos7安裝php環(huán)境的方法:首先用yum快速搭建lamp平臺;然后安裝php,并將php與mysql關聯(lián)起來;接著安裝常用php模塊,并創(chuàng)建“phpinfo();”用于測試php;最后重啟apache服務器即可。
centos7下面安裝php環(huán)境
用yum快速搭建lamp平臺
實驗環(huán)境:
[root@nmserver-7 html]# cat /etc/redhat-release centos release 7.3.1611 (altarch) [root@nmserver-7 html]# uname -alinux nmserver-7.test.com 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 httpdcreated symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.1.4 查看服務狀態(tài)
[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 -dforeground7月 21 17:21:35 nmserver-7.test.com systemd[1]: starting the apache http server...7月 21 17:21:36 nmserver-7.test.com httpd[2449]: ah00558: httpd: could not reliably determine the server's fully q...ssage7月 21 17:21:37 nmserver-7.test.com 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=httpsuccess[root@nmserver-7 ~]# firewall-cmd --permanent --zone=public --add-service=httpssuccess[root@nmserver-7 ~]# firewall-cmd --reloadsuccess1.6確認80端口監(jiān)聽中
[root@nmserver-7 ~]# netstat -tulpactive 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 addr1: 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 forever2: 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 forever3: 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