yum安装 lnmp (linux+nginx+php7.1+mysql5.7)
1、第一步先更新yum
yum update
2、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 nginx
启动nginx
/bin/systemctl restart nginx.service
3、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 mysqld
#查看密码和修改密码
扫描二维码关注公众号,回复:
7607197 查看本文章
5.7 这样改: set global validate_password_policy=0; set global validate_password_length=1; mysql8.0 这样改: mysql> set global validate_password.policy=0; mysql> set global validate_password.length=1; mysql>
|
4、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-fpm
5.单独安装redis
yum install redis
#修改配置
vi /etc/redis.conf
#daemonize yes 后台运行
#appendonly yes 数据持久化
service redis start
6.安装php-redis扩展
#先装git
yum install git
#git下扩展
cd /usr/local/src
git clone https:#github.com/phpredis/phpredis.git
#安装扩展
cd phpredis
phpize
#修改php配置
vi /etc/php.ini 添加extension=redis.so
#重启php
service php-fpm restart
www.xxx.conf
server {
listen 80;
server_name more.xuanxuankeji.com;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html/more;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html/more;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}