PHP环境LAMP/LNMP安装与配置
Lnmp = Linux + Nginx + Mysql + PHP
yum groupinstall -y *Development Tools* #先安装开发软件包
php的安装 (编译安装)
1. 下载: wget http://repoforge.org/use/ # Nginx第三方原Repoforge
安装: rpm -ivh 文件
yum clean all #清除缓存
yum list
2. rz 选择phpa安装包 #PHP http://php.net/
tar -zxvf 文件名 #解压php
3. yum install gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel
4. cd php目录
./configure --prefix=/usr/local/php-fpm --enable-fpm --with-zlib --with-pdo-mysql --enable-mbstring --with-gd --with-png-dir=/usr/lib64 --with-jpeg-dir=/usr/lib64 --with-freetype-dir=/usr/lib64 #安装php目录 Succes:Thank you for using PHP
make && make install #Succes: Don't forget to run 'make test'.
5. cd ~ #安装完成切换目录
vim test.php => <?php phpinfo();
/usr/local/php5.6/bin/php test.php #测试
php常用命令
1. 查看php版本: /usr/local/php/bin/php -v
2. 查看phpinfo: /usr/local/php/bin/php -i
3. 查看php编译模块: /usr/local/php/bin/php -m
4. 查看php.ini配置文件路径和目录: /usr/local/php/bin/php --ini
php-fpm常用命令
查看php-fpm占用端口号: ps -ef | grep php-fpm
1. 配置php-fmp: vi /usr/local/php/etc/php-fpm.conf
Mysql安装
yum list installed | grep mariadb yum -y remove mariadb-文件 #检查mariadb 有就删除
1. wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm #官网https://dev.mysql.com/downloads/mysql/
2. yum localinstall mysql57-community-release-el7-8.noarch.rpm #安装Mysql 原
yum repolist enabled | grep "mysql.*-community.*" #检测安装成功
mysql-connectors-community/x86_64 MySQL Connectors Community 45
mysql-tools-community/x86_64 MySQL Tools Community 59
mysql56-community/x86_64 MySQL 5.6 Community Server 378
3. yum install mysql-community-server #创建目录
4. systemctl start mysqld #启动服务 systemctl stop mysqld.service #关闭服务 service mysql restart #重启mysql服务
systemctl status mysqld #查看状态 Active: active (running)
5. [root@localdomain ~]# systemctl enable mysqld #开机启动
[root@localdomain ~]# systemctl daemon-reload
7. 设置密码
mysql -uroot -p #进入mysql
grep "password" /var/log/mysqld.log #查看密码
/* 重置Mysql密码 */
a. vim /etc/my.cnf (注:windows下修改的是my.ini)
b. 在 [mysqld] 后面任意一行添加 skip-grant-tables 用来跳过密码验证的过程
c. systemctl restart mysqld.service #重启Msql
d. 终端: mysql
mysql> use mysql;
mysql> update user set password=password("你的新密码") where user="root";
如果错误 update mysql.user set authentication_string=password('你的密码') where user='root';
mysql> flush privileges;
mysql> quit
e. systemctl restart mysqld.service #重启Msql
f. 在 [mysqld] 去掉一行添加 skip-grant-tables
port=3306 # 添加
datadir=/mysql_data
8. use mysql; #登陆之后切换
grant all privileges on *.* to 'root'@'%' identified by 'zbfpassword'; #设置远程连接,报错:flush privileges;在执行
9. flush privileges; #刷新 exit;退出
10. firewall-cmd --zone=public --add-port=3306/tcp --permanent #添加端口
firewall-cmd --add-port=80/tcp --permanent #永久添加80端口

systemctl start firewalld #开启防火墙
systemctl status firewalld #查看firewalld状态
11. systemctl stop firewalld.service #关闭防火墙
12. yum install -y php.mysql #加载PHP安装包
安装Nginx
1. 进入: http://nginx.org/en/download.html #选择稳定版本
2. 下载:wget http://nginx.org/download/nginx-1.12.2.tar.gz #tar -zxvf 文件 解压 ls -alh |grep nginx-1.12.2 #查看大小 8
3. cd nginx-1.12.2 #进入目录
./configure --prefix=/usr/local/nginx
make && make install
出现 make: *** No rule to make target `build', needed by `default'. Stop. #yum -y install openssl openssl-devel
4. cd /usr/local/nginx #切换目录
./configure --prefix=/usr/local/nginx
cd /usr/local/nginx/sbin #切换目录
./nginx #启动 nginx
ps aux | grep nginx #查看
PHP与Nginx配置PHP-frm
1. ps aux | grep httpd #查看 Apache
systemctl stop httpd.service #关闭Apache
2. cd php5.6 #切换目录进去
cp php.ini-production /usr/local/php-fpm/etc/php.ini
3. cd /usr/local/php-fpm/etc/ #切换目录进去
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf

4. cd /usr/local/php-fpm/sbin/
./php-fpm #启动
ps aux | grep php #查看
5. cd /usr/local/nginx/conf/
vim nginx.conf

6. killall nginx #关闭Nginx
ps aux | grep nginx #查看关闭
7. cd /usr/local/nginx/sbin/ #切换重启nginx
./nginx
ps aux | grep nginx #查看启动
8. cd /usr/local/nginx/html/ #切换测试
vim index.php <?php phpinfo(); ?>
Ip+index.php #测试打开
Lamp = Linux + Apache + Mysql + PHP
1. yum install -y httpd #安装Apache
systemctl start httpd.service #开启
systemctl enable httpd.service #开机启动
systemctl status httpd.service #状态
systemctl restart firewalld.service #重启服务
* conf ->httpd.conf 主配置文件 。conf.d ->模块配置文件
* /var/www/html 网站根目录

#管理员邮箱
#域名

加速器 ( zendopcache ) ;
1. 安装 Remi 源:yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
2. 编辑Remi 源配置文件 :
修改 enabled=0 为 enabled=1。结尾另起一行添加下面的代码:priority=3
3. 更新yum缓存:yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
4. 安装 Zend Opcache:yum install php56w-pecl-zendopcache #注:出现conflict php为5.5则php55w-peclzendopcache,总之与php版本对应
5. 这个配置文件采用的基本就是 README 中的推荐设置,只有几个地方需要修改。
- opcache.memory_consumption=128
- opcache.interned_strings_buffer=8
- opcache.max_accelerated_files=4000
- opcache.revalidate_freq=60
- opcache.fast_shutdown=1
- opcache.enable_cli=1
6. over查询一下看看是否正确启动了: php -v

浙公网安备 33010602011771号