LAMP环境搭建与配置

LAMP环境搭建

1.Mysql-5.6.40

1.1 安装mysql

#cd /usr/local/src	//软件包都放在这里方便管理
#wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz		//下载源码包

1.2 解压

#tar -zxvf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz		//解压
#mv mysql-5.6.43-linux-glibc2.12-x86_64 /usr/local/mysql		// 挪动位置

1.3 安装与配置

#cd /usr/local/mysql
#useradd -s /sbin/nologin mysql  //建立 MySQL 用户,因为启动 MySQL 需要该用户
#mkdir -p /data/mysql  //创建 datadir,数据库文件会放到这里面
#chown -R mysql:mysql /data/mysql  // 更改权限,不更改后续操作就会出问题
#ls -la /data/mysql/
#[ -d /usr/local/mysql ] && mv /usr/local/mysql /usr/local/mysql_old	//&&相当于一个判断,意前面命令执行才会执行后面
#yum install -y perl_Module_Install
.#/scripts/mysql_install_db --user=mysql --datadir=/data/mysql	//--user 表示定义数据库的以哪个用户的身份运 --datadir 表示定义数据库的安装目录
#cp support-files/my-default.cnf /etc/my.cnf
#vi /etc/my.cnf		//修改配置文件
	Basedir=/usr/local/mysql	//basedir 表示 MySQL 包所在路径
	Datadir=/data/mysql/datadir		//表示定义存放数据的位置
	Port=3306	//port 表示定义 MySQL 服务监听的端口号
	Server_id=128	//表示该 MySQL 服务的 ID 号
	socket = /tmp/mysql.sock	//定义 MySQL 服务监听的套接字地址
#cp support-files/mysql.server /etc/init.d/mysql	//复制启动脚本文件
#chmod 755 /etc/init.d/mysql	//修改启动脚本文件的属性
#vim /etc/init.d/mysql		//修改启动脚本
	basedir=/usr/local/mysql
	datadir=/data/mysql
#chkconfig --add mysql		//把 mysql 服务加到系统服务列表中
#chkconfig mysql on		//开机就启动
#service mysql start	//启动服务

1.4验证

#netstat -ltunp|grep 3306  //查看3306端口 (如没有此命令 使用 命令yum - y install net-tools)
#ps -ef | grep mysql //结果要大于2行

2. 安装Apache

2.1下载

#wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.39.tar.gz
#wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz 
#wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.5.tar.gz 

2.3 解压

#tar -zxvf httpd-2.4.39.tar.gz 
#tar -zxvf apr-1.6.5.tar.gz 
#tar -zxvf apr-util-1.6.1.tar.gz

2.4安装与配置

#cd /usr/local/src/apr-1.6.5
#/configure --prefix=/usr/local/apr
#yum install -y libtool*
#make  && make install
#cd /usr/local/src/apr-util-1.6.1.tar.gz
.#/configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#yum install -y expat-devel
#echo $?		//返回值为0正确
#make && make install
#cd /usr/local/src/httpd-2.4.39.tar.gz
#yum install -y  pcre-devel
#./configure --prefix=/usr/local/apache2.4 --enable-so --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
#make &&make install

2.5查看

#ls  /usr/local/apache2.4/bin/apachectc -M
(5)出现问题的解决方法
[root@localhost apr-1.6.5]# ./configure --prefix=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.6.5
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/apr-1.6.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
#yum groupinstall "Development Tools" "Server Platform Development" -y

3. 安装PHP

3.1下载

#wget http://cn2.php.net/distributions/php-5.6.30.tar.gz

3.2 解压

#cd /usr/local/src
#tar -zxvf php-5.6.30.tar.gz

3.3 安装与配置

#yum install -y libxml2-devel
#yum install -y openssl openssl -devel
#yum install -y bzip2 bzip2-devel
#yum install -y libpng libpng-devel
#yum install -y freetype freetype-devel
#yum install -y epel-release
#yum install -y libmcrypt-devel
#yum -y install libjpeg-devel

//为防止配置时出错提前安装库文件

#cd/usr/local/src/ php-5.6.30
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
#make && make install
//编译安装

