由于Centos7,新安装配置后,并没有相应的一些常用命令软件包(tar zxvf,ifconfig , wget) 等,则首先需要安装一些常用的命令:
1:安装常用软件包:
1-1:tar 命令:yum install -y tar
1-2:wget命令:yum install -y wget
1-2:ifconfig命令:
yum provides ifconfig
yum whatprovides ifconfig
1-3:安装uzip:yum install -y unzip zip(现在暂时用不到,后期会用先配置好)
2:基本常用软件配置好后,执行ifconfig 查看IP地址或者ping www.baidu.com,查看网络是否ping通,方便下一步下载软件
3:查看电脑环境:
$ uname -r 3.10.0-327.28.3.el7.x86_64 $ cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)
4:下载安装xampp-linux-x64-5.5.38-3-installer.run
$ wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/5.5.38/xampp-linux-x64-5.5.38-3-installer.run $ chmod +x xampp-linux-x64-5.5.38-3-installer.run $ ./xampp-linux-x64-5.5.38-3-installer.run ---------------------------------------------------------------------------- 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.
5:安装完成后,追加环境变量(可执行文件,库文件和头文件)
$ vi /etc/profile export PATH=$PATH:/opt/lampp/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lampp/lib export C_INCLUDE_PATH=$C_INCLUDE_PATH:/opt/lampp/include $ source /etc/profile
6:启动LAMP(出现以下,则成功启动Success!)
$ /opt/lampp/lampp start Starting XAMPP for Linux 5.5.38-3... XAMPP: Starting Apache...ok. XAMPP: Starting MySQL...ok. XAMPP: Starting ProFTPD...ok.
Ps:lampp命令支持stop,status,start,restart等命令
7:设置xampp开机自动启动
$ ln -s /opt/lampp/lampp /etc/init.d/lampp $ chkconfig --add lampp
8:xampp常用组件的配置
# HTTPD主配置文件; /opt/lampp/etc/httpd.conf # PHP主配置文件; /opt/lampp/etc/php.ini # MariaDB主配置文件; /opt/lampp/etc/my.cnf # MariaDB数据目录; /opt/lampp/var/mysql # 所有日志目录; /opt/lampp/logs/
OK!至此安装完成,浏览器输入IP/dashboard 或者(localhost/dashboard ),访问即可,如果像重装,只需删除 /opt/lampp即可、
Ps:如果不能访问,则还需修改Centos的防火墙 以及 xampp的配置文件
直接修改 httpd-xampp.conf 的配置文件(注意自己的所在路径)
vi /opt/lampp/etc/extra/httpd-xampp.conf
将如下代码中 将Require Local 修改替换为 Require all granted
# since XAMPP 1.4.3 <Directory "/opt/lampp/phpmyadmin"> AllowOverride AuthConfig Limit Require all granted </Directory> <Directory "/opt/lampp/phpsqliteadmin"> AllowOverride AuthConfig Limit Require all granted </Directory>意思就是将接受本地请求授权为接受所有请求
此时xampp和PHPmyadmin页面就都可以自由的从外网访问了!
还没有完成:还需设置Centos的防火墙:
查看已经开放的端口: firewall-cmd --list-ports 开启端口 firewall-cmd --zone=public --add-port=80/tcp --permanent #设置这一句重启防火墙即可 开放80端口给外界访问,一定要重启防火墙生效 命令含义: –zone #作用域 –add-port=80/tcp #添加端口,格式为:端口/通讯协议 –permanent #永久生效,没有此参数重启后失效 重启防火墙 firewall-cmd --reload #重启firewall systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
附件下载:CentOS7x8664DVD1511.iso 提取码:8ub2