[root@localhost ~]# service httpd start \\启动httpd服务;注意httpd和apache的关系
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
[root@localhost ~]# chkconfig httpd on \\设置httpd开启自器
mysql的初始化
[root@localhost ~]# service mysqld start \\开启mysql服务,会提示需要初始化,很详细
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
[root@localhost ~]# chkconfig mysqld on \\设置mysql开机自启动
[root@localhost ~]# mysqladmin -u root password linuxprobe.com
\\初始化mysql,在这里需要设置mysql的root的密码;命令:mysqladmin -u 用户 password 密码
[root@localhost ~]# mysql -u root -p \\登录mysql查看是否能够登录
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> \\ok登录成功
[root@localhost ~]# ls /etc/httpd/ \\配置文件目录,相关配置模块
conf/ conf.d/ logs/ modules/ run/
[root@localhost ~]# vi /etc/httpd/conf/
httpd.conf magic
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf \\主配文件
[root@localhost ~]# wc -l /etc/httpd/conf/httpd.conf
1009 /etc/httpd/conf/httpd.conf
\\ 主配文件共有1009行,其中有好多都是注释的.养成好习惯,备份默认配置文件
[root@localhost ~]# tail /etc/httpd/conf/httpd.conf \\更多配置建议参考《linux就该这样学》相关内容
# The first VirtualHost section is used for requests without a known
# server name.
#
# \\配置文件中添加虚拟主机的语句
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#
高级环境的测试
LAMP是一个稳定的动态的网站架构方案,在这里我们需要添加php的支持,测试动态网站。
启用对php的支持
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
[root@localhost ~]# cat /etc/httpd/conf/httpd.conf |grep DirectoryIndex
\\在配置文件402行添加对php页面的支持
# DirectoryIndex: sets the file that Apache will serve if a directory
添加php测试页面,测试
[root@localhost ~]# vi /var/www/html/index.php
[root@localhost ~]# cat /var/www/html/index.php \\添加php信息的测试页面
[root@localhost ~]# vi /var/www/html/test.php
[root@localhost ~]# cat /var/www/html/test.php \\添加php页面测试
test
this php test