search
Homephp教程php手册CentOS 5.5 uses yum to install Apache PHP MySQL
CentOS 5.5 uses yum to install Apache PHP MySQLJul 09, 2016 am 09:09 AM
apachecentosmysqlphpyumcodeInstallOpen sourceprogrammingprogramming languagesoftware development

1. Install centos5.5 operating system
The CentOS development community has released a new 5.5 version. CentOS 5.5 is based on Red Hat Enterpris Linux 5.5.0, which includes Kernel 2.6.18, Apache 2.2, PHP 5.1.6, MySQL 5.0, PostgreSQL 8, GNOME 2.16, KDE 3.5, OpenOffice.org 2.3, Firefox 3.0, Evolution 2.12, etc. . Additionally, CentOS 5.3 updates the artwork and restores the Contrib repository per user request.
CentOS 5.5 supports i386 and x86_64 architectures, and its ISO image can be obtained from the following address. http://www.wljcz.com/html/caozuoxitong/Linux/2009/0726/409.html
2. System installation
CentOS 5.5 is installed as a server, so if it is useless, it will not be installed; specifically It’s up to you what not to install:
3. Install Apache php Mysql
Before installing with yum, first replace it with the Chinese CentOS5.3 mirror server! Fast and easy-to-use yum update source: http://www .wljcz.com/html/caozuoxitong/Linux/2009/0726/410.html This article has a detailed introduction. After modifying the update source according to the steps provided, you can easily use the yum command to quickly install the software.

1. Update the system kernel to the latest. yum -y update
Install Apahce, PHP, Mysql, and PHP connection mysql library component

Code:
yum -y install httpd php mysql mysql -server php-mysql

2. Install mysql extension

Code:
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
or one-time Paste installation:

Code:
yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php- pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql

3. Set the mysql database root account password.

Code:
mysqladmin -u root password 'newpassword'
"newpassword" represents the password you want to set. The root user password of the newly installed mysql is empty by default. Set the password Then you can make the mysql database more secure

Code:
mysql -u root -p (You will be asked to enter the password you just set, just enter it and press Enter)
mysql> DROP DATABASE test; (delete test database)
mysql> DELETE FROM mysql.user WHERE user = ”; (delete anonymous account)
mysql> FLUSH PRIVILEGES; (overload permissions)

4. Follow the above Installation method, the configured default site directory is /var/www/html/ Create a new php script:

Code:
phpinfo();
?>
4. Configure the firewall
Add allowed access to HTTP and FTP ports

Code:
iptables -I RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
iptables -I RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Restart iptables: service iptables restart
5. Install phpMyAdmin
Go to phpMyAdmin official website to download phpMyAdmin, php 5.2 or above is required for version 3.1 or above, upload it to your website directory, and then configure it in just a few steps. .php is renamed to config.inc.php, then open the config.inc.php file and make the following modifications;
Code:
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
// $cfg['Servers'][$i]['pmadb' ] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
// $cfg['Servers'][$i][' relation'] = 'pma_relation';
// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
// $cfg['Servers'][$i] ['table_coords'] = 'pma_table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
// $cfg['Servers'][$ i]['column_info'] = 'pma_column_info';
// $cfg['Servers'][$i]['history'] = 'pma_history';
// $cfg['Servers'] [$i]['designer_coords'] = 'pma_designer_coords';
Remove the // comment in front of each line
$cfg['blowfish_secret'] = ”; |Modify to| $cfg['blowfish_secret'] = 'http';
$cfg['Servers'][$i]['controluser'] = 'pma'; |Change 'pma' to your account|$cfg['Servers'][$i] ['controlpass'] = 'pmapass'; |Set 'pmapass as your mysql login password
$cfg['blowfish_secret'] = ”; | Add phrase password for example: $cfg['blowfish_secret'] = 'onohot ';
6. Install php extension
Code:
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
7. Install apache extension
Code:
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
At this point, the PHP environment under centos5.3 is basically configured, and you can start the service with the command.
8. If you want to upgrade PHP
Mention that PHP needs to be upgraded to 5.2 or above, and centos 5.x currently provides PHP version 5.1.6.
It is more convenient to upgrade PHP to 5.2 through the following method. Now Recommended to everyone.
First import the following address.

# rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

# vi /etc/yum.repos.d/CentOS-Base.repo Add the following information

[utterramblings]

name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck= 1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

Execute the command to automatically upgrade.

yum update php -y
yum install libmcrypt -y

1. Update the system kernel to the latest.
[root@linuxfei ~]#yum -y update
After the system is updated, if an error message is prompted during yum installation, please execute the following command to fix it.
[ root@linuxfei ~]#rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*
2. Install Apahce, PHP, Mysql, and PHP connection mysql library component
[root@linuxfei ~ ]#yum -y install httpd php mysql mysql-server php-mysql
//Install mysql extension
[root@linuxfei ~]#yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
//Install php extension
[root@linuxfei ~]# yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
//Install apache extension
[root@linuxfei ~]#yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
One-time paste installation:
[root@linuxfei ~]# yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql

