龙空技术网

YUM安装LAMP与LNMP

聪明芒果yO 141

前言:

此刻小伙伴们对“lnmp上nginx重启”可能比较讲究,我们都想要分析一些“lnmp上nginx重启”的相关文章。那么小编同时在网上收集了一些对于“lnmp上nginx重启””的相关资讯,希望咱们能喜欢,兄弟们一起来了解一下吧!

LAMP动态网站部署架构是由一套 Linux+Apache+MySQL+PHP 组成的动态网站系统解决方案.LNMP动态网站部署架构是由一套 Linux+Nginx+MySQL+PHP 组成的动态网站系统解决方案.编译安装费时费力有时还会出错误,下面我们将通过Yum仓库,快速构建LANMP网站环境.

LAMP

1.配置yum源,安装依赖

yum install -y wgetwget -O /etc/yum.repos.d/CentOS-Base.repo 

2.安装LAMP5环境

yum install -y httpd httpd-devel mariadb mariadb-server mysql-devel php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

3.安装LAMP7环境

yum -y install epel-releaserpm -Uvh  -Uvh  install -y httpd httpd-devel mariadb mariadb-server mysql-devel php70w php70w-intl php70w-mysql php70w-common php70w-gd php70w-mbstring php70w-mcrypt php70w-devel php70w-xml
LNMP

1.配置yum源,安装依赖

wget -O /etc/yum.repos.d/CentOS-Base.repo  -y install epel-releaseyum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel libjpeg* libmcrypt libmcrypt-devel

2.安装Nginx

rpm -Uvh  install -y nginxsystemctl start nginxsystemctl enable nginx

3.安装与配置MySQL

yum install -y mariadb mariadb-serversystemctl start mariadbsystemctl enable mariadbmysql_secure_installation

4.安装PHP

yum install -y php php-devel php-fpm \php-mysql php-common php-gd php-imap \php-ldap php-odbc php-pear php-xml \php-xmlrpc php-mbstring php-mcrypt \php-bcmath php-mhashsystemctl start php-fpmsystemctl enable php-fpm

5.编辑PHP主配置文件

编辑配置文件,在PHP文件末尾追加写入以下标★语句

vim /etc/php.ini ★cgi.fix_pathinfo=1      #将注释去掉,开启PHP的pathinfo伪静态功能★max_execution_time = 0      #脚本运行的最长时间,默认30秒★max_input_time = 300     #脚本可以消耗的时间,默认60秒★memory_limit = 256M     #脚本运行最大消耗的内存,根据你的需求更改数值,默认128M★post_max_size = 100M      #单提交的最大数据,默认100M★upload_max_filesize = 10M    #上载文件的最大许可大小,默认2M

6.修改php-fpm的配置

编辑配置文件,在PHP-fpm文件中,修改以下标★语句

vim /etc/php-fpm.d/ ★listen.owner = nobody     #解除注释★listen.group = nobody     #解除注释★user = nginx      #将apache修改为nginx★group = nginx      #将apache修改为nginx

7.修改nginx的主配置

编辑配置文件,在server语句内,写入以下标★语句

vim /etc/nginx/nginx.conf38     server {39         listen       80 default_server;40         listen       [::]:80 default_server;41         server_name  _;42         root         /usr/share/nginx/html;43 44         # Load configuration files for the default server block.45         include /etc/nginx/default.d/*.conf;46 ★         location / {★ ★         root   /usr/share/nginx/html;★         index index.php index.html index.htm;★ 52         }53 ★         location ~ \.php$ {★         root           /usr/share/nginx/html;★         try_files $uri =404;★         fastcgi_pass   127.0.0.1:9000;★         fastcgi_index  index.php;★         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;★         include        fastcgi_params;★         }62 63         error_page 404 /404.html;64             location = /40x.html {65         }

8.设置网页目录权限

chown -R nginx:nginx /usr/share/nginx/html

9.新建index.php测试页

vim /usr/share/nginx/html/index.php<?php    phpinfo();?>

10.重启服务,并查看9000端口是否启动成功

systemctl restart nginxsystemctl restart php-fpmsystemctl restart mariadbnetstat -npa | grep 9000

标签: #lnmp上nginx重启