1、安装yumyum update2、安装nginx源:yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpmyum repolist enabled | grep nginx*安装nginxyum -y inst...
1、安装yum
yum update
2、安装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
systemctl start nginx
设置开机自启动
systemctl enable nginx.service
3、检查开机自启动是否设置成功
systemctl list-dependencies | grep nginx
4、浏览器中输入公网ip,检测是否安装成功
出现如下则成功
5、安装mysql
安装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 install mysql-community-devel
启动mysql
systemctl mysqld start
检查mysql启动是否正常
sytemctl mysqld status 或者 ps -ef | grep mysql
设置mysqld服务开机自启动
systemctl enable mysqld.service
检查mysqld开机自启动是否设置成功
systemctl list-dependencies | grep mysqld
mysql5.7以后的争强了安全机制, 所以使用yum安装,启动会系统会自动生成一个随机的密码,修改mysql密码
查看mysql的随机密码
grep 'temporary password' /var/log/mysqld.log
使用查询得到的随机密码在终端登录
mysql -u root -p 更改密码(mysql文档规定,密码必须包括大小写字母数字加特殊符号>8位) 根据获取的随机密码登录
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Yourpassword';修改密码
退出mysql客户端,用刚才修改的密码登录确保密码修改成功 exit;
使用新密码登录
6、安装php
安装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
安装php扩展源(这是php7.1的安装其他版本直接把7.1直接改成7.2)
yum repolist enabled | grep "webtatic*"
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 -m
验证php是否安装成功
php -v 会出现php的班本信息
7、配置nginx文件
新建.conf后缀的文件文件目录在/etc/nginx/conf.d/下面 复制下面内容放进去
server {
listen 80;
server_name danshufenxiang.com;
root /home/www; #自定义站点位置
index index.php index.html index.htm;
location / {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
本文标题为:php中linux搭建lnmp环境
基础教程推荐
- PHP实现Redis单据锁以及防止并发重复写入 2022-10-12
- php array分组,PHP中array数组的分组排序 2022-08-01
- laravel ORM关联关系中的 with和whereHas用法 2023-03-02
- PHP命名空间简单用法示例 2022-12-01
- thinkphp3.2.3框架动态切换多数据库的方法分析 2023-03-19
- 在Laravel中实现使用AJAX动态刷新部分页面 2023-03-02
- PHP中的错误及其处理机制 2023-06-04
- PHP获取MySQL执行sql语句的查询时间方法 2022-11-09
- laravel 解决多库下的DB::transaction()事务失效问题 2023-03-08
- 使用PHP开发留言板功能 2023-03-13