centos安裝web服務器 LAMP(Linux Apache MySQL PHP)

centos7上搭建http服務器,yum搭建LAMP環境,linux下搭建PHP+apache+mysql環境

首先更新源(要安裝新版本的LAMP,這裏使用第三方yum源):

CentOs 6.x
    rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
CentOs 7.x  
    rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

演示服務器linux系統版本(阿里雲新服務器)

cat /etc/issue
#或者
cat /etc/redhat-release

CentOS release 6.8 (Final)

安裝對應版本的源

yum install epel-release

Complete!

#安裝httpd(apache)
yum -y install httpd
#啓動服務
service httpd start
#將httpd加入啓動項中 開啓自啓動
chkconfig httpd on


#重啓apache
service httpd restart
#停止apache
service httpd stop

如果是阿里雲的服務器記得打開80端口,在安全組配置 - 配置規則 - 添加安全組規則 協議類型選擇 HTTP (80)

安裝指定版本的php5.6、mysql

yum -y install php56w-devel php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64  php56w-pdo.x86_64 php56w-pear.noarch php56w-pecl-igbinary.x86_64 php56w-pecl-redis.x86_64 php56w-bcmath.x86_64 php56w-fpm.x86_64

Complete!

如果需要先卸載低版本再安裝Mysql5.7版本 查看這個地址  >>   Linux 卸載安裝Mysql(圖文卸載安裝方法)

#mysql5.7

#下載centos6的 mysql rpm包

wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm

yum -y install wget

繼續

yum localinstall -y mysql57-community-release-el6-9.noarch.rpm
yum -y install mysql-community-server

Complete!

如果是centos7

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

rpm -ivh mysql57-community-release-el7-8.noarch.rpm

yum -y install mysql-server

systemctl enable mysqld.service

systemctl start mysqld.service

#設置mysql自啓動
chkconfig mysqld on
#啓動mysql
service mysqld start
#查找Mysql5.7 默認密碼
grep 'temporary password' /var/log/mysqld.log
#登錄Mysql
mysql -uroot -p

Mysql 相關操作

-- 設置密碼爲TLEwOIF:Y|>G@H1 '' 引號中間輸入自定義密碼

ALTER USER 'root'@'localhost' IDENTIFIED BY 'TLEwOIF:Y|>G@H1';

-- 開啓遠程連接(外網訪問)

use mysql;
update user set host = '%' where user = 'root'; 

-- 刷新權限

FLUSH PRIVILEGES;

-- 檢測遠程連接開啓狀態

select user,host from user;

 

注:開啓遠程訪問 一般情況下,外網的服務器需要開啓3306端口,(阿里雲)在安全組配置 - 配置規則 - 添加安全組規則 協議類型選擇 MySQL (3306)

#重啓Mysql

service mysqld restart

#停止Mysql

service mysqld stop

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章