Home Backend Development PHP Problem How to install php environment in linux yum

How to install php environment in linux yum

Sep 13, 2021 am 09:26 AM
linux php yum

linux yum installation method for the PHP environment: 1. Install PHP and mysql through the "yum -y install httpd" command; 2. Configure the boot service; 3. Set the mysql database root account password; 4. Create a new one php script can be tested.

How to install php environment in linux yum

The operating environment of this article: linux5.9.8 system, PHP7.1 version, DELL G3 computer

How to install php environment with linux yum ?

Linux installs the php environment, yum installs the php environment

Use yum to manage and install the basic installation of Apache PHP Mysql.

1. Install Apahce, PHP, Mysql, and the PHP connection mysql library component.

yum -y install httpd php mysql mysql-server php-mysql
Copy after login
Copy after login

2. Configure the startup service at startup

/sbin/chkconfig httpd on [设置apache服务器httpd服务开机启动]
/sbin/chkconfig --add mysqld [在服务清单中添加mysql服务]
/sbin/chkconfig mysqld on [设置mysql服务开机启动]
/sbin/service httpd start [启动httpd服务,与开机启动无关]
/sbin/service mysqld start [启动mysql服务,与开机无关]
Copy after login

3. Set the mysql database root account password.

mysqladmin -u root password 'newpassword' [引号内填密码]
Copy after login

4. Make the mysql database more secure

mysql -u root -p
mysql> DROP DATABASE test; [删除test数据库]
mysql> DELETE FROM mysql.user WHERE user = ''; [删除匿名帐户]
mysql> FLUSH PRIVILEGES; [重载权限]
Copy after login

5. According to the above installation method, the default site directory configured is /var/www/html/

New A php script:

6. Create a new database, add a database user, and set user permissions. Write a php script to test the database connection.

mysql> CREATE DATABASE my_db;
mysql> GRANT ALL PRIVILEGES ON my_db.* TO  IDENTIFIED BY 'password';
 
//安装apache扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
//安装php的扩展
yum install php-gd
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
//安装mysql扩展
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
[root@soft bin]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 
""mysql dead but subsys locked
Copy after login

The solution is as follows:

