lamp php7.1(轉載)

安裝Apache&Nginx

 
nginx_Apache.jpg

①.升級一下yum源(不是必須的),升級會花點時間,須要選擇的地方都選擇都輸入「y」便可php

yum update

②. 安裝Apachehtml

yum list |grep httpd //查看有哪些Apache能夠安裝 yum install -y httpd //安裝Apache指令 http -v //安裝完成後查看Apache版本指令 顯示內容以下 Server version: Apache/2.4.6 (CentOS) Server built: Apr 12 2017 21:03:28 

③.經過瀏覽器訪問
在本機的瀏覽器的地址欄中輸入虛擬主機的ip地址,可是瀏覽器中沒有顯示有效的內容mysql

 
2017-06-11_124942.png

這種狀況基本是Centos自帶的防火牆開啓形成的nginx

1.關閉防火牆 [root@localhost /]# systemctl systemctl stop firewalld //關閉防火牆 [root@localhost /]# systemctl systemctl status firewalld //查看防火牆狀態 [root@localhost /]# systemctl systemctl restart httpd //重啓Apache 

再次刷新瀏覽器c++

 
2017-06-11.png

若是不想關閉防火牆,那咱們能夠在防火牆上容許訪問80端口(這是Apache默認的端口)web

2.防火牆上開啓80端口 [root@localhost /]# firewall-cmd --permanent --zone=public --add-port=80/tcp //開啓80端口而且永久生效 success [root@localhost /]# firewall-cmd --reload //從新載入防火牆配置 success [root@localhost /]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2017-06-11 13:08:10 CST; 8s ago //防火牆的狀體是開啓的 

刷新瀏覽器依舊能訪問到Apache的默認頁面
④.安裝Ngixnsql

[root@localhost /]# yum search nginx //搜索沒有nginx這個安裝包 很遺憾的是沒有 [root@localhost /]# yum install nginx //嘗試安裝 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn No package nginx available. //仍是沒有nginx的安裝包 //將nginx放到yum repro庫中 [root@localhost /]# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm [root@localhost /]# yum search nginx //再次搜索nginx安裝包 ======================================================== N/S matched: nginx ========================================================= nginx-debug.x86_64 : debug version of nginx nginx-debuginfo.x86_64 : Debug information for package nginx nginx-module-geoip.x86_64 : nginx GeoIP dynamic modules nginx-module-geoip-debuginfo.x86_64 : Debug information for package nginx-module-geoip nginx-module-image-filter.x86_64 : nginx image filter dynamic module nginx-module-image-filter-debuginfo.x86_64 : Debug information for package nginx-module-image-filter nginx-module-njs.x86_64 : nginx nginScript dynamic modules nginx-module-njs-debuginfo.x86_64 : Debug information for package nginx-module-njs nginx-module-perl.x86_64 : nginx Perl dynamic module nginx-module-perl-debuginfo.x86_64 : Debug information for package nginx-module-perl nginx-module-xslt.x86_64 : nginx xslt dynamic module nginx-module-xslt-debuginfo.x86_64 : Debug information for package nginx-module-xslt nginx-nr-agent.noarch : New Relic agent for NGINX and NGINX Plus nginx-release-centos.noarch : nginx repo configuration and pgp public keys pcp-pmda-nginx.x86_64 : Performance Co-Pilot (PCP) metrics for the Nginx Webserver nginx.x86_64 : High performance web server //是存在nginx安裝包的 [root@localhost /]# yum install nginx //安裝nginx [root@localhost /]# nginx -v //查看nginx版本 nginx version: nginx/1.12.0 [root@localhost /]# systemctl restart nginx // 重啓nginx 

我但願經過80端口訪問的是Apach服務器,經過8080端口訪問的是nginx服務器,這麼作?數據庫

[root@localhost /]# firewall-cmd --permanent --zone=public --add-port=8080/tcp success [root@localhost /]# firewall-cmd --reload success [root@localhost /]# firewall-cmd --zone=public --list-ports //查看全部打開的端口 80/tcp 8080/tcp //80,8080已經打開 [root@localhost /]# cd /etc/nginx/conf.d [root@localhost conf.d]# vim default.conf //將其中的listen 80;修改成 listen 8080; [root@localhost conf.d]# systemctl restart nginx //重啓nginx 

經過瀏覽器訪問vim

 
2017-06-11.png

安裝MySql

 
2017-06-11.png

CetOS7已使用了MariaDB替代了默認的MySQL ,因此咱們想使用MySQL還得多作點事情centos

[root@localhost /]# yum install wget //安裝wget [root@localhost /]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm //下載mysql5.7的rpm文件 [root@localhost /]# yum localinstall mysql57-community-release-el7-8.noarch.rpm //安裝rmp文件 [root@localhost /]#yum install mysql-community-server //安裝MySQL數據庫 約190M左右 [root@localhost /]# systemctl start mysqld //啓動數據庫 [root@localhost /]# grep 'temporary password' /var/log/mysqld.log //查看MySQL數據的原始密碼文件 2017-06-11T06:18:16.057811Z 1 [Note] A temporary password is generated for root@localhost: uvrpXRuul6/h [root@localhost /]# mysql -u root -p //進入數據庫系統 mysql> set password for 'root'@'localhost'=password('Aa@123456'); //從新爲數據庫設置密碼 Query OK, 0 rows affected, 1 warning (0.01 sec) //將MySQL設置爲開機啓動項 [root@localhost /]# systemctl enable mysqld [root@localhost /]# systemctl daemon-reload //設置數據的默認字符集(非必須的) [root@localhost ~]# vim /etc/my.cnf //將下面兩行配置代碼加入到my.cnf最後面 character_set_server=utf8 init_connect='SET NAMES utf8' [root@localhost ~]# systemctl restart mysqld //重啓MySQL //進入MySQL數據庫 mysql> select version(); +-----------+ | version() | +-----------+ | 5.7.18 | +-----------+ 1 row in set (0.00 sec) mysql> show variables like '%character%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.01 sec) 

安裝PHP7

 
php7.jpg
//安裝依賴文件 yum install gcc-c++ libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel //安裝php組新版本rpm [root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm Retrieving https://mirror.webtatic.com/yum/el7/epel-release.rpm warning: /var/tmp/rpm-tmp.F1aZTS: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:epel-release-7-5 ################################# [100%] [root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm warning: /var/tmp/rpm-tmp.rnxYY3: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:webtatic-release-7-3 ################################# [100%] [root@localhost ~]# yum search php71 //查看有哪些php最新版的安裝包文件 [root@localhost ~]# yum install mod_php71w php71w-mysqlnd php71w-cli php71w-fpm //安裝php7最新版 [root@localhost ~]# php -v //查看php版本 PHP 7.1.5 (cli) (built: May 12 2017 21:54:58) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies [root@localhost ~]# systemctl restart httpd //重啓Apache [root@localhost ~]# vim /var/www/html/index.php <?php phpinfo(); ?> 

刷新瀏覽器

 
2017-06-11.png
做者:龔天元 連接:https://www.jianshu.com/p/ed2d1820bd3e 來源:簡書 簡書著做權歸做者全部,任何形式的轉載都請聯繫做者得到受權並註明出處。
相關文章
相關標籤/搜索