Home > Backend Development > PHP Problem > How to install and build centos php environment

How to install and build centos php environment

L
Release: 2023-03-01 09:40:01
Original
2473 people have browsed it

How to install and build centos php environment

centos build php environment

Install Apache
1. Install
yum - y install httpd
2. Start the apache service
systemctl start httpd.service
3. Set the apache service to start at boot
systemctl enable httpd.service

CentOS7 uses Firewall-cmd. Before CentOS7, it used iptables firewall. If you want the external network to access the apache home directory, you need to do the following operations:
firewall -cmd --permanent --zone=public --add-service=http<br>firewall-cmd --permanent --zone=public --add-service=https<br>firewall-cmd --reload

Install PHP

1.Install
yum -y install php
2.Restart apache service
systemctl restart httpd or systemctl restart httpd.service
Then, you can write a php file and run it in the browser;
eg:
vi /var/www/html/info.php
i

Esc
:wq
Then, enter 192.168.1.1/info.php
in your computer browser to run, and some php messages will appear. Information

Install MySQL
I also installed MariaDB based on the tutorial I learned
1. Installation
yum -y install mariadb-service mariadb
2. Enable MySQL service
systemctl start mariadb.service
3. Set up to start the MySQL service at boot
systemctl enable mariadb.service
4. Setup Password for the root account
mysql_secure_installation
Then a string of things will appear. You can read it carefully. If you are too lazy to read it, just press Enter when the prompt comes out and let you set it. When it comes to password, you just enter the password you want, and then continue to ask you to select y/n, and just press Enter; when everything is over, you can enter mysql -uroot -p to verify;

Associate PHP and MySQL
yum search php, select the installation you need: yum -y install php-mysql

Install commonly used PHP modules
For example, GD library, curl, mbstring,...
1. Installation:
yum -y install php-gd php-ldap php-odbc php-pear php -xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

Restart apache service
systemctl restart httpd.service

The above is the detailed content of How to install and build centos php environment. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template