从零开始学网站开发——2.搭建Linux+Nginx+MySQL+PHP环境
从零开始学网站开发——2.搭建LNMP环境 nginx的安装配置,mariadb(mysql)的安装配置,php的安装配置,phpmyadmin的安装和配置)https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/01098d4d8e3d4ac7911e139106a46f01~tplv-tt-large.image?x-expires=1969343867&x-signature=ErKsw1rr8NaXQ7FKIilhxfyFZgM%3D在终端登录测试服务器
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/0a12590526944bfd8009c35c7b852b0d~tplv-tt-large.image?x-expires=1969343867&x-signature=g8vrN3qrHRnMLWvmYsmWz7xWc5w%3D
sudo apt install nginx安装nginxhttps://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/585ace06f25f4fbca3244bfe88659e72~tplv-tt-large.image?x-expires=1969343867&x-signature=94sCd0JRnkQ8toG%2BlTS9oPxFOzQ%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/efd6c3b50ea249fa8c709294c913a4b7~tplv-tt-large.image?x-expires=1969343867&x-signature=9RyGcBRnFdLWtSJ5G3bCSRIhiwk%3D
在浏览器输入http://192.168.11.37/(假造机的ip地址),可以看到一个nginx的默认欢迎界面。这就证实我们的nginx安装成功了!
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/cd46514e7a034e8cba25f87ee69eb07e~tplv-tt-large.image?x-expires=1969343867&x-signature=R1iA6xljpZEcY9nCzBkyWpUDhQA%3D
sudo apt install mariadb-server安装mariadb(mysql),这个数据库服务器跟mysql一样用。https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/b635078500134cedb87c4b464b505d03~tplv-tt-large.image?x-expires=1969343867&x-signature=Vntx5lqNGzHDCtv50arK1SBwN2Y%3D
sudo mysql_secure_installation安装完成后,首次运行 MySQL / MariaDB 的设置,默认会问我们输入暗码,我们直接回车即可。https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/60f003f37cab4e3b99a11eed8475fbba~tplv-tt-large.image?x-expires=1969343867&x-signature=NkQ%2FIyNnrc5mkLGluw5IPSKt2yY%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/d466ea6d96754bf3b38c3f77e4268084~tplv-tt-large.image?x-expires=1969343867&x-signature=POfgumGd9bZ%2Be1YUSZeGEHqgZX0%3D设置root暗码
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/fc374278e4794ce1afc5b6107beff91b~tplv-tt-large.image?x-expires=1969343867&x-signature=z%2BSB3fF68IL02GCn1Sl%2FvSKqxO8%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/c60051b3db5c4ac1891eeadfb08f31dc~tplv-tt-large.image?x-expires=1969343867&x-signature=lw11F27pU6jebQb5R%2B11ENw68N8%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/ceb34754fd574b37b7b18fc7a76c5b49~tplv-tt-large.image?x-expires=1969343867&x-signature=qFvt0b%2BDWZKI3oxmrNCZQH2mWOA%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/820acb63597d4b6cbf60f94732712ad9~tplv-tt-large.image?x-expires=1969343867&x-signature=0rD9krVOIEDVFToPE7MJyAiuF9o%3D
sudo mariadb连接到mariadb,进行一些数据库的配置1.use mysql;2.update user set authentication_string=password('root'),plugin='mysql_native_password' where user='root';第二步的作用是设置数据库服务器的root暗码为root,并让root可以用暗码登录。3.flush privileges;第三步,刷新权限4.exit 退出mariadbhttps://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/2689d99184c74ac59283843f442f4724~tplv-tt-large.image?x-expires=1969343867&x-signature=KHI%2B2%2FbxnBg2qifldIxc%2BcPAUs8%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/2e720de891484da5b452f973edad24e7~tplv-tt-large.image?x-expires=1969343867&x-signature=AQ4GvOemU13qqbMohfejyGwh288%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/fdd87ced21924bf1b775fb1657ea4b16~tplv-tt-large.image?x-expires=1969343867&x-signature=9BfABAgn5ZpQWF2un8LHdkwiato%3D
mariadb -u username -p连接数据库https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/357fb4a08c7845b8a4ff3a39cc4336f1~tplv-tt-large.image?x-expires=1969343867&x-signature=7ml%2BDeH8gIqrMWDt1n%2BpoXVr5AY%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/91205395b1b34ccb9095c3799168ad88~tplv-tt-large.image?x-expires=1969343867&x-signature=1HmRWdFEV9GFbhBFwYU5Zs6%2BkiE%3D
SHOW DATABASES;表现数据库服务器中的所有数据库https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/a5057315c1484565831881192a7e8f6b~tplv-tt-large.image?x-expires=1969343867&x-signature=FdHmEkxdSwnPzyxZygTIeOv7P4E%3D
sudo apt install php-fpm php-mysql php-mbstring安装php-fpm和一些必备拓展https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/74f315a2ba3c475588641a9736d13525~tplv-tt-large.image?x-expires=1969343867&x-signature=vy1aIwdQ0W3loS5%2FLXi%2FYD6nesU%3D
sudo nano /etc/nginx/sites-available/default编辑nginx默认站点配置主要的点就是下图的红色标注部分编辑完成按ctrl+x,然后输入Y,然后回车保存完成https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/c685bf04077941fcbf29337b3a00ffbd~tplv-tt-large.image?x-expires=1969343867&x-signature=4%2BwuicUoViXN3m9vy%2FlQdJcRjKc%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/d57d8ca6ee4e432c9ab510a38caabe8d~tplv-tt-large.image?x-expires=1969343867&x-signature=K0Kph1QfFzT6CdgX%2BMo3sE%2FpUss%3D
https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/5b68b2625ce148a5b7ce552a379571f0~tplv-tt-large.image?x-expires=1969343867&x-signature=qamur2zvDDlZvbYnvYGzoTHVDiA%3D
sudo service nginx restart重启nginx服务,让刚才的改动见效https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/ddd1f70eb8ca4327afceeff3da90793c~tplv-tt-large.image?x-expires=1969343867&x-signature=dKoSqKaeS%2FS8CKV5KGm4oss060w%3D
sudo nano /var/www/html/info.php创建一个测试的php文件https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/daf09820fe9e494c86045f056f106349~tplv-tt-large.image?x-expires=1969343867&x-signature=oyfR72Ov8oyu%2FroNcsQYqEIe0rA%3D
页:
[1]