Linux Red Hat 5 企业版 常用命令
1,挂载光盘 #mkdir /mnt/cd #mount /dev/cdrom /mnt/cd 2,卸载光盘 #umount /mnt/cd 3,修改yum 源为光盘 #vi /etc/yum.repos.d/rhel-debuginfo.repo #cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.bak 修改之前备份 #内容修改为 [rhel-debuginfo] name=Red Hat Enterprise Linux $releasever - $basearch - Debug baseurl=file:///mnt/cd/Server enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release #ESC : wq 保存 4,yum 常用命令 #yum install httpd 安装一个软件 #yum remove httpd 卸载一个软件 #yum update httpd 更新一个软件 5,rpm 常用命令 #rpm -ivh xxx.i386.rpm 安装一个软件 #rpm -e xxx.i386.rpm 卸载一个软件 只用写主名称即可 rpm -e httpd #rpm -qa 显示所有已安装的软件 加参数 | grep httpd 可以查找某个软件包 6,查看网络端口 #netstat -antp | grep 80 7,强制关闭进程 #kill -9 PID 可以使用 ps 或 top 命令来查询 PID #pkill -9 http 使用进程名关闭 8,ps 查进程 #ps -aux | grep 80 或者 ps -aux | grep http 9,tar 命令 #tar -vxzf xxx.i386.tar.gz 解压缩包 #tar -cvf /tmp/etc.tar /etc <==仅打包,不压缩 #tar -zcvf /tmp/etc.tar.gz /etc <==打包后,以 gzip 压缩 #tar -jcvf /tmp/etc.tar.bz2 /etc <==打包后,以 bzip2 压缩 # 特别注意,在参数 f 之后的文件档名是自己取的,我们习惯上都用 .tar 来作为辨识。 # 如果加 z 参数,则以 .tar.gz 或 .tgz 来代表 gzip 压缩过的 tar file ~ # 如果加 j 参数,则以 .tar.bz2 来作为附档名啊~ # 上述指令在执行的时候,会显示一个警告讯息: 10,源码安装 lmap #安装 mysql #tar zxvf mysql-5.0.86-linux-i686-icc-glibc23.tar.gz #cp -R mysql-5.0.86-linux-i686-icc-glibc23 /user/local/mysql #groupadd mysql #useradd -g mysql mysql -d /home/mysql -s /sbin/nologin #chown -R mysql:mysql /usr/local/mysql #/usr/local/mysql/script//scripts/mysql_install_db --user=mysql #cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql #cp support-files/my-medium.cnf /etc/my.cnf #service mysql start #bin/mysqladmin -uroot password '123456' 新装mysql root 密码为空时可以使用mysqladmin 初始化密码 修改以后无需重启即可生效 #忘记密码时修改mysql 密码方法 #pkill -9 mysql #bin/mysqld_safe --skip-grant-tables --skip-networking & 如果在本机上操作不用 --skip-networking #bin/mysql update mysql.user set password = password('abc') where user = 'root'; FLUSH PRIVILEGES; #service mysql restart #安装apache 2.2 #wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.2.22.tar.bz2 #tar jxfv httpd-2.2.22.tar.bz2 #cd httpd-2.2.22 #configure --prefix=/usr/local/apache --enable-rewrite --enable-so #make && make install #make clean 清除编译文件 #cd /usr/local/apache/ #cp bin/apachectl /etc/init.d/apache #service apache start 打开浏览器看是否 It words! #service apache stop 将apache 关闭,下面我们来安装php 安装php5.4 #wget http://cn.php.net/get/php-5.4.3.tar.bz2/from/this/mirror #tar jxvf php-5.4.3.tar.bz2 #cd php-5.4.3 #./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --without-iconv --with-mysql --with-mysql-sock --with-libxml-dir --enable-zip --enable-mbstring --with-gd #可以输出这个提示说明没有错误 +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP. #make && make install #make clean #cp php.ini-production /usr/local/php5/lib/php.ini 启动新建一个 phpinfo.php 打开服务器 报错。 httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied #关闭SELINUX #vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled 需要重启 #重启以访问 localhost/phpinfo.php 直接输出代码。未解析。这个可能和PHP 版本有关,这次使用的是最新版 php 5.4 原来用 php 5.3.10 会自动添加 修改httpd.cnf AddType application/x-httpd-php .php 11,nginx php mysql #主要是 php 和 nginx 因为 mysql 已经安装好了。在以上的基础上在添加 --enable-fpm --with-apxs2=/usr/local/apache/bin/apxs 即可。 #cd php-5.4.3 #./configure --prefix=/usr/local/php5 --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --without-iconv --with-mysql=/usr/local/mysql --with-libxml-dir --enable-zip --enable-mbstring --with-gd --enable-fpm #编译时报错 Note that the MySQL client library is not bundled anymore! #添加mysql 安装位置就正常了。 #cp php.ini-production /usr/local/php5/lib/php.ini #cd /usr/local/php5/ #cp etc/php-fpm.conf.default etc/php-fpm.conf #sbin/php-fpm 启动fpm 使用ps 查看是否启动 ##安装nginx #./configure --prefix=/usr/local/nginx #make && make install #cd /usr/local/nginx #vi conf/nginx.cnf #欢迎页 location / { root html; index index.html index.htm index.php; } #启动 fpm location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name; include fastcgi_params; } #启动nginx #sbin/nginx& 12,开机自动启动 #chkconfig 版本 1.3.30.1 - 版权 (C) 1997-2000 Red Hat, Inc. 用法: chkconfig --list [name] chkconfig --add <name> chkconfig --del <name> chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities> #chkconfig --add mysql #chkconfig mysql on #添加自启动 #vi /etc/rc.d/rc.local