因为CentOS的gcc版本太低,升级新版本的gcc太麻烦,懒得升级了,所以直接换了Ubuntu。以前都用LNMP一键安装脚本,这次,打算练练手,就打算用apt-get手动安装(不要问我为什么不编译安装,因为太慢了..上一次编译了一天)

1.安装MySQL

直接运行以下命令即可安装

[bash] apt-get install mysql-server [/bash]

输入以下命令配置

[bash] mysql_secure_installation [/bash]

我的设置我贴出来,如下

[bash] #1 VALIDATE PASSWORD PLUGIN can be used to test passwords… Press yY for Yes, any other key for No: N (我的选项) #2 Please set the password for root here… New password: (输入密码) Re-enter new password: (重复输入) #3 By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them… Remove anonymous users? (Press yY for Yes, any other key for No) : N (我的选项) #4 Normally, root should only be allowed to connect from ‘localhost’. This ensures that someone cannot guess at the root password from the network… Disallow root login remotely? (Press yY for Yes, any other key for No) : Y (我的选项) #5 By default, MySQL comes with a database named ‘test’ that anyone can access… Remove test database and access to it? (Press yY for Yes, any other key for No) : N (我的选项) #6 Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press yY for Yes, any other key for No) : Y (我的选项) [/bash]

2.安装Nginx

输入以下命令安装最新版的Nginx

[bash] sudo apt-get install nginx [/bash]

3.安装php和php常用扩展

输入以下命令安装php7.3

[bash] sudo apt-get install php7.3-fpm php7.3-cli php7.3-cgi php7.3-mysql [/bash]

4.修改配置文件

[bash] sudo nano /etc/nginx/sites-enabled/default [/bash]

取消注释掉以下部分,注意:不要同时取消注释两个fastcgi_pass,否则会报错

输入以下命令启动Web环境

[bash] nginx sudo /etc/init.d/nginx restart php sudo /etc/init.d/php start [/bash]

5.完成!

在/var/www/html/下创建php文件,并且在里面输入

[php][/php] [/bash]

如果不出所料的话,打开你的IP即可看到phpinfo

6.一些问题

1.MySQL

我在用phpMyAdmin时候出现无法登陆错误,报错(HY000/1698):Access denied for user ‘root‘@’localhost’

我也不清楚为什么会出现这个错误,于是我网上查了一下,把网上的内容贴出来

[bash] sudo mysql -u root -p #登陆MySQL use mysql; UPDATE user SET plugin=’mysql_native_password’ WHERE User=’root’; FLUSH PRIVILEGES; exit; [/bash]

然后,密码会清空,再次输入 mysql_secure_installation 配置一下密码就可以正常用MySQL登陆了


广告
广告正在加载中...
暂不开放评论,如对本文有任何疑问或建议,请联系apple@mr-wu.top
All Tags