• YUM安装LAMP与LNMP


    该系列文章只是本人的学习笔记,文章中的文字描述提取自《Linux鸟哥私房菜》《Linux运维之道》等书中的重点内容,部分内容是在培训Linux运维时总结的笔记,化繁为简能够在工作中快速复习掌握重点,并不代表个人立场,但转载请加出处,并注明参考文献。

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

    LAMP

    1.配置yum源,安装依赖

    
    yum install -y wget
    
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.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-release
    
    rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    
    yum 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 http://mirrors.aliyun.com/repo/Centos-7.repo
    
    yum -y install epel-release
    yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel libjpeg* libmcrypt libmcrypt-devel
    

    2.安装Nginx

    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    yum install -y nginx
    
    systemctl start nginx
    systemctl enable nginx
    

    3.安装与配置MySQL

    yum install -y mariadb mariadb-server
    
    systemctl start mariadb
    systemctl enable mariadb
    
    mysql_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-mhash
    
    systemctl start php-fpm
    systemctl 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/www.conf 
    
    ★listen.owner = nobody					#解除注释
    ★listen.group = nobody					#解除注释
    
    ★user = nginx						#将apache修改为nginx
    ★group = nginx						#将apache修改为nginx
    

    7.修改nginx的主配置

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

    vim /etc/nginx/nginx.conf
    
    38     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 nginx
    systemctl restart php-fpm
    systemctl restart mariadb
    
    netstat -npa | grep 9000
    

  • 相关阅读:
    设置maven阿里云镜像和公司私服并存
    idea favorites bookmarks标签收藏夹数据丢失bug
    C#后期绑定调用COM组件
    SQL Studio 1.0:一款轻便的SQL脚本工具兼容SQL Server、MySQL、Access2007
    SQL Studio 2.0: 新版发布
    SQLHelper用的不爽,试试CmdRunner吧
    Flask + uWSGI+ Linux 指南及避坑
    Flask + Pyinstaller 打包后运行报错 SystemError
    Url重写之UrlRewriter
    .net5 提取压缩包内指定文件内容无需解压
  • 原文地址:https://www.cnblogs.com/LyShark/p/10229671.html
Copyright © 2020-2023  润新知