3. Start service configuration
[root@linuxfei ~]# /sbin/chkconfig httpd on [Set apache to start automatically]
[root@linuxfei ~]# /sbin/chkconfig –-add mysqld [ mysql service]
[root@linuxfei ~]# /sbin/chkconfig mysqld on [mysqld service]
[root@linuxfei ~]# /sbin/service httpd start [self-start httpd service]
[root @linuxfei ~]# /sbin/service mysqld start [Self-start mysqld service]
4. Set the mysql database root account password.
[root@linuxfei ~]# mysqladmin -u root password 'linuxfei' [Password in quotes]
[root@linuxfei ~]# mysql -u root -p ← Log in as root with an empty password
Enter password:linuxfei ← Enter password here

Welcome to the MySQL monitor. Commands end with ; or g. ← Confirm that you can log in successfully with your password
Your MySQL connection id is 5 to server version: 4.1.20

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

5. Install phpmyadmin
[root@linuxfei /]# wget http://gd2.down.chinaz.com:808/data management/phpMyAdmin-3.tar.gz
--2010-03 -23 16:38:18-- http://gd2.down.chinaz.com:808/??????/phpMyAdmin-3.x.tar.gz
Resolving gd2.down.chinaz.com ... 121.11.80.154
Connecting to gd2.down.chinaz.com|121.11.80.154|:808... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4700100 (4.5M) [application/x-gzip]
Saving to: `phpMyAdmin-3.x.tar.gz'

100%[======================================>] 4,700,100 134K/s in 37s

2010-03-23 ​​16:38:56 (123 KB/s) - `phpMyAdmin-3.x.tar.gz' saved [4700100/4700100]

Unzip phpmyadmin

[root@centos5 /]#tar zxvf phpMyAdmin-3.x.tar.gz

[root@linuxfei /]# mv phpMyAdmin-3.3.1-all-languages ​​/var/www/html/phpmyadmin

Move the extracted directory to the /var/www directory and rename it to phpmyadmin

Modify config.sample.inc.php in the root directory of phpmyadmin and rename it to config.inc.php

Open and edit config.inc.php

$cfg['blowfish_secret'] = '';

Find the two lines below and remove //

// $cfg['Servers'][$i]['controluser'] = 'pma'; mysql username
// $cfg['Servers'][$i]['controlpass'] = 'pmapass' mysql password


apache configuration

