ubuntu17.10装mysql_apt方式安装LNMP环境教程(ubuntu17.10|PHP7.1)

文章目录

[隐藏]

1. 简要说明

2. 安装MYSQL 5.7

3. 安装Nginx

4. 安装PHP7.1

5. 配置nginx

6. 使PHP7.1支持MySQL

1. 简要说明

安装环境是阿里云ubuntu17.10,这个教程里我把域名都写成hostname.com, ip都写成192.168.1.1,你可以根据自己的需要更换。另外如果不是root账户的话,最好切换到root账户。

sudo su

2. 安装MYSQL 5.7

我们使用apt-get方式安装MySQL:

apt-get -y install mysql-server mysql-client

安装的时候会要求你输入MySQL的root密码,建议此时输入,比较方便。

输入以下命令,让MySQL更安全:

mysql_secure_installation

我们将会被问这些问题:

root@root:~# mysql_secure_installationSecuring the MySQL server deployment.Enter password for user root: 这里输入MySQL密码VALIDATE PASSWORD PLUGIN can be used to test passwordsand improve security. It checks the strength of passwordand allows the users to set only those passwords which aresecure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key for No: 想要让MySQL验证密码强度可以填Y,但个人建议N。otherwise.Using existing password for root.Change the password for root ? ((Press y|Y for Yes, any other key for No) : 建议NoBy default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : 这个要填YSuccess.Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : 是否允许root远程登录?想要更安全选Y,但我建议选N,可以避免很多问题。Success.By default, MySQL comes with a database named 'test' thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 这个选Y,移除没用的test表。- Dropping test database...Success.- Removing privileges on test database...Success.Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : 选YSuccess.All done!

MySQL就装好了。

3. 安装Nginx

apt-get install nginx

apt-get install nginx

然后你打开你的IP地址或域名,就能看见nginx默认页面了。

d8f7ee3b8a04dd8bf90995274bb637e8.png

nginx默认的路径在/var/www/html

4. 安装PHP7.1

我们搭建wordpress博客主要要用到php-fpm组件,我们apt-get它,ubuntu会自动安装必要的php程序。

apt-get -y install php7.1-fpm

5. 配置nginx

编辑nginx的默认站点配置文件

vim /etc/nginx/sites-available/default

server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf;root /var/www/html;# Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html;server_name _;location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; }# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ .php$ { include snippets/fastcgi-php.conf; # With php7.0-cgi alone: fastcgi_pass 127.0.0.1:9000; # With php7.0-fpm: # fastcgi_pass unix:/run/php/php7.0-fpm.sock; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /.ht { deny all; }}

另外需要注意,我们是要安装wordpress的,所以又一个index的地方(# Add index.php to the list),在index后面要增加index.php

PHP-FPM默认是通过socket连接的,我们要改成用TCP链接。

vim /etc/php/7.0/fpm/pool.d/www.conf

修改listen:

;listen = /var/run/php5-fpm.sock listen = 127.0.0.1:9000

像上面那样修改后,重启nginx:

service nginx restart

然后打开:

vim /etc/php/7.1/fpm/php.ini

设置cgi.fix_pathinfo=0

; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting; of zero causes PHP to behave as before. Default is 1. You should fix your scripts; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.; http://php.net/cgi.fix-pathinfocgi.fix_pathinfo=0

reload php-fpm:

service php7.0-fpm reload

新建一个文件:

vim /var/www/html/info.php

写入

然后我们可以打开浏览器输入域名,例如 192.168.1.1/info.php(你的显示应该是php7.1)

8b68d8a06459e5f661cb28c94c5beaaf.png

你可以看到PHP已经工作了,包括现在支持的一些模块。

6. 使PHP7.1支持MySQL

我们可以先看一下有哪些PHP7.1的模块:

apt-cache search php7.1

可以选一些你喜欢的模块安装(以下是我自己安装的):

apt-get -y install php7.1-mysql php7.1-gd php7.1-curl php7.1-intl php7.1-mcrypt

reload PHP-FPM:

service php7.1-fpm reload

刷新一下192.168.1.1/info.php,看一下自己的模块是否都安装好了。

这样就安装配置好了,接下来就可以在/var/www/html里上传wordpress文件了。

原文出处:qiujunya -> https://qiujunya.com/lnmpphp71.html

本项目是一个基于SSM(Spring+SpringMVC+MyBatis)框架和Vue.js前端技术的大学生第二课堂系统,旨在为大学生提供一个便捷、高效的学习和实践平台。项目包含了完整的数据库设计、后端Java代码实现以及前端Vue.js页面展示,适合计算机相关专业的毕设学生和需要进行项目实战练习的Java学习者。 在功能方面,系统主要实现了以下几个模块:用户管理、课程管理、活动管理、成绩管理和通知公告。用户管理模块支持学生和教师的注册、登录及权限管理;课程管理模块允许教师上传课程资料、设置课程时间,并由学生进行选课;活动管理模块提供了活动发布、报名和签到功能,鼓励学生参与课外实践活动;成绩管理模块则用于记录和查询学生的课程成绩和活动参与情况;通知公告模块则实时发布学校或班级的最新通知和公告。 技术实现上,后端采用SSM框架进行开发,Spring负责业务逻辑层,SpringMVC处理Web请求,MyBatis进行数据库操作,确保了系统的稳定性和扩展性。前端则使用Vue.js框架,结合Axios进行数据请求,实现了前后端分离,提升了用户体验和开发效率。 该项目不仅提供了完整的源代码和相关文档,还包括了详细的数据库设计文档和项目部署指南,为学习和实践提供了便利。对于基础较好的学习者,可以根据自己的需求在此基础上进行功能扩展和优化,进一步提升自己的技术水平和项目实战能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值