centos7yum安装LNMP

-----------安装nginx----------

  rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
  yum info nginx
  yum install epel-release
  yum install epel-release -y
  yum install -y nginx
  systemctl  start nginx
  systemctl enable nginx

-----------安装php------------

yum install -y php php-devel php-fpm php-mysql php-common php-devel php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel
systemctl start php-fpm
systemctl enable php-fpm

-----------安装mysql---------

rpm  -ivh  http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
yum install mysql-community-server -y 
systemctl start mysqld 
systemctl enable mysqld 

找出密码 grep
'temporary password' /var/log/mysqld.log 首先,修改validate_password_policy参数的值 mysql> set global validate_password_policy=0;

#修改密码的长度
mysql>set global validate_password_length=1;
再次执行修改密码就可以了 
ALTER USER
'root'@'localhost' IDENTIFIED BY 'root123';
授权其他机器登陆(可以不执行)
GRANT ALL PRIVILEGES ON
*.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;

 -----创建站点目录-----

mkdir -p /usr/share/nginx/html/www

mv /usr/share/nginx/html/index.html   /usr/share/nginx/html/www/

------编辑nginx配置文件----

vim  /etc/nginx/conf.d/php.conf

server {
    server_name 192.168.1.30;
    listen 80;
    root html/www;
    index index.php index.html;
location / {
            if (!-f $request_filename){
                rewrite ^/(.+)$ /index.php last;
        }
    location ~ .php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
       # fastcgi_param  SCRIPT_FILENAME  html$fastcgi_script_name;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
}
}
}

测试

-----php页面测试添加-----

cat >/usr/share/nginx/html/www/test_info.php<<EOF
<?php phpinfo(); ?>
EOF

原文地址:https://www.cnblogs.com/wangyong-blog/p/9618390.html