ubuntu

作者: 小小怪吃吃吃 | 来源:发表于2018-07-30 16:01 被阅读0次

环境搭建

ubuntu18.04.1下快速搭建LNMP环境(PHP7.2.5+MySql5.7+Nginx1.14.0)

一、nginx
参考:https://www.linuxidc.com/Linux/2018-05/152257.htm

**均需要sudo提权**
更新:apt update
安装nginx :apt install nginx
检查nginx服务的状态和版本:
        systemctl status nginx
        nginx -v
配置防火墙:
        ufw allow 'Nginx Full'
验证更改:
        ufw status
使用systemctl管理Nginx服务:
        停止nginx服务:systemctl stop nginx
        再次启动:systemctl start nginx
        重新启动:systemctl restart nginx
        在进行配置更改后重新加载nginx服务:systemctl reload nginx
        禁用nginx服务在启动时启动:systemctl disable nginx
        重新启用:systemctl enable nginx

二、MySQL
参考:http://www.mamicode.com/info-detail-2327939.html

安装mysql:sudo apt-get install mysql-server mysql-client 
修改密码:
初始密码为空
mysql> use mysql;
mysql> update mysql.user set authentication_string=PASSWORD('新密码'), plugin='mysql_native_password' where user='root';
mysql>flush privileges;

三、PHP7.2.5安装

apt-get install php7.2 php7.2-fpm php7.2-mysql

四、配置Nginx解析PHP
1、nginx配置文件

首先修改nginx配置文件:vim /etc/nginx/sites-available/default
修改41行 为:root /var/www;
修改location php:见下图
然后重启nginx:service nginx restart
image.png

2、php配置文件

接下来修改php相关配置文件:vim /etc/php/7.2/fpm/pool.d/www.conf
image.png

3、重启php7.2-fpm

service php7.2-fpm start

五、检测

1、在/var/www里面新建info.php文件,然后查看localhost/info.php 。
<?php oh-info();>
2、在/var/www里面新建mysql.php文件。
<?php echo ‘<h1>Page loaded with PHP!</h1>‘;
$conn = mysqli_connect(‘localhost‘, ‘site_admin‘, ‘your_password‘);

if(!$conn){
    die(‘<h2>Error: </h2>‘ . mysqli_connect_error());
}else{
    echo ‘<h2>Successfully Connected to MySQL Database!</h2>‘;
}
?>

设置vim显示行号

一、临时显示行号

输入:set number

二、永久性显示行号

一般在当前用户的根目录下创建vimrc文件,即使用下面的命令: 
vim ~/.vimrc
在打开的vimrc文件中最后一行输入:set number ,然后保存退出。

配置网卡文件

'''sudo vi /etc/network/interfaces'''

相关文章

网友评论

      本文标题:ubuntu

      本文链接:https://www.haomeiwen.com/subject/blkfvftx.html