LAMP
由Linux搭建,Apache提供WEB服務,MariaDB 或 MySQL提供資料庫存取,PHP 或 Python作為網頁的程式語言。
首先安裝第三方套件庫:
1.查看CentOS官方獲社群認可的軟件庫:可供CentOS 使用的軟件庫 - CentOS Wiki
2.安裝 EPEL、Remi Repository、MariaDB Repositories
安裝 Apache HTTP Server
由Linux搭建,Apache提供WEB服務,MariaDB 或 MySQL提供資料庫存取,PHP 或 Python作為網頁的程式語言。
首先安裝第三方套件庫:
1.查看CentOS官方獲社群認可的軟件庫:可供CentOS 使用的軟件庫 - CentOS Wiki
2.安裝 EPEL、Remi Repository、MariaDB Repositories
- EPEL:
- # sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- Remi Repository:
- # sudo rpm -Uvh http://mirror.innosol.asia/remi/enterprise/remi-release-7.rpm
- MariaDB Repositories:這邊使用 MariaDB 10.3
- # sudo vim /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.3 CentOS repository list - created 2019-09-03 01:44 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.3/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=13.清除套件庫緩存及讓repo設定生效
- # sudo yum clean all
安裝 Apache HTTP Server
- # sudo yum install httpd
查看 Apache 測試頁
- 使用 先前架設 DNS Server 做解析到 Apache Server ,URL:www.brookdns.local
Apache 完成安裝!!
Mariadb
安裝 MariaDB 10.3
PHP
安裝PHP前有必要先確認一下版本,例如:worepress.org上就有要求PHP的版本需要7.3,後面需要安裝 wordpress 所以這邊安裝 php7.3版,但是 CentOS7預設提供的PHP只有提供5.4版,所以開始時有安裝套件庫(Remi Repository),先安裝 yum-utils 使用yum-config-manager指令啟用 Remi Repository PHP7.3。
PHP完成安裝!!
Mariadb
安裝 MariaDB 10.3
- sudo yum install mariadb-server
啟動 MariaDB | 查看 MariaDB 狀態 | 開機後啟動MariaDB
執行 mysql_secure_installation 設定相關安全性
- 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. Set root password? [Y/n] y 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] y ... 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] y ... 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] y - 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] y ... 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! "登入 MariaDB 測試
- mysql -u root -p
MariaDB 測試完成!!
PHP
安裝PHP前有必要先確認一下版本,例如:worepress.org上就有要求PHP的版本需要7.3,後面需要安裝 wordpress 所以這邊安裝 php7.3版,但是 CentOS7預設提供的PHP只有提供5.4版,所以開始時有安裝套件庫(Remi Repository),先安裝 yum-utils 使用yum-config-manager指令啟用 Remi Repository PHP7.3。
- sudo yum install yum-utils
- sudo yum-config-manager --enable remi-php73
安裝PHP7.3及常用擴建
- sudo yum install php php-xml php-gd php-mbstring php-intl php-mysqlnd php-pecl-zip php-pecl-mysql
安裝完後在 Apache 存放網頁的路徑下創建一個 PHP 信息測試頁,寫入<?php phpinfo(); ?>
重新啟動 Apache 服務
- sudo systemctl restart httpd
查看 PHP 信息頁面
留言
張貼留言