3.4验证

[root@localhost php-5.6.30]# /usr/local/apache2.4/bin/httpd -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_prefork_module (shared)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 auth_basic_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 mime_module (shared)
 log_config_module (shared)
 env_module (shared)
 headers_module (shared)
 setenvif_module (shared)
 version_module (shared)
 unixd_module (shared)
 status_module (shared)
 autoindex_module (shared)
 dir_module (shared)
 alias_module (shared)
 php5_module (shared)

4.配置httpd支持的PHP

4.1配置 httpd的主配置文件

#vim /usr/local/apache2.4/conf/httpd.conf
搜索ServerName www.example.com:80前面的井号删除
然后把Require all denied这句改成Require all granted. //修改的目的是允许所有请求,如果不设置改行,则我们访问的时候回报403错误。
搜索下面这行:AddType application/x-gzip .gz .tgz
在这一行下面添加:AddType application/x-httpd-php .php
再搜索这一句:DirectoryIndex index.html 
修改为:DirectoryIndex index.html index.php

4.2测试配置文件是否正确

[root@localhost ~] #/usr/local/apache2.4/bin/apachectl -t	//检验配置文件是否正确:Syntax OK
[root@localhost ~] #/usr/local/apache2.4/bin/apachectl graceful		//启动 httpd 命令
[root@localhost ~]# ps -ef |grep http	//查看是否启动
root      76755      1  0 01:45 ?        00:00:00 /usr/local/apache2.4/bin/httpd -k graceful
daemon    76764  76755  0 01:45 ?        00:00:00 /usr/local/apache2.4/bin/httpd -k graceful
daemon    76765  76755  0 01:45 ?        00:00:00 /usr/local/apache2.4/bin/httpd -k graceful
daemon    76766  76755  0 01:45 ?        00:00:00 /usr/local/apache2.4/bin/httpd -k graceful
daemon    76767  76755  0 01:45 ?        00:00:00 /usr/local/apache2.4/bin/httpd -k graceful
daemon    76768  76755  0 01:45 ?        00:00:00 /usr/local/apache2.4/bin/httpd -k graceful
root      76772  76680  0 01:46 pts/1    00:00:00 grep --color=auto http
[root@localhost ~]# curl localhost		//使用 curl 命令简单测试,,显示It works!了就是成功
[root@localhost ~]# curl localhost/1.php
php 解析正确

5.Apache配置(默认虚拟主机)

5.1 配置

#vim /usr/local/apache2.4/conf/httpd.conf
搜索关键字httpd-vhost找到这行吧前面的井号删除
#vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf //进入虚拟主机配置文件
把virtualHost里的重新编辑如下
    ServerName www.123.com
    <Directory /data/wwwroot/www.123.com>
    AllowOverride AuthConfig
    AuthName "123.com user auth"
    AuthType Basic
    AuthUserFile /data/.htpasswd
     require valid-user
     </ Directory> 
     <VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/data/wwwroot/www.123.com"
    ServerName www.123.com
 </  VirtualHost>

5.2验证访问

[root@localhost docs] # curl -x localhot:80 www.123.com	//访问
 www.123.com
[root@localhost docs] # curl -x localhost:80 
www.123.com

6.用户认证

6.1配置

#-vim /usr/local/apache2.4/conf/extra/httpd-vhost.conf
	<VirtualHost *:80>
		<Directory /usr/local/apache2.4/docs/aaa.com>		// 指定认证的目录
		
		<FilesMatch admin.php>针对单个文件
			AllowOverride AuthConfig		// 这个相当于打开认证的开关
        	AuthName "123.com user auth"		//自定义认证的名字,作用不大
        	AuthType Basic		//认证的类型,一般为 Basic
        	AuthUserFile /usr/local/apache2.4/docs/.htpasswd		//指定密码文件所在位置
 			require valid-user		// 指定需要认证的用户为全部可用用户
		</Directory>
		<FilesMatch admin.php>针对单个文件
			AllowOverride AuthConfig
       	    AuthName "abc.com user auth"
        	AuthType Basic
            AuthUserFile /usr/local/apache2.4/docs/.htpasswd
       		require valid-user
        </FilesMatch>
	</VirtualHost>
#/usr/local/apache2.4/bin/apachectl -t
#/usr/local/apache2.4/bin/apachectl graceful
#/usr/local/apache2.4/bin/htpasswd  -cm /usr/local/apache2.4/docs/.htpasswd aming
//htpasswd 为创建用户的工具,-c为creat -m为指定密码加密的方式为 MD5,data/.htpasswd 为密码文件,
//aming 为创建的用户。第一次执行需加-c
//第二次不用加,否则密码文件会重置
然后去物理机的C:\Windows\System32\drivers\etc/hosts文件里最底下添加下面一行 (这里的文件要设置更改权限)
192.168.237.129 www.123.com //这里的地址为你的Linux IP与本人的可能不一样
最后设置完全控制:

LAMP环境搭建与配置_第1张图片
LAMP环境搭建与配置_第2张图片
LAMP环境搭建与配置_第3张图片
LAMP环境搭建与配置_第4张图片

6.2 验证

#curl -x localhost:80 123.com -I -u aming:123123

LAMP环境搭建与配置_第5张图片然后再去浏览器访问www.123.com
LAMP环境搭建与配置_第6张图片

7.配置域名跳转

7.1 修改虚拟主机文件

#vim /usr/local/apache2.4/conf/extra/httpd-vhost.conf
把123.com域名跳转到www.123.com修改为:
DocumentRoot  "/data/wwwroot/www.123.com"
    ServerName www.123.com
    ServerAlias 123.com
    <IFModule mod _rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_HOST} !^www.123.com$
        RewriteRule ^/(.*)$ http://www.123.com/$1 [R=301,L]
     </IfModule>
 #vim /usr/local/apache2.4/conf/httpd.conf
 搜索rewrite,删掉前面的井号。
#/usr/local/apache2.4/bin/apachectl -M|grep -i rewrite

在这里插入图片描述

7.2 验证

#/usr/local/apache2.4/bin/apachectl graceful
#curl -x 127.0.0.1:80 -I 123.com

在这里插入图片描述

8. 配置访问日志

8.1 修改虚拟主机文件

#vim /usr/local/apache2.4/conf/extra/httpd-vhost.conf
编辑成:
DocumentRoot  "/data/wwwroot/www.123.com"
    ServerName www.123.com
    ServerAlias 123.com
    <IFModule mod _rewrite.c>
        RewriteEngine on
        RewriteConf %{HTTP_HOST} !^www.123.com$
        RewriteRule ^/(.*)$ http://www.123.com/$1 [R=301,L]
     </IfModule>
     CustomLog "logs/123.com-access_log" combined
</VirtualHost>

8.2 验证

#/usr/local/apache2.4/bin/apachectl graceful
#curl -x 127.0.0.1:80 -I 123.com
#tail /usr/local/apache2.4/logs/123.com-access_log

在这里插入图片描述

9.访问日记不记录静态文件

9.1修改虚拟主机配置文件

 #vim /usr/local/apache2.4/conf/extra/httpd-vhost.conf

编辑成:

 DocumentRoot  "/data/wwwroot/www.123.com"
    ServerName www.123.com
    <IFModule mod _rewrite.c>
        RewriteEngine on
        RewriteConf %{HTTP_HOST} !^www.123.com$
        RewriteRule ^/(.*)$ http://www.123.com/$1 [R=301,L]
     </IfModule>
     SetEnvIf Request_URI ".*\.gif$" image-request
     SetEnvIf Request_URI ".*\.jpg$" image-request
     SetEnvIf Request_URI ".*\.png$" image-request
     SetEnvIf Request_URI ".*\.bmp$" image-request
     SetEnvIf Request_URI ".*\.swf$" image-request
     SetEnvIf Request_URI ".*\.js$" image-request
     SetEnvIf Request_URI ".*\.css$" image-request
     Customlog "logs/123.com-access_log" combined
     <IfMoudle mod_expire.c>

LAMP环境搭建与配置_第7张图片

9.2 验证

#/usr/local/apache2.4/bin/apachectl -t
#/usr/local/apache2.4/bin/apachectl graceful
#curl -x 127.0.0.1:80 -I 123.com
#ls /usr/local/apache2.4/logs/

