Notes for installing WordPress on Debian.
Apache2 VirtualHost (HTTP/S)
Enable Apache rewrite and ssl modules:
# a2enmod rewrite ssl
Add the following configuration to /etc/apache2/httpd.conf
.
<VirtualHost *:80> ServerAdmin [email protected] ServerName example.com ServerAlias blog.example.com RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined </VirtualHost> <VirtualHost *:443> ServerAdmin [email protected] ServerName example.com ServerAlias blog.example.com SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCertificateFile /etc/ssl/webserver/server.crt SSLCertificateKeyFile /etc/ssl/webserver/server.key SSLCertificateChainFile /etc/ssl/webserver/server-ca-bundle.crt LogLevel error ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined DocumentRoot /data/ftp/wordpress <Directory /> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all SSLRequireSSL </Directory> </VirtualHost>
MySQL Database and User
Get a list of existing MySQL users and hosts.
mysql> SELECT user,host FROM mysql.user;
Create a new WordPress database with a new user.
mysql> CREATE DATABASE my_wp; mysql> GRANT ALL PRIVILEGES ON my_wp.* TO "wpuser"@"localhost" IDENTIFIED BY "passwd"; mysql> FLUSH PRIVILEGES;
mysql> SHOW grants FOR 'wpuser'@'localhost'; +---------------------------------------------------------------------------------+ | Grants for wpuser@localhost | +---------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'wpuser'@'localhost' IDENTIFIED BY PASSWORD '*4502000000' | | GRANT ALL PRIVILEGES ON `my_wp`.* TO 'wpuser'@'localhost' | +---------------------------------------------------------------------------------+
Delete a user from MySQL.
mysql> DELETE FROM mysql.user WHERE user='username';
ProFTPd User
Webserver’s group ID:
# grep www-data /etc/group www-data:x:33:
FTP root is under /data/ftp/
. Add new ProFTPd user:
# ftpasswd --passwd --file=/etc/proftpd/auth/users.passwd --name=ftpuser --home=/data/ftp/wordpress --shell=/bin/false --uid=33 --gid=33
How to set up ProFTPd.
Or alternatively add the following line to wp-config.php
to update wordpress without ftp:
define('FS_METHOD','direct');
WordPress Installation and Configuration
Download and install:
# wget http://wordpress.org/latest.tar.gz # tar xf ./latest.tar.gz -C /data/ftp # chown -R root:root /data/ftp/wordpress # chmod 0755 /data/ftp/wordpress # chown -R www-data:root /data/ftp/wordpress/wp-content # cd ./wordpress # cp ./wp-config-sample.php ./wp-config.php # chown root:www-data ./wp-config.php # chmod 0640 ./wp-config.php
Open wp-config.php
and configure appropriatelly.
//MySQL settings define('DB_NAME', 'my_wp'); define('DB_USER', 'wpuser'); define('DB_PASSWORD', 'wppasswd'); define('DB_HOST', 'localhost'); define('DB_CHARSET', 'utf8'); define('DB_COLLATE', ''); //FTP config define('FS_METHOD', 'direct'); define('FTP_BASE', '/data/ftp/wordpress'); define('FTP_USER', 'ftpuser'); define('FTP_PASS', 'ftppasswd'); define('FTP_HOST', 'localhost'); define('FTP_SSL', false); //Get keys from: https://api.wordpress.org/secret-key/1.1/salt/ define('AUTH_KEY', 'U@0ODy*54'); define('SECURE_AUTH_KEY', ',fL!xtyZ='); define('LOGGED_IN_KEY', '_uYlu&'); define('NONCE_KEY', 'DB|pL_,L0'); define('AUTH_SALT', 'HSCA^k)1i'); define('SECURE_AUTH_SALT', 'PHzO#OZgE'); define('LOGGED_IN_SALT', '6b,8ymis)'); define('NONCE_SALT', 'Q<~d=?'); //WordPress database table prefix $table_prefix = 'wp_'; define('WPLANG', ''); define('WP_DEBUG', false); if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); require_once(ABSPATH . 'wp-settings.php');
Navigate to https://localhost/wp-admin/install.php and finish the installation.
Change WordPress Sitename in MySQL Database
To get existing values:
mysql> SELECT * from wp_options WHERE option_name = 'siteurl'; mysql> SELECT * from wp_options WHERE option_name = 'home';
To put new values:
mysql> UPDATE wp_options SET option_value = 'http://example.com' WHERE option_name = 'siteurl';
mysql> UPDATE wp_options SET option_value = 'http://example.com' WHERE option_name = 'home';
Related Posts
Setting Up ProFTPd on Debian Wheezy with Explicit FTPS and Alternate mod_auth_file File
Installing Zabbix 1.8.19 From Source on Debian Wheezy with PHP Frontend and HTTPS (LAMP Stack)