[root@soft mysql-4.1.19]# rm -fr /var/lib/mysql/*
[root@soft mysql-4.1.19]# rm /var/lock/subsys/mysql
rm: remove regular empty file `/var/lock/subsys/mysqld'? yes
shell> killall mysqld
shell> service mysqld start
[root@soft mysql-4.1.19]# /etc/rc.d/init.d/mysqld status
mysqld (pid 5457) is running...
###数据库运行正常;
Copy after login

1. Two important directories:

Apache has two important directories:

1. Configuration directory/ etc/httpd/conf;

2. Document directory/var/www:

2. Two configuration modes:

Two configuration methods for Apache under Fedora: Text mode (terminal command line) and graphical configuration. Both have their own advantages: graphical configuration is easier to get started, and editing the httpd.conf file directly in text mode is more free and direct.

3. Starting and shutting down the Apache service

Stopping, starting, and shutting down the Apache service can be operated in two modes: text (terminal) mode and graphical interface.

IV. Operations under the terminal

If you want to use Linux as a WWW server, I recommend not to install a graphical interface (i.e. X

window, KDE or GNOME desktop), which is very Obviously not installing these programs will significantly improve system performance, ease of operation and beautiful interface at the cost. I think the essence of Linux lies in the richness of the command line. Linux commands can accomplish all tasks.

1. Start, restart, and stop the service of Apache:

cd /etc/init.d command switches to the /etc/init.d directory and run the following command:

./httpd start //启动Apache服务
./httpd restart //重新启动Apache服务
./httpd stop //停止Apache服务
Copy after login

Automatically start the Apache service after booting up

The cd /sbin command switches to the /sbin directory and runs the chkconfig command. Parameters: ./chkconfig --level 5 httpd on

./chkconfig --list You can check whether httpd starts automatically at boot. If 5: starts, it means it starts automatically at boot.

2. Configuration

The cd /etc/httpd/conf command switches to the directory /etc/httpd/conf, use vi editor to open and edit the httpd.conf configuration, before configuring, in order To prevent configuration errors, back up httpd.conf.

fedora8 Use yum to manage and install the basic installation of Apache PHP Mysql.

1. Install Apahce, PHP, Mysql, and the PHP connection mysql library component.

yum -y install httpd php mysql mysql-server php-mysql
Copy after login
Copy after login

2. Configure the startup service at startup

/sbin/chkconfig httpd on             [设置apache服务器httpd服务开机启动]
 /sbin/chkconfig --add mysqld         [在服务清单中添加mysql服务]
 /sbin/chkconfig mysqld on             [设置mysql服务开机启动]
 /sbin/service httpd start            [启动httpd服务,与开机启动无关]
 /sbin/service mysqld start           [启动mysql服务,与开机无关]
Copy after login

3. Set the mysql database root account password.

mysqladmin -u root password 'newpassword'           [引号内填密码]
Copy after login

4. Make the mysql database more secure

mysql -u root -p
mysql> DROP DATABASE test;                            [删除test数据库]
mysql> DELETE FROM mysql.user WHERE user = '';        [删除匿名帐户]
mysql> FLUSH PRIVILEGES;                              [重载权限]
Copy after login

5. According to the above installation method, the default site directory configured is /var/www/html/

New A php script:

<?php
   phpinfo();
?>
Copy after login

6. Create a new database, add a database user, and set user permissions. Write a php script to test the database connection.

mysql> CREATE DATABASE my_db;
mysql> GRANT ALL PRIVILEGES ON my_db.*  BY &#39;password&#39;;
 
 
 
//安装apache扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
//安装php的扩展
yum install php-gd
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
//安装mysql扩展
yum -y installmysql-connector-odbcmysql-devel libdbi-dbd-mysql
Copy after login

Recommended learning: "

PHP Video Tutorial

"

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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to start nginx in Linux How to start nginx in Linux Apr 14, 2025 pm 12:51 PM

Steps to start Nginx in Linux: Check whether Nginx is installed. Use systemctl start nginx to start the Nginx service. Use systemctl enable nginx to enable automatic startup of Nginx at system startup. Use systemctl status nginx to verify that the startup is successful. Visit http://localhost in a web browser to view the default welcome page.

How to check whether nginx is started How to check whether nginx is started Apr 14, 2025 pm 01:03 PM

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

How to start nginx server How to start nginx server Apr 14, 2025 pm 12:27 PM

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP

How to check whether nginx is started? How to check whether nginx is started? Apr 14, 2025 pm 12:48 PM

In Linux, use the following command to check whether Nginx is started: systemctl status nginx judges based on the command output: If "Active: active (running)" is displayed, Nginx is started. If "Active: inactive (dead)" is displayed, Nginx is stopped.

How to solve nginx403 error How to solve nginx403 error Apr 14, 2025 pm 12:54 PM

The server does not have permission to access the requested resource, resulting in a nginx 403 error. Solutions include: Check file permissions. Check the .htaccess configuration. Check nginx configuration. Configure SELinux permissions. Check the firewall rules. Troubleshoot other causes such as browser problems, server failures, or other possible errors.

How to solve nginx304 error How to solve nginx304 error Apr 14, 2025 pm 12:45 PM

Answer to the question: 304 Not Modified error indicates that the browser has cached the latest resource version of the client request. Solution: 1. Clear the browser cache; 2. Disable the browser cache; 3. Configure Nginx to allow client cache; 4. Check file permissions; 5. Check file hash; 6. Disable CDN or reverse proxy cache; 7. Restart Nginx.

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Difference between centos and ubuntu Difference between centos and ubuntu Apr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

See all articles