LAMP环境搭建与配置_第8张图片

9.3访问日志切割

#vim /usr/local/apache2 .4/conf/extra/httpd-vhosts.conf
DocumentRoot  "/data/wwwroot/www.123.com"
    ServerName www.123.com
    <IFModule mod _rewrite.c>
        RewriteEngine on
        RewriteConf %{HTTP_HOST} !^www.123.com$
        RewriteRule ^/(.*)$ http://www.123.com/$1 [R=301,L]
     </IfModule>
     SetEnvIf Request_URI ".*\.gif$" image-request
     SetEnvIf Request_URI ".*\.jpg$" image-request
     SetEnvIf Request_URI ".*\.png$" image-request
     SetEnvIf Request_URI ".*\.bmp$" image-request
     SetEnvIf Request_URI ".*\.swf$" image-request
     SetEnvIf Request_URI ".*\.js$" image-request
     SetEnvIf Request_URI ".*\.css$" image-request
     CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/123.com-access_%Y%m%d.log 86400"combined env=!image-request
      <IfMoudle mod_expire.c>

LAMP环境搭建与配置_第9张图片

#/usr/local/apache2.4/bin/apachectl -t
#/usr/local/apache2.4/bin/apachectl graceful

9.4配置验证

#touch /data/wwwroot/123.com/aming.jpg
#touch /data/wwwroot/123.com/aming.txt
#curl -x 127.0.0.1:80 123.com/aming.jpg
#curl -x 127.0.0.1:80 123.com/aming.txt
#cat /usr/local//apache2.4/logs/123.com-access_20220907.1og

LAMP环境搭建与配置_第10张图片

10. 配置静态元素过期时间

10.1 修改虚拟主机配置文件

#vim /usr/local/apache2.4/conf/extra/httpd-vhost.conf

编辑成:

 DocumentRoot "/data/wwwroot/www.123.com"
    ServerName www.123.com
    ServerAlias 123.com
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.123.com$
    RewriteRule ^/(.*)$ http://www.123.com/$1 [R=301,L]
</IfModule>
    SetEnvIf Request_URI ".*\.gif$" image-request
    SetEnvIf Request_URI ".*\.jpg$" image-request
    SetEnvIf Request_URI ".*\.png$" image-request
    SetEnvIf Request_URI ".*\.bmp$" image-request
    SetEnvIf Request_URI ".*\.swf$" image-request
    SetEnvIf Request_URI ".*\.js$" image-request
    SetEnvIf Request_URI ".*\.css$" image-request
    CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/123.com-access_%Y%m%d.1og 86400"combined env=!image-request
<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresByType image/gif "access plus 1 days“
    ExpiresByType image/jpeg "access plus 24 hours"
    ExpiresByType image/png "access plus 24 hours'
    ExpiresByType text/css "now plus 2 hour"
    ExpiresByType application/x-javascript "now plus 2 hours"
    ExpiresByType application/javascript "now plus 2 hours"
    ExpiresByType application/x-shockwave-flash "now plus 2 hours"
    ExpiresDefault "now plus 0 min"
  </IfModule>

LAMP环境搭建与配置_第11张图片

10.2 验证

#/usr/local/apache2.4/bin/apachectl -t
#/usr/local/apache2.4/bin/apachectl graceful
#vim /usr/local/apache2.4/conf/httpd.conf  //搜索关键词expires,找到这一行LoadModule expires_ module modules/mod_ expires .so 把前面井号删掉。
#/usr/local/apache2.4/bin/apachectl graceful
#/usr/local/apache2.4/bin/apachectl -M|grep -i expires
expires_module(share)//有这行输出说明正确加载expires模块
#curl -x 127.0.0.1:80 -I 123.com/aming.txt

LAMP环境搭建与配置_第12张图片

#curl -x 127.0.0.1:80 -I 123.com/aming.jpg

LAMP环境搭建与配置_第13张图片

(max-age=86400说明将缓存86400秒,max-age=0说明没有该类型缓存文件)

11.配置防盗链

