LAMP环境搭建基本步骤

Posted h-gallop

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LAMP环境搭建基本步骤相关的知识,希望对你有一定的参考价值。

LAMP环境搭建基本步骤

参考链接https://yq.aliyun.com/articles/106387

apache性能优化、配置https://my.oschina.net/lockupme/blog/743948

1、安装apache

yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql

2、安装mysql

用以前安装文档

3、安装php

安装php5.6依赖和源

安装php

yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common

yum 安装php7.2

添加yum 源

#rpm -Uvh https:``//dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#rpm -Uvh https:``//mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh http:*//rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y  --enablerepo=remi-php73  install php php-pdo php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-mysql php-redis php-zip

php.ini配置

expose_php = Off
short_open_tag = ON
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 32M
date.timezone = Asia/Shanghai
mbstring.func_overload=2

#连接数据库报错,需要修改php.ini文件中的*_default_socket = mysql/mysql.sock

4、apache配置

1、如果有mod_rewrite.so这句,就把这句前面的#号去掉;如果没有mod_rewrite.so这句,就在mod_foo.so这句后面加上这句;反正就是开启mod_rewrite.so这个服务

vi /etc/httpd/conf/httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so

2、把AllowOverride None改成AllowOverride All

3.配置虚拟主机,把下面这段加在/etc/httpd/conf/httpd.conf最后面,注意去掉注释

<VirtualHost *:80>
ServerAdmin suibian@sina.com                //随便哪个邮箱
DocumentRoot "/var/www/html/laravel5.2/public"   //项目的访问路径
ServerName www.aliyun.com                  //域名,绑定这台服务器的IP
DirectoryIndex index.php index.html index.htm    //访问网站时默认打开的文件
ErrorLog "logs/www.aliyun.com-error_log"       //日志
CustomLog "logs/www.aliyun.com-access_log" common //日志
</VirtualHost>

<VirtualHost *:80>  
DirectoryIndex  index.html index.php
ServerName www.public.landzg.com  
ServerAlias *.public.landzg.com
DocumentRoot /wwwroot/yijia_landzg/wwwroot/public
ErrorLog "logs/www.aliyun.com-error_log"       //日志
CustomLog "logs/www.aliyun.com-access_log" common //日志
<Directory "/wwwroot/yijia_landzg/wwwroot/public">  
    Options -Indexes  +FollowSymlinks  
    AllowOverride All  
    Require all granted 
    Allow from all  
</Directory>  
</VirtualHost>

#限定某个目录禁止解析PHP
<Directory /data/wwwroot/111.com/upload>
    php_admin_flag engine off  //这一段就可以禁止解析PHP代码
    <FilesMatch (.*).php(.*)> //这一段就是让php的文件访问受到限制,防止php文件的源代码被查看
    Order allow,deny
    Deny from all
    </FilesMatch>
</Directory>


以上是关于LAMP环境搭建基本步骤的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu下搭建LAMP环境

LAMP环境搭建教程

CentOS6编译安装 LAMP+Wordpress--搭建自己的博客

linux下LAMP环境的搭建

源代码编译安装LAMP环境

Linux(CentOS 7)LAMP环境的搭建