创建扩张目录,存放虚拟主机的配置,因为在企业里由于需要配合大量的业务,所以配置内容也会随之增加,如果全部都是在nginx.conf里的话会使得整个文件非常的臃肿。
apache的重启:./bin/apachectl restart
nginx的配置文件每句结尾一定要加上;(分号)
windows修改hosts的路径:win+R--> system32--> drivers --> etc-->hosts。如果记事本不能修改,请先以管理员运行记事本,在把hosts文件拖入。推荐使用Notepad++。
Apache服务器在站点目录下没有index.html时,可以访问并查看整个网站的目录结构,可以通过修改httpd.conf中的“Options Indexes FollowSymLinks”---> "Options -Indexes FollowSymLinks"。nginx安全新则相对高点,如果没有index.html文件直接报错一般是403.
Apache服务器的默认站点目录是DocumentRoot。Nginx是root html。
服务器一定要隐藏版本号,否则容易被攻击。
++++++++++++++++++++++nginx服务安装完成++++++++++++++++++++++++
Mysql
4、安装二进制mysql
mysql分类:
社区版
商业版
集群
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz
tar zxvf mysql-5.5.32-linux2.6-x86_64.tar.gz
cp -avr mysql-5.5.32-linux2.6-x86_64/ /application/
cd /application/
mv mysql-5.5.32-linux2.6-x86_64/ mysql-5.5.32/
ln -s mysql-5.5.32/ mysql
useradd -M -s /sbin/nologin mysql
cd mysql
mkdir /application/mysql/data -p
chown -R mysql:mysql /application/mysql-5.5.32/
-----------------------------------------------------------------
./scripts/mysql_install_db --basedir=/application/mysql/
--datadir=/application/mysql/data/ --user=mysql
##初始化数据库
mysql_install_db根据版本的不同可能存放的路径也不一样
--basedir是mysql的安装路缙
--datadir是数据文件存放路径
--user是用户名
成功的标准是echo $?没有错误+两个OK没有error
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
##想要开机自动启动,就把mysql.server放到正确的位置即/etc/init.d/mysqld
/application/mysql//bin/mysqladmin -u root password 'new-password'
/application/mysql//bin/mysqladmin -u root -h linuxidc password 'new-password'
Alternatively you can run:
/application/mysql//bin/mysql_secure_installation
##设置密码的方法
You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &
##运行数据库
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl
##测试数据库
提示:/etc/init.d/mysqld实质是复制了mysql.server文件,所以一定不要和cd /application/mysql/
; /application/mysql//bin/mysqld_safe &方法一起用否则会出错
---------------------------------------------------------------
\cp support-files/my-medium.cnf /etc/my.cnf
\cp support-files/mysql.server /etc/init.d/mysqld
--------------------------------------
vim /etc/init.d/mysqld
..................
basedir=/application/mysql/
datadir=/application/mysql/data
...................
或者
#sed -i'46s/\(basedir=\)/\1\/application\/mysql/p' /etc/init.d/mysqld
##修改46行为basedir=/application/mysql,只限定当前环境,其他环境可能有变化
#sed -i'47s/\(datadir=\)/\1\/application\/mysql\/data/p' /etc/init.d/mysqld
##修改datadir为/application/mysq/data
----OK---------------------------------
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
echo "export PATH=/application/mysql/bin:$PATH" >> /etc/profile
source /etc/profile
----------------------------------------------------
mysql_secure_installation
##以下内容看自己的需求
mysql -uroot -p
mysql>show databases;
mysql> use mysql
mysql> show tables;
mysql> select User,Host from user;
mysql>DELETE FROM user WHERE User='root' and Host='::1';
## 目前是不会用的到的所以删除,如果有需求就不用删除
mysql> quit
--OK--------------------------------------------------
总结: