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

posted @ 2020-10-16 23:39  鲁哒哒  阅读(1528)  评论(0编辑  收藏  举报