Home > Article > Backend Development > How to install php environment in linux 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.
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
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服务,与开机无关]
3. Set the mysql database root account password.
mysqladmin -u root password 'newpassword' [引号内填密码]
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; [重载权限]
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
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... ###数据库运行正常;
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服务
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
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服务,与开机无关]
3. Set the mysql database root account password.
mysqladmin -u root password 'newpassword' [引号内填密码]
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; [重载权限]
5. According to the above installation method, the default site directory configured is /var/www/html/
New A php script:
<?php phpinfo(); ?>
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 '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 installmysql-connector-odbcmysql-devel libdbi-dbd-mysql
Recommended learning: "
PHP Video TutorialThe 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!