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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

See all articles