##创建普通用户,并切换到普通用户下
useradd lvnian002
tail -5 /etc/passwd
echo asdasd | passwd --stdin lvnian002
su lvnian002
##########
[[email protected] conf]# useradd lvnian002
tail -5 /etc/passwd
echo asdasd | passwd --stdin lvnian002
su lvnian002[[email protected] conf]# tail -5 /etc/passwd
tcpdump:x:72:72::/:/sbin/nologin
mysql:x:500:500::/home/mysql:/sbin/nologin
lvnian:x:501:501::/home/lvnian:/sbin/nologin
apache:x:502:502::/home/apache:/sbin/nologin
lvnian002:x:503:503::/home/lvnian002:/bin/bash
[[email protected] conf]# echo asdasd | passwd --stdin lvnian002
Changing password for user lvnian002.
passwd: all authentication tokens updated successfully.
[[email protected] conf]# su lvnian002
[[email protected] conf]$
###创建apache服务目录,并创建相关目录,已经配置文件
mkdir -p /home/lvnian002/application/apache
cp /application/apache/conf /home/lvnian002/application/apache/ -ap
cp /application/apache/logs /home/lvnian002/application/apache/ -ap
cp /application/apache/htdocs /home/lvnian002/application/apache/ -ap
cp /application/apache/error /home/lvnian002/application/apache/ -ap
[[email protected] conf]$ mkdir -p /home/lvnian002/application/apache
[[email protected] conf]$ cp /application/apache/conf /home/lvnian002/application/apache/ -ap
[[email protected] conf]$ cp /application/apache/logs /home/lvnian002/application/apache/ -ap
[[email protected] conf]$ cp /application/apache/htdocs /home/lvnian002/application/apache/ -ap
[[email protected] conf]$ cp /application/apache/error /home/lvnian002/application/apache/ -ap
[[email protected] conf]$
###修改普通用户的apache服务端口号,防止和其他apache服务端口号一样
cd /home/lvnian002/application/apache/conf/
#less apache.conf
grep -i listen httpd.conf
sed -i ‘s/listen 80/listen 8080/g‘ apache.conf
grep -i listen httpd.conf
#######
[[email protected] conf]$ grep -i listen httpd.conf
# Listen: Allows you to bind Apache to specific IP addresses and/or
# Change this to Listen on specific IP addresses as shown below to
#Listen 12.34.56.78:80
Listen 80
[[email protected] conf]$
[[email protected] conf]$ sed -i ‘s/Listen 80/Listen 8080/g‘ httpd.conf
[[email protected] conf]$ grep -i listen httpd.conf
# Listen: Allows you to bind Apache to specific IP addresses and/or
# Change this to Listen on specific IP addresses as shown below to
#Listen 12.34.56.78:80
Listen 8080
[[email protected] conf]$
######启动apahce服务,并检查是不是普通用户启动的
/application/apache/bin/httpd -f /home/lvnian002/application/apache/conf/httpd.conf -k start
netstat -lnt
ps -ef |grep httpd
########3
[[email protected] conf]$ /application/apache/bin/httpd -f /home/lvnian002/application/apache/conf/httpd.conf -k start
[[email protected] conf]$ netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 :::8080 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 ::1:25 :::* LISTEN
[[email protected] conf]$
[[email protected] conf]$ ps -ef |grep httpd
503 43857 1 0 13:18 ? 00:00:00 /application/apache/bin/httpd -f /home/lvnian002/application/apache/conf/httpd.conf -k start
503 43858 43857 0 13:18 ? 00:00:00 /application/apache/bin/httpd -f /home/lvnian002/application/apache/conf/httpd.conf -k start
503 43859 43857 0 13:18 ? 00:00:00 /application/apache/bin/httpd -f /home/lvnian002/application/apache/conf/httpd.conf -k start
503 43860 43857 0 13:18 ? 00:00:00 /application/apache/bin/httpd -f /home/lvnian002/application/apache/conf/httpd.conf -k start
503 43861 43857 0 13:18 ? 00:00:00 /application/apache/bin/httpd -f /home/lvnian002/application/apache/conf/httpd.conf -k start
503 43963 43763 0 13:23 pts/1 00:00:00 grep httpd
[[email protected] conf]$
故障解决:
[[email protected] conf]$ /application/apache/bin/httpd -f /home/lvnian002/application/apache/conf/httpd.conf -k start
(13)Permission denied: httpd: could not open error log file /application/apache2.22.27/logs/error_log.
Unable to open logs
[[email protected] conf]$
切换到root用户下,给logs文件授权
[[email protected] apache]# chmod 777 /application/apache2.22.27/logs -R
[[email protected] apache]#