11.1 修改虚拟主机配置文件

#vim /usr/local/apache2 .4/conf/extra/httpd-vhosts.conf

修改成:

DocumentRoot  "/data/wwwroot/www.123.com"
    ServerName www.123.com
    <IFModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_HOST} !^www.123.com$
        RewriteRule ^/(.*)$ http://www.123.com/$1 [R=301,L]
     </IfModule>
     SetEnvIf Request_URI ".*\.gif$" image-request
      CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/123.com-access_%Y%m%d.1og 86400" combined env=!image-request
      <Directory /data/wwwroot/www.123.com>
    SetEnvIfNoCase Referer "http://www.123.com" local_ref
    SetEnvIfNoCase Referer "http://123.com" local_ref
    SetEnvIfNoCase Referer "^$" local ref
    <filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif)">
        Order Allow,Deny
        Allow from env=local_ref
    </filesmatch>
  </Directory>

LAMP环境搭建与配置_第14张图片

11.2 验证

#/usr/local/apache2.4/bin/apachectl -t
Syntax OK
#/usr/local/apache2.4/bin/apachectl graceful
#curl -x 127.0.0.1:80 -I -e "http://www.123.com/123.txt" http                                                                                                                               ://www.123.com/aming.jpg//状态码200
HTTP/1.1 200 OK
Date: Thu, 08 Sep 2022 00:48:49 GMT
Server: Apache/2.4.54 (Unix) PHP/5.6.39
Last-Modified: Wed, 07 Sep 2022 01:36:38 GMT
ETag: "0-5e80c5819b368"
Accept-Ranges: bytes
Content-Type: image/jpeg

#curl -x 127.0.0.1:80 -I -e "http://www.1234.com/123.txt" htt                                                                                                                               p://www.123.com/aming.jpg //状态码400
HTTP/1.1 403 Forbidden
Date: Thu, 08 Sep 2022 00:50:22 GMT
Server: Apache/2.4.54 (Unix) PHP/5.6.39
Content-Type: text/html; charset=iso-8859-1

12. 访问控制

12.1 修改虚拟主机配置文件

#vim /usr/local/apache2 .4/conf/extra/httpd-vhosts.conf
  修改成:
  DocumentRoot "/data/wwwroot/www.123.com"
    ServerName www.123.com
    ServerAlias 123.com
    CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/123.com-access_%Y%m%d.1og 86400"combined
    <Directory /data/wwwroot/www.123.com/admin/>
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Directory>
#/usr/local/apache2.4/bin/apachectl graceful
#mkdir /data/wwwroot/www.123.com/admin/ //创建admin目录,模拟网站后台
#echo "admin" > /data/wwwroot/www.123.com/admin/index.html //在后台目录下创建文件,并写入内容.
 #>  /usr/local/apache2.4/logs/123.com-access_20220908.1og //清空当天的访问日志

12.2配置验证

#curl -x 192.168.237.129:80 -I www.123.com/admin/index.html  HTTP/1.1 403 Forbidden
Date: Thu, 08 Sep 2022 01:04:24 GMT
Server: Apache/2.4.54 (Unix) PHP/5.6.39
Content-Type: text/html; charset=iso-8859-1

#curl -x 127.0.0.1:80 -I www.123.com/admin/index.html
HTTP/1.1 200 OK
Date: Thu, 08 Sep 2022 01:04:49 GMT
Server: Apache/2.4.54 (Unix) PHP/5.6.39
Last-Modified: Thu, 08 Sep 2022 01:02:31 GMT
ETag: "6-5e81ffbeaee9b"
Accept-Ranges: bytes
Content-Length: 6
Content-Type: text/html
#cat /usr/local/apache2.4/logs/123.com-access_20220908.1og

LAMP环境搭建与配置_第15张图片

12.3 针对文件配置

#vim /usr/local/apache2 .4/conf/extra/httpd-vhosts.conf 

修改成:

 DocumentRoot "/data/wwwroot/www.123.com"
    ServerName www.123.com
    ServerAlias 123.com
    CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/123.com-access_%Y%m%d.1og 86400"combined
    <Directory /data/wwwroot/www.123.com/admin/>
        <Filesmatch "admin.php(.*)">
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
        </Filesmatch>
    </Directory>
