Xampp完整安裝教程-linux


部署php項目

部署php 項目,需要工具Xampp,其中包含了apache,php,mysql 運行環境

下載


wget https://www.apachefriends.org/xampp-files/5.6.31/xampp-linux-x64-5.6.31-0-installer.run

3設置權限

chmod 777 xampp-linux-x64-5.6.31-0-installer.run

4 運行文件
./xampp-linux-x64-5.6.31-0-installer.run
運行成功會提示選擇一些選項 一路Y即可

下面是我安裝的過程

Welcome to the XAMPP Setup Wizard.


Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.

XAMPP Core Files : Y (Cannot be edited)

XAMPP Developer Files [Y/n] :y

Is the selection above correct? [Y/n]: y


Installation Directory

XAMPP will be installed to /opt/lampp
Press [Enter] to continue:


Setup is now ready to begin installing XAMPP on your computer.

Do you want to continue? [Y/n]: y


Please wait while Setup installs XAMPP on your computer.

Installing
0% ______________ 50% ______________ 100%
#########################################


Setup has finished installing XAMPP on your computer.
安裝完成以后 可以使用你的服務器IP地址或者本地的127.0.0.1來測試

切換到/opt/lampp目錄下

cd /opt/lampp/

ls

可以看到有個 htdocs 目錄

這里就是存放你的代碼

打開ftp

1 本地就不用說了吧

2 服務器的賬號密碼 默認的就是root. 密碼是你在購買服務器時 提示讓你設置的密碼 不要忘記了。記得要隔一段時間修改一下

在htdocs目錄下新建一個目錄 比如ruofan

然后新建一個build.php

寫入
echo '歡迎來到若凡';
成功以后進行下一步

啟動
1 啟動關閉
需要切換目錄:

cd /opt/lampp/

啟動 XAMPP

./lampp start

停止 XAMPP

./lampp stop

重啟 XAMPP

./lampp restart

2 訪問數據庫,並設置密碼

進入mysql

/opt/lampp/bin/mysql -uroot -p

xampp安裝完畢后,默認數據庫密碼為空

Enter password:
這里如果沒有啟動lampp ,會報一下錯誤

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/lampp/var/mysql/mysql.sock' (2 "No such file or directory")
確定啟動lampp以后

直接Enter就可以進入數據庫

Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 5Server version: 10.1.21-MariaDB Source distribution

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)]>

設置root用戶密碼

set password for root@localhost = password('123');
創建用戶並設置遠程訪問權限,不要直接用root用戶直接遠程訪問 創建一個個人用戶

MariaDB [(none)]> CREATE USER '用戶名'@'%' IDENTIFIED BY '密碼';

MariaDB [(none)]> GRANT ALL ON . TO '用戶名'@'%';

MariaDB [(none)]> flush privileges;
//2017-08-19

一個實例,添加一個對某個數據庫只有查詢權限的用戶

MariaDB [(none)]> create user 'zhangsl'@'%' identified by 'zhangsl2017';
Query OK, 0 rows affected (0.02 sec)

MariaDB [(none)]> grant select on db_name.* to 'zhangsl'@'%';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

打開你的數據庫訪問軟件 我這里用的是 Mac Sequel pro

使用上述創建的個人用戶進行訪問 這里的數據庫填寫 mysql

進去以后 新建一個自己的數據庫,然后回到連接的地方 把mysql 改為自己的數據庫

3 配置虛擬主機
執行

cat /opt/lampp/etc/httpd.conf
 可以查找到以下數據

Virtual hosts#Include etc/extra/httpd-vhosts.conf

這里如果提示 Permission denied

可以先賦予權限  

 xampp為我們准備了一個專用於配置虛擬主機的文件了,去掉#號以刪除其注釋,然后編輯

vim /opt/lampp/etc/extra/httpd-vhosts.conf
文件,此文件中xampp為我們創建了兩個虛擬主機的示例,然后添加我們自己需要的虛擬主機

DocumentRoot /opt/lampp/htdocs
ServerName blog.upwqy.com
DocumentRoot表示虛擬主機對應的路徑,即網站目錄,ServerName表示虛擬主機的訪問地址,類似IIS中的主機頭值。

至此,虛擬主機的設置也算是完成了。

最后我們需要在apache配置文件/opt/lampp/etc/httpd.conf中添加一下網站目錄的訪問權限。

Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
參考鏈接:
https://zhuanlan.zhihu.com/p/30367945


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM