cnblogs/dcrenl/centos 搭建php环境.html
2024-09-24 12:43:01 +08:00

7 lines
1.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>安装Apache<br />1.安装<br />yum -y install httpd<br />2.开启apache服务<br />systemctl start httpd.service<br />3.设置apache服务开机启动<br />systemctl enable httpd.service</p>
<p>CentOS7用的是Firewall-cmdCentOS7之前用的是iptables防火墙要想让外网能访问到apache主目录就需要做以下的操作<br />firewall-cmd --permanent --zone=public --add-service=http<br />firewall-cmd --permanent --zone=public --add-service=https<br />firewall-cmd --reload</p>
<p>安装PHP<br />1.安装<br />yum -y install php<br />2.重启apache服务<br />systemctl restart httpd或者systemctl restart httpd.service<br />然后你可以写一个php文件在浏览器中运行一下了;<br />eg:<br />vi /var/www/html/info.php<br />i<br />&lt;?php phpinfo(); ?&gt;<br />Esc<br />:wq<br />然后,在自己电脑浏览器输入 192.168.1.1/info.php<br />运行会出现php的一些信息</p>
<p>安装MySQL<br />我这里根据所学的那个教程也安装了MariaDB<br />1.安装<br />yum -y install mariadb-service mariadb<br />2.开启MySQL服务<br />systemctl start mariadb.service<br />3.设置开机启动MySQL服务<br />systemctl enable mariadb.service<br />4.设置root帐户的密码<br />mysql_secure_installation<br />然后会出现一串东西可以仔细读一下如果你懒得读就在提示出来的时候按Enter就好了让你设置密码的时候你就输入你想要的密码就行然后继续在让你选择y/n是Enter就好了当一切结束的时候你可以输入mysql -uroot -p的方式验证一下</p>
<p>将PHP和MySQL关联起来<br />yum search php选择你需要的安装yum -y install php-mysql</p>
<p>安装常用的PHP模块<br />例如GD库curlmbstring,...<br />1.安装:<br />yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel</p>
<p><br />重启apache服务<br />systemctl restart httpd.service</p>