centos7之lnmp安装

1.安装nginx

[php]  view plain  copy
  1. yum install yum-priorities -y    
  2. wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm    
  3. rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm    
  4. yum install nginx   

[php]  view plain  copy
  1. systemctl start nginx.service #启动nginx  #若启动失败,应先更改端口号在重新启动  
  2. systemctl stop nginx.service #停止nginx  
  3. systemctl restart nginx.service #重启nginx   
  4. systemctl enable nginx.service #设置开机启动    

2.更改nginx端口号(根据自己需求)

[php]  view plain  copy
  1. cd /etc/nginx/conf.d/    
  2. vim default.conf    
  3. 把listen 80改成listen 81    
[php]  view plain  copy
  1. systemctl restart nginx.service #重启nginx  

3.访问http://ip:81即可看到nginx首页 

#比如 http://192.168.1.121:81

4.下一步安装php-fpm

[php]  view plain  copy
  1. yum install php-fpm    
  2. systemctl start php-fpm.service #启动php-fpm    
  3. systemctl enable php-fpm</span>.service #设置开机启动   

5.更改nginx配置文件识别php vi /etc/nginx/conf.d/default.conf,把之前的#给去掉就可以了,顺手改一下fastcgi_param

[php]  view plain  copy
  1. location ~ \.php$ {    
  2.     root           html;    
  3.     fastcgi_pass   127.0.0.1:9000;    
  4.     fastcgi_index  index.php;    
  5.     fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/$fastcgi_script_name;    
  6.     include        fastcgi_params;    
  7. }   

6.访问http://ip:81/test.php即可看到nginx中的php页面

#路径为   cd /usr/share/nginx/html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以按照以下步骤在CentOS 7上安装LNMP(Linux + Nginx + MySQL + PHP): 1. 首先,需要更新YUM源。您可以使用以下命令添加EPEL源和IUS源: ``` yum install \ https://repo.ius.io/ius-release-el7.rpm \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm ``` 2. 接下来,安装必要的依赖库。您可以使用以下命令安装所需的依赖库: ``` yum install libevent* libtool* autoconf* libstd* ncurse* bison* openssl* ``` 3. 然后,需要安装cmake,因为自MySQL 5.5版本之后,需要使用cmake来支持编译安装。您可以使用以下命令安装cmake: ``` yum install cmake ``` 4. 最后,您需要将Nginx的软件源添加到CentOS 7系统中。您可以使用以下命令添加Nginx软件源: ``` yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm ``` 完成以上步骤后,您就可以继续安装LNMP环境了。这些步骤将帮助您在CentOS 7上安装LNMP123 #### 引用[.reference_title] - *1* *3* [Centos7部署LNMP](https://blog.csdn.net/qq_54735393/article/details/127199833)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *2* [CentOS7搭建LNMP环境](https://blog.csdn.net/weixin_46078817/article/details/103687975)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值