当前位置: 首页 > 后端技术 > PHP

centos7下配置lnmp

时间:2023-03-29 18:12:21 PHP

rpm-Uvhhttp://nginx.org/packages/cen...安装yuminstallnginxsystemctlstartnginx.servicerpm-Uvhhttps://dl.fedoraproject.org/...rpm-Uvhhttps://mirror.webtatic.com/y...安装phpyuminstall-yphp70wphp70w-mysql.x86_64php70w-gd.x86_64php70w-ldap.x86_64php70w-mbstring.x86_64php70w-mcrypt.x86_64php70w-fpmsystemctlstartphp-fpm.service添加一个nginx配置文件,配置如下server{listen80;服务器名称test.com;root/usr/share/nginx/html;indexindex.htmlindex.htmindex.php;charsetutf-8;location/{try_files$uri$uri//index.php?$query_string;}location=/favicon.ico{access_log关闭;log_not_found关闭;}location=/robots.txt{access_logoff;log_not_found关闭;}access_logoff;client_max_body_size100m;位置~.php${fastcgi_pass127.0.0.1:9000;#tcp连接和socket连接fastcgi_split_path_info^(.+\.php)(/.+)$;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi;}location~*.(otf|eot|svg|ttf|woff)${add_headerAccess-Control-Allow-Origin*;}location~*^.+.(jpg|jpeg|gif|png|swf|rar|zip|css|js|pdf|ico|html)${access_logoff;expires30d;break;}location~/.ht{denyall;}}systemctlrestartnginxphp-fpm配置文件位置:(/etc/php-fpm.d/www.conf)修改用户=nginxgroup=nginxsystemctlrestartphp-fpm.servicemysql下载wgethttps://dev.mysql.com/get/mys...安装mysql源码yumlocalinstallmysql57-community-release-el7-11.noarch.rpmyuminstall-ymysql-community-serversystemctlstartmysqldsystemctlstatusmysqldsetbootshell>systemctlenablemysqldreloadallmodifiedconfigurationfilesshell>systemctldaemon-reloadmysql安装完成后生成默认密码使用/var/log/mysqld.log文件中的grep命令在日志中查找密码。shell>grep'temporarypassword'/var/log/mysqld.log首次使用初始密码登录后,使用以下命令修改密码shell>mysql-uroot-pmysql>ALTERUSER'root'@'本地主机'由'MyNewPass4!'标识;默认情况下,本地只允许root账号登录。如果要连接其他机器上的mysql,必须添加允许远程连接的账户。或者修改root允许远程连接(不推荐)添加一个允许远程连接的账户mysql>GRANTALLPRIVILEGESON。TO'zhangsan'@'%'IDENTIFIEDBY'Zhangsan2018!'