yum安裝 lnmp (linux+nginx+php7.1+mysql5.7)

一、第一步先更新yum updatephp

 

二、yum安裝nginx
安裝nginx最新源:
yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum repolist enabled | grep "nginx*"
安裝nginx:
yum -y install nginx
啓動nginx:
service nginx start
設置nginx服務器開機自啓動:
systemctl enable nginx.service
檢查開機自動是否設置成功:
systemctl list-dependencies | grep nginxmysql

 

三、yum安裝mysql5.7
安裝mysql源:
yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
安裝mysql:
yum -y install mysql-community-server mysql-community-devel
啓動mysql:
service mysqld start
檢查mysql啓動是否正常:
service mysqld status 或者 ps -ef | grep mysql
設置mysqld服務開機自啓動:
systemctl enable mysqld.service
檢查mysqld開機自啓動是否設置成功:
systemctl list-dependencies | grep mysqldnginx

 

#查看密碼和修改密碼git

#查看mysql的root帳號的密碼 grep 'temporary password' /var/log/mysqld.log 

#登陸mysql mysql -uroot -p 

#修改密碼 ALTER USER 'root'@'localhost' IDENTIFIED BY 'password'; 

#修改root用戶可遠程登陸 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; 

#刷新 flush privileges;

 

四、yum安裝php7.1
安裝php源:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
檢查源是否安裝成功;
yum repolist enabled | grep "webtatic*"
安裝php擴展源:
yum -y install php71w php71w-fpm
yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache
驗證php7.1.x和擴展是否安裝成功 :
驗證php是否安裝成功
php -v
驗證對應的擴展是否安裝成功
php -m
設置php-fpm並檢測php-fpm的運行狀態:
啓動php-fpm
service php-fpm star
檢查啓動是否成功
service php-fpm status
設置開機自啓動:
systemctl enable php-fpm.service
檢查開機自啓動是否設置成功:
systemctl list-dependencies | grep php-fpm
ps -ef | grep php-fpmgithub

 

################################################
5.單獨安裝redis
yum install redis
#修改配置
vi /etc/redis.conf
#daemonize yes 後臺運行
#appendonly yes 數據持久化
service redis startweb

 

6.安裝php-redis擴展
#先裝git
yum install gitredis

#git下擴展
cd /usr/local/src
git clone https:#github.com/phpredis/phpredis.gitsql

#安裝擴展
cd phpredis
phpizecentos

#修改php配置
vi /etc/php.ini 添加extension=redis.sobash

#重啓phpservice php-fpm restart

相關文章
相關標籤/搜索