yumphpdevel
‘壹’ LAMP - CentOS7+Apache2.4+Mysql8+php7.3环境搭建
yum -y install epel-release
yum -y install yum-utils
yum update
yum -y install httpd
systemctl enable httpd
systemctl start httpd
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
# 隐藏版本号
vim /etc/httpd/conf.d/secure.conf
TraceEnable off
ServerSignature Off
ServerTokens Prod
# 配置vhost
vim /etc/httpd/conf.d/vhosts.conf
DocumentRoot "/var/www/html"
ServerName example.com
ServerAlias www.example.com
ErrorLog "logs/example.com-error_log"
CustomLog "logs/example.com-access_log" combined
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
yum install certbot python2-certbot-apache
certbot --apache
systemctl restart httpd
# 安装MySQL8 YUM源
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
yum install mysql-community-server
systemctl enable mysqld
systemctl start mysqld
# 查看自动生成的MySQL密码
grep "password" /var/log/mysqld.log
# 登录MySQL后修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
# 刷新MySQL权限表
FLUSH PRIVILEGES;
yum-config-manager --disable remi-php54
yum-config-manager --enable remi-php73
yum -y install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-opcache php-redis php-soap
# 隐藏php版本号
vim /etc/php.ini
expose_php = off
系统参数设置
# 文件打开数设置
ulimit -n 65535
vim /etc/security/limits.d/nofile.conf
* soft nofile 65535
* hard nofile 65535
# 内核网络优化
vim /etc/sysctl.conf
# 启用timewait 快速回收
net.ipv4.tcp_tw_recycle = 1
‘贰’ linux centos 7 下用yum 安装iso镜像里自带的php5.4.16版本的但是没有php-fqm文件不知道怎么重启php服务
systemctl restart php-fpm.service #这条命令是重启php服务
下面是一个比较靠谱的php安装步骤:
先删除已有的php版本 ,执行下面的命令删除php
yum remove php-common
然后像安装那样问你是否继续的,输入yes即可
添加 yum 源
CentOS 6.x 的源
# rpm -Uvh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安装 PHP
# yum install --enablerepo=remi,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
注:安装5.6版本为remi-php56,安装5.5版本为remi-php55
‘叁’ centos服务器怎么配置环境
安装apache:
yum install httpd httpd-devel
启动apache:
/etc/init.d/httpd start
此时输入服务器的IP地址,应该看到apache的服务页面,端口不用输,apache默认就是使用80端口
安装mysql:
yum install mysql mysql-server
启动mysql:
/etc/init.d/mysqld start
安装php
yum install php php-devel
重启apache使php生效
/etc/init.d/httpd restart
此时可以在目录:/var/www/html/下建立一个PHP文件
代码:
<?php phpinfo(); ?>
然后访问这个文件,就能看到PHP的一些信息,php.ini配置文件的路径可以在这个页面上看到
安装php的扩展
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
安装完扩展之后需要再次重启apache
/etc/init.d/httpd restart
测试mysql是否链接成功的php代码
<?php
$con = mysql_connect("10.0.@.@@","@@","@@");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydb", $con);
$result = mysql_query("SELECT * FROM sys_user");
while($row = mysql_fetch_array($result))
{
echo $row['UserName'] . " " . $row['PassWord'] . " " . $row['id'];
echo "<br />";
}
mysql_close($con);
?>
可以把上面的代码传入目录/var/www/html/
就可以看到执行情况
‘肆’ linux php-7.1.8怎么安装php-devel
用yum安装
首先查找yum包 看有没有对应版本
yumsearchphp-devel
rpm-Uvhhttps://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm-Uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpm
之后再次查找安装就好了!