LNMP
LNMP
含义:就是搭建一个博客系统
分别的含义
linux::一个操作系统
nginx:一个网站服务器
mysql:一个数据库服务
php:一个编程语言
版本:
nginx |
nginx-1.16.1-1.el7.ngx.x86_64.rpm |
mariadb-server |
mariadb-server-5.5.52-1.el7.x86_64.rpm |
php |
php-5.4.16-46.1.el7_7.x86_64.rpm |
php-mysql |
php-mysql-5.4.16-46.1.el7_7.x86_64.rpm |
php-fpm |
php-fpm-5.4.16-46.1.el7_7.x86_64.rpm |
大概的流程:
1:解压压缩包,安装4软件 nginx mariadb-server php php-mysql php-fpm
2:配置nginx
3:配置mariadb
4:nginx网页文件的移动
5:防火墙和selinux的权限
6:访问
1:解压压缩包,yum源,安装软件
1 2 3 4 5 6 7 8 9 10 11 | [root@server ~]# unzip lnmp.zip [root@server ~]# unzip wordpress-4.7.3-zh_CN.zip #编写一个lnmp的yum源,就是里面有一些所需要的安装的软件 [lnmp] name=lnmp baseurl=file: ///root/lnmp/lnmp gpgcheck=0 enable=1 [root@server ~]# yum -y install mariadb-server nginx php php-mysql php-fpm |
2:配置nginx的配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | [root@server ~]# systemctl start nginx [root@server ~]# systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. [root@server ~]# systemctl start mariadb [root@server ~]# systemctl enable mariadb Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service. [root@server ~]# systemctl start php-fpm [root@server ~]# systemctl enable php-fpm #编写配置文件 #添加网站允许的网页文件的格式 location / { 9 root /usr/share/nginx/html; 10 index index.php index.html index.htm; 11 } # 修改脚本路径 location ~ \.php$ { 31 root /usr/share/nginx/html; 32 fastcgi_pass 127.0.0.1:9000; 33 fastcgi_index index.php; 34 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 35 include fastcgi_params; 36 } #重启nginx服务 [root@server ~]# systemctl restart nginx |
3:配置mysql数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | [root@server ~]# mysql_secure_installation Set root password? [Y/n] 是否设置root密码 Disallow root login remotely? [Y/n] 是否禁止root远程登录 Remove test database and access to it? [Y/n] 是否删除test数据库 Reload privilege tables now? [Y/n] 是否重新加载权限 MariaDB [(none)]> create database wordpress; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | wordpress | +--------------------+ 4 rows in set (0.00 sec) MariaDB [(none)]> exit |
4:nginx网页文件的移动
1 2 3 4 5 6 7 8 9 | [root@server ~]# cp -ar wordpress/* /usr/share/nginx/html/ [root@server ~]# cd /usr/share/nginx/html/ [root@server html]# ls 50x.html license.txt wp-admin wp-config-sample.php wp-includes wp-login.php wp-signup.php index.html readme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php #设置可执行的权限,网页文件 [root@server html]# chmod 777 -R ./ |
5:防火墙和selinux的权限的设置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #防火墙的放行 [root@server html]# firewall-cmd --permanent --add-service=http success [root@server html]# firewall-cmd --permanent --add-service=mysql success [root@server html]# firewall-cmd --reload success [root@server html]# firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: ens32 ens33 sources: services: dhcpv6-client http mysql ssh ports: protocols: masquerade: no forward-ports: sourceports: icmp-blocks: rich rules: #nginx网页文件selinux的上下文类型 [root@server html]# semanage fcontext -a -t 'httpd_sys_content_t' '/usr/share/nginx/html/(/.*)?' [root@server html]# restorecon -RFv /usr/share/nginx/html/ [root@server html]# ll -Z -rwxrwxrwx. root root system_u:object_r:httpd_sys_content_t:s0 50x.html -rwxrwxrwx. root root system_u:object_r:httpd_sys_content_t:s0 index.html -rwxrwxrwx. root root system_u:object_r:httpd_sys_content_t:s0 index.php -rwxrwxrwx. root root system_u:object_r:httpd_sys_content_t:s0 license.txt -rwxrwxrwx. root root system_u:object_r:httpd_sys_content_t:s0 readme.html |
6:访问
就是会出现少了一个文件,所以创建那个文件,就可以
http://192.168.10.100
总结:
当然也可以使用apache来搭建
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步