搭建LAMP环境即linux+apache+mysql+php
一,安装apache2,Apache在centos系统中,其实叫"httpd",可以使用yum来安装
1、查看httpd包是否可用
yum list | grep httpd
2、安装apache yum install httpd
3、配置ServerName
如果出现这个问题,
就是没有域名,则需要去
/etc/httpdd/conf/httpd.conf
这个文件下修改,将这一行取消注释,并将它的端口设为80ServerName localhost:8
4、常用指令
启动
httpd -k start
停止
httpd -k stop
设置开机自动启动
chkconfig httpd on
5、说明 默认的主配置文件是/etc/httpd/config/httpd.conf
Apache默认将网站的根目录指向/var/www/html
默认主配置文件/etc/httpd/conf/httpd.conf
配置存储在/etc/httpd/conf.d、目录
6、开放80端口
iptables-cmd --zone=public --add-port=80/tcp --permanent
命令含义:
--zone #作用域 --add-port=80/tcp #添加端口,格式为:端口/通讯协议 --permanent #永久生效,没有此参数重启后失效
重启防火墙
iptables-cmd --reload
查看状态
iptables-cmd --state
<1>例如 查询9200端口是否打开
命令如下: iptables-cmd --query-port=9200/tcp
返回yes 表示打开
<2>打开9300端口
命令如下:iptables-cmd --add-port=9300/tcp
如果看到这个页面,就表示apache已经成功搭建了
二、安装mysql
# 下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-community-server
service mysqld start
shell> systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: active (running) since 五 2016-06-24 04:37:37 CST; 35min ago
Main PID: 2888 (mysqld)
CGroup: /system.slice/mysqld.service
└─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
6月 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server...
6月 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.
service enable mysqld
service daemon-reload
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
或者:
set password for 'root'@'localhost'=password('MyNewPass4!');
yum install mysql-community-server
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
error: Failed dependencies:
epel-release >= 7 is needed by webtatic-release-7-3.noarch
yum -y install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w
[root@moliangjun /]# php -v
PHP 7.0.18 (cli) (built: Apr 15 2017 07:09:11) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
#php -v
#rpm -qa|grep php