国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Apache > 正文

centos系統安裝php+mysql的apache服務器

2024-08-27 18:30:24
字體:
來源:轉載
供稿:網友
VEVB友情提示:CentOS 5.x yum安裝LAMP(Apache+MySQL+PHP)。

 

LAMP是Linux,Apache,MySQL,PHP的縮寫。這個教程主要是講在centos安裝有php和mysql支持的apache web服務器。在這個教程我使用主機名server1.example.com對應IP地址192.168.0.100。這些設置可能不同于你,你必須替換成你正確的。

添加外部源,保證MySQL和PHP最新

因為系統基本的源的MySQL和PHP程序比較舊,所以我們添加比較新的外部源。

1 # rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
2 # vi /etc/yum.repos.d/CentOS-Base.repo

在底部增加下面信息

1 [utterramblings]
2 name=Jason's Utter Ramblings Repo
3 baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
4 enabled=1
5 gpgcheck=1
6 gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

安裝MySQL

執行yum程序安裝MySQL

1 yuminstallmysql mysql-server

添加MySQL進啟動項(這樣系統啟動時會自動啟動MySQL),并立即啟動MySQL服務器:

1 chkconfig --levels 235 mysqld on
2 /etc/init.d/mysqldstart

設置MySQL root帳號密碼:

1 mysql_secure_installation
 
01 NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
02 SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
03  
04 In order to log into MySQL to secure it, we'll need the current
05 passwordforthe root user. If you've just installed MySQL, and
06 you haven'tsetthe root password yet, the password will be blank,
07 so you should just press enter here.
08  
09 Enter current passwordforroot (enterfornone):
10 OK, successfully used password, moving on...
11  
12 Setting the root password ensures that nobody can log into the MySQL
13 root user without the proper authorisation.
14  
15 Set root password? [Y/n] <-- ENTER
16 New password: <-- 你的MySQL root密碼
17 Re-enter new password: <-- 你的MySQL root密碼
18 Password updated successfully!
19 Reloading privilege tables..
20 ... Success!
21  
22 By default, a MySQL installation has an anonymous user, allowing anyone
23 to log into MySQL without having to have a user account createdfor
24 them. This is intended onlyfortesting, and tomakethe installation
25 go a bit smoother. You should remove them before moving into a
26 production environment.
27  
28 Remove anonymoususers? [Y/n] <-- ENTER
29 ... Success!
30  
31 Normally, root should only be allowed to connect from'localhost'. This
32 ensures that someone cannot guess at the root password from the network.
33  
34 Disallow root login remotely? [Y/n] <-- ENTER
35 ... Success!
36  
37 By default, MySQL comes with a database named'test'that anyone can
38 access. This is also intended onlyfortesting, and should be removed
39 before moving into a production environment.
40  
41 Removetestdatabase and access to it? [Y/n] <-- ENTER
42 - Droppingtestdatabase...
43 ... Success!
44 - Removing privileges ontestdatabase...
45 ... Success!
46  
47 Reloading the privilege tables will ensure that all changes made so far
48 will take effect immediately.
49  
50 Reload privilege tables now? [Y/n] <-- ENTER
51 ... Success!
52  
53 Cleaning up...
54  
55 Alldone! If you've completed all of the above steps, your MySQL
56 installation should now be secure.
57  
58 Thanksforusing MySQL!

安裝Apache

Apache在CentOS軟件包可用,因此我們可以使用yum安裝:

1 yuminstallhttpd

設置系統啟動時自啟動Apache

1 chkconfig --levels 235 httpd on

并啟動Apache

1 /etc/init.d/httpdstart

現在你直接在你的瀏覽器鍵入http://192.168.0.100,你就應該會看到Apache的測試頁面。

安裝PHP

我們可以按照下面的命令安裝PHP和Apache PHP模塊:

1 yuminstallphp

然后重啟Apache服務器:

1 /etc/init.d/httpdrestart

安裝相關模塊使用PHP支持MySQL

為了讓PHP支持MySQL,我們可以安裝php-mysql軟件包。你也可以安裝其它的php模塊。可以使用以下命令搜索可用的php模塊:

1 yum search php

選擇一些你需要的模塊進行安裝:

1 yuminstallphp-mysql php-common php-mbstring php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

現在重啟Apache:

1 /etc/init.d/httpdrestart

安裝phpMyAdmin

phpMyAdmin是一個可視化管理你的MySQL數據庫的軟件。
安裝很簡單,下載解壓到根目錄即可.
下載地址:http://www.phpmyadmin.net/home_page/downloads.php
接著我們配置phpMyAdmin,為了使用phpMyAdmin不僅僅只允許localhost連接,我們修改一下apache的配置。

1 vi/etc/httpd/conf.d/phpmyadmin.conf

填入如下內容:

01 #
02 # Web application to manage MySQL
03 #
04  
05 #<directory share="" phpmyadmin?="" usr="" ?="">
06 # Order Deny,Allow
07 # Deny from all
08 # Allow from 127.0.0.1
09 #</directory>
10  
11 Alias/phpmyadmin/usr/share/phpmyadmin
12 Alias/phpMyAdmin/usr/share/phpmyadmin
13 Alias/mysqladmin/usr/share/phpmyadmin

重啟apache:
/etc/init.d/httpd restart
然后你就可以通過http://192.168.0.100/phpmyadmin/進入phpMyAdmin了。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 兴和县| 陆良县| 梓潼县| 龙泉市| 伊金霍洛旗| 深水埗区| 平顶山市| 雅江县| 西昌市| 砀山县| 鄯善县| 长乐市| 梁平县| 潮州市| 镇远县| 淮南市| 临泽县| 调兵山市| 精河县| 治多县| 江口县| 彰武县| 兴化市| 肃南| 方城县| 新化县| 红安县| 怀集县| 台州市| 奈曼旗| 布拖县| 岗巴县| 温州市| 韩城市| 栾川县| 宣汉县| 政和县| 夏河县| 柳州市| 象山县| 六枝特区|