/etc/httpd/conf/httpd.conf
The most important configuration file, but many other distributions split this file into several small files to manage different parameters respectively. But the most important configuration file is still based on this file name.
/etc/httpd/conf.d/*.conf
This is one of the features of CentOS. If you don’t want to modify the original configuration file httpd.conf, you can separate your own additional parameters, and When starting apache, this file will be read into the main configuration file.
/usr/lib/httpd/modules
Apache supports many modules, so the modules you want to use are placed in this directory by default
/var/www/html
This is the default for CentOS The directory where the "Home Page" is located.
/var/www/error
If the host setting is wrong or the data required by the browser is wrong, the error message that appears on the browser will be based on the default information of this directory.
/var/www/icons
Provides some small icons for apache
/var/www/cgi-bin
The directory where some executable CGI programs are placed by default
/var/log /httpd
By default, apache’s log files are placed here. For websites with high traffic, be very careful with this directory, because this file can easily become large, and you need enough space.
/usr /sbin/apachectl
This is the main executable file of Apache. This executable file is actually a shell script. It can actively detect some settings on the system, making it easier for you to start Apache.
/usr/sbin/ httpd
This is the main apache binary file
/usr/bin/htpasswd
When you want to log in to certain web pages, you need to enter your account number and password. Then Apache itself provides the most basic password protection method. The password is generated through this command

As for MySQL, the important directories and files you need to know are as follows:
/etc/my.cnf: This is the MySQL configuration file, including the optimization of the MySQL database you want to , or you are specifying some additional parameters for mysql, you can implement it in this file
/usr/lib/mysql: This directory is where the MySQL database is placed. When starting any MySQL server, please be sure to remember to When backing up, back up this directory completely.

In addition, in terms of PHP, you should know the following files.
/usr/lib/httpd/modules/libphp4.so: The module provided by PHP to apache. This is related to whether we can design the most important file of the PHP programming language on the apache web page
/etc/httpd/conf .d/php.conf: Do you want to manually write this module into Httpd.conf? No, because the system has actively written the PHP setting parameters into this file, and this file will be read when Apache restarts.
/etc/php.ini: This is the main configuration file of PHP, including whether PHP can allow users to upload files, whether it can allow certain low-security flags, etc., are all set in this configuration file.
/etc/php.d/mysql.ini /usr/lib/php4/mysql.so: Whether PHP can support the MySQL interface depends on these two files. These two files are provided by php-mysql software
/usr/bin/phpize /usr/include/php: If you want to install a similar PHP accelerator in the future to speed up browsing, then this file and directory are It needs to exist, otherwise the accelerator software cannot be used.

Basic settings of httpd.conf
First of all, you need to have a complete host name in /etc/hosts, otherwise when restarting the apache service, you will be prompted that the complete host name cannot be found.
The basic settings of httpd.conf are as follows:

Set the relevant parameters in the project
times. . . .

For example, if you want to provide additional functions for the homepage /var/www/html, you can set it as follows:

Options Indexes
……


Setting projects for the host environment
#vi /etc/httpd/conf/httpd.conf
ServerTokens OS
# This project tells the client the version and operating system of the WWW server, No need to adapt it
#If you don’t want to tell too much host information, change the OS of this project to Minor

ServerRoot "/etc/httpd"
#This is the top-level directory of the settings file. Absolute paths are usually used. When some of the following data settings use relative paths,
#is the lower level related to the setting value of this directory. Directory, no need to change it
ServerRoot
Set the absolute path of Apache installation
TimeOut
Set the maximum waiting time for server reception to completion
KeepAlive
Set whether the server is turned on For the continuous request function, real servers generally need to open
Port
to set the default port of the http service.
User/Group
sets the executor and group of the server program. This is usually apache

Let’s do a few experiments on Apache
1: We test changing the default website directory to the root home directory
Create a new /root/website directory
#mkdir -p /root/website
#echo "website page" >> /root/website/index.html
#vi /etc/httpd/conf/httpd.conf
Find the DocumentRoot "/var/www/html" section // The root directory of apache
Change the directory /var/www/html to /root/website
Find // Define the area of ​​​​apache /var/www/html
Change /var/www/html into /root/website
In this way, we have changed the default path of apahce
Then restart the service
#service httpd restart
//When you restart the service here, an error may be reported, saying The directory cannot be found. This is mainly caused by selinux
So how to solve it? There are two ways, turn off selinux
#setenforce 0
or change the selinux attribute of the /root/website file so that it matches the requirements of the httpd server
How to change it? We can copy the selinux attributes of the /var/www/html directory
#chcon -R --reference /var/www/html /root/website
and then restart the service, and then you will see that it does not report an error
But when you go to access localhost, you will find that access is denied. Why? Mainly because your /root permissions are 750, and user ahache does not have permission to access. You need to change the permissions. You can change it like this
#chmod -R 755 /root
and then access it and find it normal

2: Name-based virtual host
requires two domain names to be resolved to your server. The corresponding relationship is
/var/www/server server.example.com
/var/www/client client .example.com
When accessing these two domain names, the contents of the homepages in different files can be displayed respectively
#echo "server page" >> /var/www/server/index.html
# echo "client page" >> /var/www/client/index.html
Then we edit a configuration file
#vi /etc/httpd/conf.d/virtual.conf //Remember conf.d The content inside is also the apache configuration file
. Add the following content:
NameVirtualHost 192.168.76.133:80

ServerName service.example.com
DocumentRoot /var/www/server

ServerName client.example.com
DocumentRoot /var/www/client

#service httpd restart
In this way, the name-based virtual host is configured
If you do not have DNS, you can add a record to the hosts file on your machine. The file Linux is in /etc/hosts and Windows is in C: windowssystem32driversetchosts file
add these two lines
192.168.76.133 server.example.com
192.168.76.133 client.example.com
In this way, when you test it, you will find that different domain names are displayed differently. The content is so that the name-based virtual host is configured!

3: Virtual host based on IP address
Add a temporary network card first
#ifconfig eth0:0 192.168.76.132 //Temporary use, it will disappear after restarting
Then convenient virtual.conf file
#vi /etc/httpd/conf.d/virtual.conf
Change the content to
#NameVirtualHost 192.168.76.133:80


ServerName service.example.com
DocumentRoot /var/www/server

ServerName client.example.com
DocumentRoot /var/www/client

Then you use IP to access, and you find that different content can be displayed, or you edit the hosts file and access with domain name is no problem
In this way, the virtual host based on IP address is also successful!

4: Alias ​​
Add
Alias ​​/test "/root/website/" to /etc/httpd/conf/httpd.conf // Alias ​​will also be displayed when you use 192.168.76.133/test to access it The page of 192.168.76.133
What you need to pay attention to here is the difference between /test and /test/. If you use /test, you can only access it with 192.168.76.133/test. If you use /test/, then 192.168.76.133/test/, and /test will not let you access
Forgot to comment out the virtual directory just set in the /etc/httpd/conf.d directory, otherwise it will not be accessible. Yes Because a virtual directory is created, the settings in httpd.conf cannot be accessed. Of course, you can use localhost to access it, but other accesses will not work

5: Implement web page resource download
First add an alias
#vi /etc/httpd/conf/httpd.conf
Add after Alias ​​/test "/root/website/"
Alias ​​/down "/var/ftp/pub"
Let’s set parameters for the /var/ftp/pub area

Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all

Add MultiViews to Options // Automatically list directory documents when there is no index
Then restart the service, so that the files in /var/ftp/pub can be listed in http://192.168.76.133/down/ , try clicking Save As. Can it be downloaded? Haha success!

6: Implementation of .htpasswd
#vi /etc/httpd/conf/httpd.conf
We will do it for the /var/ftp/pub we just created
Add the following information
Alias /down "/var/ftp/pub/"

Options Indexes MultiViews
AllowOverride AuthConfig
Order allow,deny
Allow from all


AuthType Basic
AuthName "this is test"
AuthUserFile /etc/httpd/htpasswd
Require User test

Then restart the httpd service,
generate the .htpasswd user password
htpasswd -c /etc/httpd/htpasswd test
then access 192.168.76.133/down and you will need a password
like this It was successful

This article comes from qkweb.net, please indicate the source when reprinting http://www.qkweb.net/showa/715.html

Statement
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
centos用什么命令可查版本号centos用什么命令可查版本号Mar 03, 2022 pm 06:10 PM

查版本号的命令:1、“cat /etc/issue”或“cat /etc/redhat-release”,可输出centos版本号;2、“cat /proc/version”、“uname -a”或“uname -r”,可输出内核版本号。

centos重启网卡的方法是什么centos重启网卡的方法是什么Feb 22, 2023 pm 04:00 PM

centos重启网卡的方法:1、对于centos6的网卡重启命令是“service network restart”;2、对于centos7的网卡重启命令是“systemctl restart network”。

centos php怎么安装opcachecentos php怎么安装opcacheJan 19, 2023 am 09:50 AM

centos php安装opcache的方法:1、执行“yum list php73* | grep opcache”命令;2、通过“yum install php73-php-opcache.x86_64”安装opcache;3、使用“find / -name opcache.so”查找“opcache.so”的位置并将其移动到php的扩展目录即可。

centos 怎么离线安装 mysqlcentos 怎么离线安装 mysqlFeb 15, 2023 am 09:56 AM

centos离线安装mysql的方法:1、将lib中的所有依赖上传到linux中,并用yum命令进行安装;2、解压MySQL并把文件复制到想要安装的目录;3、修改my.cnf配置文件;4、复制启动脚本到资源目录并修改启动脚本;5、将mysqld服务加入到系统服务里面;6、将mysql客户端配置到环境变量中,并使配置生效即可。

centos 7安装不出现界面怎么办centos 7安装不出现界面怎么办Jan 03, 2023 pm 05:33 PM

centos7安装不出现界面的解决办法:1、选择“Install CentOS 7”,按“e”进入启动引导界面;2、 将“inst.stage2=hd:LABEL=CentOS\x207\x20x86_64”改为“linux dd”;3、重新进入“Install CentOS 7”,按“e”将“hd:”后的字符替换成“/dev/sdd4”,然后按“Ctrl+x”执行即可。

centos 怎么删除 phpcentos 怎么删除 phpFeb 24, 2021 am 09:15 AM

centos删除php的方法:1、通过“#rpm -qa|grep php”命令查看全部php软件包;2、通过“rpm -e”命令卸载相应的依赖项;3、重新使用“php -v”命令查看版本信息即可。

如何在 CentOS 9 Stream 上安装 Nagios如何在 CentOS 9 Stream 上安装 NagiosMay 10, 2023 pm 07:58 PM

我们的PC中有一个磁盘驱动器专门用于所有与Windows操作系统相关的安装。该驱动器通常是C驱动器。如果您还在PC的C盘上安装了最新的Windows11操作系统,那么所有系统更新(很可能是您安装的所有软件)都会将其所有文件存储在C盘中。因此,保持此驱动器没有垃圾文件并在C驱动器中拥有足够的存储空间变得非常重要,因为该驱动器拥有的空间越多,您的Windows11操作系统运行起来就越顺畅。但是您可以在磁盘驱动器上增加多少空间以及可以删除多少文件是有限制的。在这种情况下,

centos中ls命令不显示颜色怎么办centos中ls命令不显示颜色怎么办Apr 20, 2022 pm 03:16 PM

方法:1、利用“vim ~/.bashrc”编辑用户目录(~)下的“.bashrc”文件;2、在文件内添加“alias ls="ls --color"”;3、利用“:wq!”命令保存文件内的更改;4、“exit”命令退出终端后重新连接即可。

See all articles

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)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment