Linux套件Fedora 21 安裝 LAMP 伺服器圖文教程

來源:互聯網
上載者:User

本教程按照 howtoforge.com 網站原文翻譯而來,如果不成功,可參看原文。不久前 Fedora 21 發布了,版本有三個,其中有一個伺服器版本,原文提示採用的就是 server 伺服器版本,先看看 LAMP 是 Linux、Apache、MySQL/MariaDB、PHP 的簡稱。

本教程採用的執行個體網域名稱為 server1.example.com,IP 位址為 192.168.0.100,實際上你安裝的時候有所不同,請作相應修改。

1、先安裝資料庫MySQL/MariaDB 5。

MariaDB 安裝命令:

yum install mariadb mariadb-server

為 MariaDB 建立開機自啟動:

systemctl enable mariadb.service

啟動 mysql 服務:

systemctl start mariadb.service

mysql_secure_installation

設定超級root使用者密碼,按照提示操作:

[root@server1 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

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): <– 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] <– ENTER
New password: <– 輸入密碼
Re-enter new 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] <– 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] <– 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] <– ENTER
 – Dropping test database…
… Success!
– 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] <– 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!
[root@server1 ~]#

2、安裝Apache2


yum install httpd

設定隨系統自啟動:

systemctl enable httpd.service

啟動服務:

systemctl start httpd.service

接下來我們需要添加Apache服務覆蓋在防火牆命令如下:

firewall-cmd --set-default-zone=public

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

好了,輸入IP地址:http://192.168.0.100,看看 apache 運行情況:



Fedora 系統 Apache 預設根目錄 /var/www/html,設定檔目錄 /etc/httpd/conf/httpd.conf,其他設定檔目錄 /etc/httpd/conf.d/ directory。

3、安裝PHP5

安裝命令:

yum install php

重啟 apache 命令:

systemctl restart httpd.service

4、測試 PHP5 擷取 PHP5 安裝情況:


在根目錄下建立一個探針檔案:
nano /var/www/html/info.php

添加檔案內容:

<?php
phpinfo();
?>

然後訪問探針檔案:http://192.168.0.100/info.php

5、讓 MySQL 得到 PHP5 支援:

先搜尋一下支援外掛程式:
yum search php
安裝:
yum install php-mysqlnd php-mssql php-opcache
重啟服務:
systemctl restart httpd.service

再訪問一下探針檔案,看看是否已經支援。

6、安裝 phpMyAdmin 管理資料庫:


yum install phpmyadmin

現在我們設定PHPMyAdmin。我們改變了Apache配置使phpMyAdmin允許串連不僅僅限於localhost地址訪問(<目錄/usr/share/phpMyAdmin/ >):

nano /etc/httpd/conf.d/phpMyAdmin.conf

配置內容如下:

<Directory /usr/share/phpMyAdmin/>
#   AddDefaultCharset UTF-8

#   <IfModule mod_authz_core.c>
#     # Apache 2.4
#     <RequireAny>
#       Require ip 127.0.0.1
#       Require ip ::1
#     </RequireAny>
#   </IfModule>
#   <IfModule !mod_authz_core.c>
#     # Apache 2.2
#     Order Deny,Allow
#     Deny from All
#     Allow from 127.0.0.1
#     Allow from ::1
#   </IfModule>
     Require all granted
</Directory>

重啟 apache:

systemctl restart httpd.service

OK 安裝完畢,現在訪問phpmyadmin:http://192.168.0.100/phpmyadmin/

官方連結:


    Apache: http://httpd.apache.org/
    PHP: http://www.php.net/
    MySQL: http://www.mysql.com/
    Fedora: http://fedoraproject.org/
    phpMyAdmin: http://www.phpmyadmin.net/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.