#/usr/local/apache2. 4/bin/apachectl -t
#/usr/local/apache2 .4/bin/ apachectl graceful

12.4 配置验证

#touch /data/wwwroot/www.123.com/admin/admin.php
#cp /usr/local/apache2.4/htdocs/1.php /data/wwwroot/www.123.com/upload

如出现以下问题 [root@localhost ~]# curl -x 127.0.0.1:80
www.123.com/upload/1.php < !DOCTYPE HTML PUBLIC “-//IETF//DTD HTML
2.0//EN”> < html>< head> < title>404 Not Found< /title> < /head>< body> < h1>Not Found< /h1> < p>The requested URL was not found on this
server.

< /body>< /html> 先去 cd
/data/wwwroot/www.123.com/upload里是否有1.php这个文件没有就创建一个然后在里面编辑:
 #cp /usr/local/apache2.4/htdocs/1.php /data/wwwroot/www.123.com/upload //复制文件
#curl -x 127.0.0.1:80 www.123.com/upload/1.php -I
#curl -x 192.168.237.129:80 www.123.com/admin/admin.php -I

LAMP环境搭建与配置_第16张图片LAMP环境搭建与配置_第17张图片

13 PHP配置

13.1PHP基础配置

 #vim  /usr/local/php/etc/php.ini //定义date.timezone,减少警告
 找到date. timezone设置如下:
date.timezone = Asia/Shanghai
#/usr/local/php/bin/php -i |grep -i "loaded configuration file"

13.2 日志相关配置

13.2.1 配置error_log

//记录错误日志目录位置:搜索erro# vim /usr/local/php/etc/php. ini
//记录错误日志:搜索log_errors, 改成如下
log_errors=On
r. log,改为
error_log = /var/log/php/php_errors.log
//记录错误日志级别:搜索error_reporting 改为
error_reporting = E ALL & ~E_ NOTICE
//再搜索display_errors,改为
display_errors = Off
#mkdir /var/log/php
#chmod 777 /var/log/php
#/usr/local/apache2.4/bin/apachectl graceful
#vim /data/wwwroot/testdomain.com/test.php

编辑成:
在这里插入图片描述

#curl -A "123" -I -x127.0.0.1:80 testdomain. com/test .php
HTTP/1.0 500 Internal Server Error
Date: Thu, 08 Sep 2022 05:51:11 GMT
Server: Apache/2.4.54 (Unix) PHP/5.6.39
X-Powered-By: PHP/5.6.39
Connection: close
Content-Type: text/html; charset=UTF-8

LAMP环境搭建与配置_第18张图片

#cat /var/1og/php/php_errors.log
[08-Sep-2022 05:44:56 UTC] PHP Parse error:  syntax error, unexpected end of file, expecting ',' or ';' in /data/wwwroot/www.123.com/test.php on line 3
[08-Sep-2022 05:51:11 UTC] PHP Parse error:  syntax error, unexpected end of file, expecting ',' or ';' in /data/wwwroot/www.123.com/test.php on line 3

14. PHP扩展模块安装

14.1查看PHP加载的模块

#/usr/local/php/bin/php -m

LAMP环境搭建与配置_第19张图片

14.2 安装新的redis

#wget http://pecl.php.net/get/redis-2.2.5.tgz //下载新的redis
#mv redis-2.2.5 phpredis-develop //移动redis
#cd phpredis-develop
#yum  install  -y  autoconf //缺少autoconf
#/usr/local/php/bin/phpize //目的生成configure文件

在这里插入图片描述#./configure --with-php-config=/usr/local/php/bin/php-config
LAMP环境搭建与配置_第20张图片

#make && make install
#ls /usr/local/php/lib/php/extensions/no-debug                                                                                                                               -zts-20131226/
#vim /usr/local/php/etc/php.ini//增加一行配置(可以放在文件最后一行)
extension = redis.so
#/usr/local/php/bin/php -m |grep redis
redis

LAMP环境搭建与配置_第21张图片

你可能感兴趣的:(数据库,服务器,mysql)