溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Fedora 23如何安裝LAMP服務(wù)器

發(fā)布時(shí)間:2022-02-18 11:50:00 來源:億速云 閱讀:126 作者:小新 欄目:開發(fā)技術(shù)

這篇文章主要介紹了Fedora 23如何安裝LAMP服務(wù)器,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

LAMP其實(shí)就是Linux+Apache+PHP+MySQL環(huán)境,

Fedora 23如何安裝LAMP服務(wù)器

安裝 Apache

Apache 是一款開源的 web 服務(wù)框架。完全支持 CGI, SSL。

切換到 root 賬戶:

su

Fedora 23/22 輸入以下命令來安裝Apache:

dnf install httpd -y

Fedora 21 及更早的版本:

yum install httpd -y

啟動(dòng)httpd服務(wù),以在每次系統(tǒng)啟動(dòng)服務(wù):

systemctl enable httpd

使用以下命令來啟動(dòng)httpd服務(wù):

systemctl start httpd

如果您遇到以下錯(cuò)誤:

Job for httpd.service failed. See ‘systemctl status httpd.service’ and ‘journalctl -xn’ for details.

刪除所有內(nèi)容在/etc/hostname,并加上“l(fā)ocalhost”。同時(shí),在/etc/httpd/conf/httpd.conf文件中的“Servername”的值設(shè)定為“l(fā)ocalhost”,并再次嘗試啟動(dòng)httpd服務(wù)。

并調(diào)整防火墻以允許httpd服務(wù),從遠(yuǎn)程客戶端訪問。

firewall-cmd --permanent --add-service=http

firewall-cmd --permanent --add-service=https

重新啟動(dòng)firewalld服務(wù):

firewall-cmd --reload

打開瀏覽器,輸入服務(wù)器IP訪問:

Fedora 23如何安裝LAMP服務(wù)器
Fedora 23如何安裝LAMP服務(wù)器Fedora 23如何安裝LAMP服務(wù)器

安裝 MariaDB

Fedora 23/22 用戶安裝命令:

dnf install mariadb mariadb-server -y

Fedora 21 及早前版本命令:

yum install mariadb mariadb-server -y

隨系統(tǒng)自動(dòng)啟動(dòng)命令:

systemctl enable mariadb

啟動(dòng)數(shù)據(jù)庫服務(wù)器:

systemctl start mariadb

設(shè)置 MariaDB root 賬戶密碼,默認(rèn)情況下MySQL root用戶的密碼為空。因此,以防止未經(jīng)授權(quán)的訪問MySQL數(shù)據(jù)庫,我們設(shè)置需要root用戶密碼:

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.

You already have a root password set, so you can safely answer ‘n’.

Change the root password? [Y/n] y ## Enter ‘y’ and press enter ##

New password: ## Enter password ##

Re-enter new password: ## Re-enter 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] ## Press Enter ##

… 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] ## Press Enter ##

… Success!

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] ## Press Enter ##

– Dropping test database…

ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist

… Failed! Not critical, keep moving…

– 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] ## Press Enter ##

… 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!

安裝 PHP

Fedora 23/22 用戶命令:

dnf install php -y

Fedora 21 及早期版本:

yum install php -y

測試PHP是否運(yùn)行:

vi /var/www/html/testphp.php

輸入以下內(nèi)容:


重啟 Http 服務(wù):

systemctl restart httpd

瀏覽器輸入看看:

Fedora 23如何安裝LAMP服務(wù)器

安裝PHP模塊

搜索模塊并安裝:

Fedora 23/22 用戶:

dnf search php

Fedora 22及早期版本:

yum search php

現(xiàn)在安裝你所選擇所需模塊,例如php-mysql,使用以下命令:

Fedora 23/22 用戶:

dnf install php-mysql -y

Fedora 22及早期版本:

yum install php-mysql -y

重啟 HTTP 服務(wù):

systemctl restart httpd

瀏覽器查看模塊安裝是否成功:

Fedora 23如何安裝LAMP服務(wù)器

安裝 phpMyAdmin

phpmyadmin 用于管理數(shù)據(jù)庫:

Fedora 23/22 用戶:

dnf install phpmyadmin -y

Fedora 22及早期版本:

yum install phpmyadmin -y

缺省情況下,phpMyAdmin 只能從本地主機(jī)進(jìn)行訪問。若要從遠(yuǎn)程系統(tǒng)訪問您的網(wǎng)絡(luò)中,請執(zhí)行下列操作步驟。

vi /etc/httpd/conf.d/phpMyAdmin.conf

查找并注釋掉127.0.0.1 和請求 ip ::1 lines。然后添加一個(gè)額外的行要求所有授予略低于為注釋行。

這是我的更改后的 phpMyAdmin.conf 文件。這些變化以粗體標(biāo)記。

[...]

Alias /phpMyAdmin /usr/share/phpMyAdmin

Alias /phpmyadmin /usr/share/phpMyAdmin  AddDefaultCharset UTF-8

      # Apache 2.4    #       Require ip 127.0.0.1#       Require ip ::1       Require all granted

            # Apache 2.2    Order Deny,Allow

    Deny from All

    Allow from 127.0.0.1

    Allow from ::1

        # Apache 2.4    #       Require ip 127.0.0.1#       Require ip ::1       Require all granted

        [...]

重要提示:不過讓localhost以外的人訪問數(shù)據(jù)庫,應(yīng)視為危險(xiǎn),除非通過SSL適當(dāng)保護(hù)。做到這一點(diǎn)需要您自擔(dān)風(fēng)險(xiǎn)。

保存并關(guān)閉文件。重新啟動(dòng)httpd服務(wù)。

systemctl restart httpd

OK,打開 phpmyadmin 測試一下:

Fedora 23如何安裝LAMP服務(wù)器

好了,安裝完畢!

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“Fedora 23如何安裝LAMP服務(wù)器”這篇文章對大家有幫助,同時(shí)也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識等著你來學(xué)習(xí)!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI