资讯专栏INFORMATION COLUMN

centos7 下配置lnmp

RiverLi / 686人阅读

摘要:安装安装增加一个配置文件配置如下连接还有连接配置文件位置修改下载安装源设置开机启动重载所有修改过的配置文件安装完成之后,生成的默认密码在文件中。或者修改为允许远程连接不推荐添加一个允许远程连接的帐户

rpm -Uvh http://nginx.org/packages/cen...

安装 yum install nginx

systemctl start nginx.service

rpm -Uvh https://dl.fedoraproject.org/...

rpm -Uvh https://mirror.webtatic.com/y...

安装php yum install -y php70w php70w-mysql.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-fpm

systemctl start php-fpm.service

增加一个nginx配置文件配置如下

server {
listen 80;
server_name test.com;
root /usr/share/nginx/html;

index index.html index.htm index.php;

charset utf-8;

location / {

try_files $uri $uri/ /index.php?$query_string;

}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

access_log off;

client_max_body_size 100m;

location ~ .php$ {

fastcgi_pass   127.0.0.1:9000;   #tcp连接 还有socket连接
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include        fastcgi_params;

}

location ~* .(otf|eot|svg|ttf|woff)$ {

add_header Access-Control-Allow-Origin *;

}

location ~* ^.+.(jpg|jpeg|gif|png|swf|rar|zip|css|js|pdf|ico|html)$ {

access_log off;
expires 30d;
break;

}

location ~ /.ht {

deny all;

}
}

systemctl restart nginx

php-fpm配置文件位置:(/etc/php-fpm.d/www.conf)
​ 修改

user =nginx
​group=nginx

systemctl restart php-fpm.service

mysql
下载
wget https://dev.mysql.com/get/mys...

安装 mysql 源
yum localinstall mysql57-community-release-el7-11.noarch.rpm

yum install -y mysql-community-server

systemctl start mysqld

systemctl status mysqld

设置开机启动
shell> systemctl enable mysqld
重载所有修改过的配置文件
shell> systemctl daemon-reload

mysql 安装完成之后,生成的默认密码在 /var/log/mysqld.log 文件中。使用 grep 命令找到日志中的密码。

shell> grep "temporary password" /var/log/mysqld.log

首次通过初始密码登录后,使用以下命令修改密码

shell> mysql -uroot -p
mysql> ALTER USER "root"@"localhost" IDENTIFIED BY "MyNewPass4!";

默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须添加一个允许远程连接的帐户。或者修改 root 为允许远程连接(不推荐)
添加一个允许远程连接的帐户
mysql> GRANT ALL PRIVILEGES ON . TO "zhangsan"@"%" IDENTIFIED BY "Zhangsan2018!"

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/31658.html

相关文章

  • 虚拟机Linux Centos7搭建web环境(LNMP

    摘要:本文内容是,如何在下快速搭建环境。虚拟机实体机环境都可以。按照提示,输入。 本文内容是,如何在Linux centos7下快速搭建LNMP环境。虚拟机、实体机环境都可以。另外,安装教程参考的是,下面这篇文章进行文字排版和内容扩充,感谢hcchanqing作者。CentOS6.2 yum安装配置LNMP服务器(Nginx+PHP+MySQL) 特别提醒:本文系统用的Centos7,是7!...

    Enlightenment 评论0 收藏0
  • 虚拟机Linux Centos7搭建web环境(LNMP

    摘要:本文内容是,如何在下快速搭建环境。虚拟机实体机环境都可以。按照提示,输入。 本文内容是,如何在Linux centos7下快速搭建LNMP环境。虚拟机、实体机环境都可以。另外,安装教程参考的是,下面这篇文章进行文字排版和内容扩充,感谢hcchanqing作者。CentOS6.2 yum安装配置LNMP服务器(Nginx+PHP+MySQL) 特别提醒:本文系统用的Centos7,是7!...

    Cristic 评论0 收藏0

发表评论

0条评论

RiverLi

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<