yumphpdevel-九游会j9娱乐平台
『壹』 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的一些信息,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代碼
$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 "
";
}
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
之後再次查找安裝就好了!