CentOS7一步一步搭建LAMP-創(chuàng)新互聯(lián)

一、準(zhǔn)備環(huán)境

“只有客戶(hù)發(fā)展了,才有我們的生存與發(fā)展!”這是創(chuàng)新互聯(lián)的服務(wù)宗旨!把網(wǎng)站當(dāng)作互聯(lián)網(wǎng)產(chǎn)品,產(chǎn)品思維更注重全局思維、需求分析和迭代思維,在網(wǎng)站建設(shè)中就是為了建設(shè)一個(gè)不僅審美在線(xiàn),而且實(shí)用性極高的網(wǎng)站。創(chuàng)新互聯(lián)對(duì)做網(wǎng)站、成都網(wǎng)站制作、網(wǎng)站制作、網(wǎng)站開(kāi)發(fā)、網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站優(yōu)化、網(wǎng)絡(luò)推廣、探索永無(wú)止境。

1、系統(tǒng)版本

[root@Webserver01 ~]# cat /proc/version

Linux version 3.10.0-514.16.1.el7.x86_64

2、關(guān)防火墻

[root@Webserver01 ~]# systemctl disable firewalld

3、準(zhǔn)備yum源

[root@Webserver01 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

[root@Webserver01 ~]# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm

4、安裝基礎(chǔ)工具

[root@Webserver01 ~]# yum install -y net-tools vim lrzsz tree screen lsof tcpdump nc nmap

5、關(guān)掉SELINUX

[root@Webserver01 ~]# vim /etc/sysconfig/selinux  SELINUX=disabled

6、更新并重啟

[root@Webserver01 ~]# yum update -y && reboot

二、開(kāi)始安裝LAMP組建

LAMP至少需要以下組建:

  • httpd (提供 Apache 主程序)

  • mysql (MySQL 客戶(hù)端程序)

  • mysql-server (MySQL 服務(wù)器程序)

  • php (PHP 主程序含給 apache 使用的模塊)

  • php-devel (PHP 的開(kāi)發(fā)工具,這個(gè)與PHP 外掛的加速軟件有關(guān))

  • php-mysql (提供給PHP 程序讀取 MySQL 資料庫(kù)的模塊)

可以用以下命令一次安裝;

[root@Webserver01 ~]# yum install httpd mysql mysql-server php php-mysql

為了看的更詳細(xì),我們一個(gè)一個(gè)安裝

1、利用yum命令安裝Apache

[root@Webserver01 ~]# yum -y install httpd

啟動(dòng)httpd并且設(shè)置為開(kāi)機(jī)啟動(dòng)

[root@Webserver01 ~]# systemctl start httpd.service [root@Webserver01 ~]# systemctl enable httpd.service

輸入網(wǎng)址,查看測(cè)試頁(yè)

CentOS 7 一步一步搭建LAMP

2、安裝Mariadb

利用yum命令進(jìn)行安裝,并且配置開(kāi)機(jī)啟動(dòng)同樣還是利用yum命令進(jìn)行安裝,并且配置開(kāi)機(jī)啟動(dòng)

[root@Webserver01 ~]# yum -y install mariadb-server mariadb [root@Webserver01 ~]# systemctl start mariadb.service [root@Webserver01 ~]# systemctl enable mariadb.service

配置root密碼

[root@Webserver01 ~]# mysql_secure_installation 安裝過(guò)程中會(huì)有幾個(gè)選項(xiàng),大家根據(jù)自己的需要進(jìn)行配置就好了 Enter current password for root (enter for none):(輸入原始root密碼,若無(wú)enter) 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] (是否設(shè)置root密碼) New password: Re-enter new password: Password updated successfully! Reloading privilege tables..  ... Success! Remove anonymous users? [Y/n] (是否移除匿名用戶(hù))  ... Success! Disallow root login remotely? [Y/n] (是否禁止遠(yuǎn)程root登陸)  ... skipping. Remove test database and access to it? [Y/n] (是否刪除測(cè)試數(shù)據(jù)庫(kù)) Reload privilege tables now? [Y/n] (重新載入)  ... 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!

登錄數(shù)據(jù)庫(kù)測(cè)試一下

[root@Webserver01 ~]# mysql -u root -p Enter password:  Welcome to the MariaDB monitor.  Commands end with ; or \g. Your MariaDB connection id is 13 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.00 sec) MariaDB [(none)]> exit Bye

3、安裝PHP

[root@Webserver01 ~]# yum -y install php

安裝所需組件

[root@Webserver01 ~]# yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

啟動(dòng)服務(wù)并設(shè)置開(kāi)機(jī)自動(dòng)啟動(dòng)

[root@Webserver01 ~]# systemctl start httpd.service [root@Webserver01 ~]# systemctl enable httpd.service

查看80端口和3306端口是否處于監(jiān)聽(tīng)狀態(tài):

[root@Webserver01 ~]# netstat -ntlp

測(cè)試php是否正常工作

編輯/etc/httpd/conf/httpd.conf文件,在DirectoryIndex后面填寫(xiě)index.php,定義默認(rèn)主頁(yè)為index.php

[root@Webserver01 ~]# vim /etc/httpd/conf/httpd.conf

CentOS 7 一步一步搭建LAMP

重載httpd配置文件

[root@Webserver01 ~]# systemctl reload httpd.service[root@Webserver01 ~]# vim /var/www/html/index.php

制作默認(rèn)主頁(yè)/var/www/html/index.php,編寫(xiě)如下內(nèi)容

<h2>This is new Web !</h2>        <?php               phpinfo();        ?>

重啟httpd服務(wù)

[root@Webserver01 ~]# systemctl restart httpd.service

好了,該驗(yàn)證最后是否成功了

打開(kāi)網(wǎng)址 http://x.x.x.x/info.php 進(jìn)行查看

CentOS 7 一步一步搭建LAMP

看到這個(gè)頁(yè)面,我們就可以收工了,LAMP環(huán)境搭建結(jié)束!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。

本文題目:CentOS7一步一步搭建LAMP-創(chuàng)新互聯(lián)
文章出自:http://muchs.cn/article4/djepie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)公司、手機(jī)網(wǎng)站建設(shè)、微信小程序、網(wǎng)站收錄虛擬主機(jī)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)