centos7 yum簡(jiǎn)單安裝配置Lamp(Linux+Apache+MySql+Php)

1.安裝apache

? ?1.1[root@localhost ~]# yum install httpd

? ?根據(jù)提示,輸入Y安裝即可成功安裝

?1.2 systemctl start httpd.service #啟動(dòng)apache

? ? ? ?systemctl stop httpd.service? ? #停止apache

? ? ? ?systemctl restart httpd.service #重啟apache

? ? ? ?systemctl enable httpd.service? #設(shè)置apache開(kāi)機(jī)啟動(dòng)

centos7修改具體的apache配置 在etc/httpd/conf/httpd.conf目錄下,

2.安裝mariadb(MySQL)操作和mysql一樣

? ? ? yum install mariadb mariadb-server ?#安裝mariadb

? ? ?詢(xún)問(wèn)是否要安裝,輸入Y即可自動(dòng)安裝,直到安裝完成

? ? ?systemctl start mariadb.service #啟動(dòng)MariaDB,

? ? ?systemctl stop mariadb.service? ? #停止MariaDB

? ? ?systemctl restart mariadb.service #重啟MariaDB,

? ? ?systemctl enable mariadb.service? #設(shè)置開(kāi)機(jī)啟動(dòng)

3 如果需要安裝mysql需要去官網(wǎng)下載

? ? 3.1.下載 wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

? ? 3.2.rpm 安裝 mysql 相應(yīng)的 yum源: ? ?rpm -ivh mysql-community-release-el7-5.noarch.rpm

? ? 3.3.安裝mysql yum install mysql-community-server

? ?3.4.成功安裝之后重啟mysql服務(wù) service mysqld restart

? ?3.5 mysql -u root -p 進(jìn)入mysql 默認(rèn)密碼為空

? ?3.6 mysql> set password for ‘root’@‘localhost’ = password('mypasswd');

????????mysql> exit ?搞定!

? ? ? (修改密碼時(shí)可能會(huì)報(bào)錯(cuò):Error (1133): Can’t find any matching row in the user table)

? ? ? ?在mysql命令行中執(zhí)行 FLUSH PRIVILEGES ?//刷新

????grant all on *.* to root identified by 'root'; ?//遠(yuǎn)程連接語(yǔ)句

4.安裝Php(由于yum自帶的php包版本過(guò)低,可選擇刪除重新安裝)

? ?4.1.刪除舊版本 yum remove php* php-common

? ?4.2.rpm 安裝 Php7 相應(yīng)的 yum源:rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

????提示錯(cuò)誤:

????error: Failed dependencies:

????epel-release >= 7 is needed by webtatic-release-7-3.noarch

????需要先安裝epel-release。

????1.安裝epel-release

????通過(guò)命令:

? ??yum -y install epel-release

????成功安裝。

? ?4.3.安裝phpyum install php70w

? 4.4.重啟apache systemctl restart httpd.service

? 4.5.寫(xiě)一個(gè)php文件 vi /var/www/html/info.php ?

? 4.6 輸入本機(jī)IP/info.php,顯示phpinfo信息,至此apache,php OK了

php常用模塊(php70w-fpm nginx解析php的容器)這里安裝了 后面安裝nignx時(shí)? 直接調(diào)用就可以了

yum -y install php70w-devel php70w.x86_64php70w-cli.x86_64php70w-common.x86_64php70w-gd.x86_64php70w-ldap.x86_64php70w-mbstring.x86_64php70w-mcrypt.x86_64php70w-pdo.x86_64php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongo

安裝常用模塊

5,安裝nginx和php-fpm

? ? yum install -y nginx

? ? #設(shè)置nginx開(kāi)機(jī)啟動(dòng)

? ? ?systemctl enable nginx

? ? ?#設(shè)置php-fpm開(kāi)機(jī)啟動(dòng)

? ? ?? ?systemctl enable php-fpm


提示:

1,之前自己安裝的時(shí)候沒(méi)有注意php的版本,apache安裝成功了但是卻不能解析php文件后面發(fā)現(xiàn)apache里沒(méi)有加載php_module,

可以使用httpd-M檢查是否安裝,有則代表安裝過(guò)。然后安裝php7安裝的時(shí)候自動(dòng)就加上了,可能是版本過(guò)低的原因吧~~

2,如果是阿里云服務(wù)器有可能你的數(shù)據(jù)庫(kù)一直連接不上,這時(shí)你應(yīng)該檢查下你阿里云服務(wù)器的安全組接口是否開(kāi)啟,3306這個(gè)端口是否添加到安全組規(guī)則里

3,yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm 安裝php-fpm 進(jìn)程管理器

4,如果安裝好了 環(huán)境 執(zhí)行php文件 報(bào)403錯(cuò)誤 看看nginx.conf配置文件里 有沒(méi)有指定index.php

如 :location / {

? ? ? # root? html;

? ? ? index? index.html index.htm index.php;

? }

5,如果安裝完執(zhí)行php文件 頁(yè)面顯示為空白的話(huà)打開(kāi)php.ini的:

short_open_tag = On



最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容