Ubuntu重启apache2以及开启Rewrite遇到的问题

首先开启Rewrite:

admin@ubuntu:~$ sudo a2enmod rewrite
[sudo] password for admin: 
Enabling module rewrite.
To activate the new configuration, you need to run:
  service apache2 restart

提示重启apache2服务器,使用service apache2 restart重启时遇到问题:

admin@ubuntu:~$ service apache2 restart
 * Restarting web server apache2                                                /usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

百度了一下,大概是说:

这个错误只是说没有明确设定APACHE的主机名,而且也不能根据当前的IP的反向解析得到该主机名。
所以你需要手工配置。如果只是个人测试,配置为localhost倒无所谓;如果是真实服务器,建议配置为真实的主机名,而且是FQDN的,即包括主机名和域名的这种,如www.linux.cn

网上解决方法有几种,我试了其中一种:

解决方法:
sudo gedit /etc/apache2/apache2.conf

在文件后面加上:
#Server Name
ServerName 127.0.0.1

重启成功:

admin@ubuntu:~$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                 ... waiting                                                             [ OK ]

然后继续搞伪静态,百度来的:

sudo gedit /etc/apache2/sites-available/default #修改以下地方

Options FollowSymLinks

AllowOverride None(修改为AllowOverride All)

Options Indexes FollowSymLinks MultiViews

AllowOverride None(修改为AllowOverride All)

Order allow,deny

allow from all

开启wordpress的伪静态,然后执行命令查看.htaccess文件:

sudo gedit /var/www/mylog/.htaccess

# BEGIN WordPress

RewriteEngine On
RewriteBase /mylog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mylog/index.php [L]


# END WordPress

在我电脑上没有立即生效,过了一段时间,大概有10多分钟,才生效。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注