centos build php environment
Install Apache
1. Install yum - y install httpd
2. Start the apache servicesystemctl start httpd.service
3. Set the apache service to start at bootsystemctl 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.Installyum -y install php
2.Restart apache servicesystemctl 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. Installationyum -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 accountmysql_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 MySQLyum 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 servicesystemctl 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!