| 332 | |
| 333 | Now that our server software is configured, we can download and set up WordPress. For security reasons in particular, it is always recommended to get the latest version of WordPress from their site. |
| 334 | |
| 335 | cd /tmp |
| 336 | curl -O https://wordpress.org/latest.tar.gz |
| 337 | |
| 338 | Extract the compressed file |
| 339 | |
| 340 | tar xzvf latest.tar.gz |
| 341 | |
| 342 | To enable Wordpress modify the directory content through the .htaccess file let's create the required file within the directory. |
| 343 | |
| 344 | touch /tmp/wordpress/.htaccess |
| 345 | |
| 346 | Then let's create a initial configuration file from a sample configuration given. |
| 347 | |
| 348 | cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php |
| 349 | |
| 350 | We will also create the upgrade directory for WordPress as below. |
| 351 | |
| 352 | mkdir /tmp/wordpress/wp-content/upgrade |
| 353 | |
| 354 | Now we will copy entire content to the document root of WordPress site. |
| 355 | |
| 356 | cp -a wordpress/. /var/www/wp.your_domain.com/public_html/ |
| 357 | |
| 358 | Now we will set the ownership settings of the WordPress directory to the Apache user. |
| 359 | |
| 360 | chown -R www-data:www-data /var/www/wp.your_domain.com |
| 361 | |
| 362 | Next we will set correct directory and file permissions for document root. |
| 363 | |
| 364 | find wp.your_domain.com/public_html/ -type d -exec chmod 750 {} \; |
| 365 | find wp.your_domain.com/public_html/ -type f -exec chmod 640 {} \; |
| 366 | |
| 367 | Now we are going to modify the configuration file we have added earlier. Here we will configure WordPress security keys and database connection settings. |
| 368 | |
| 369 | WordPress uses security keys to protect your website against hacking attempts. WordPress security keys are an encryption tool that protects login information by making it harder to decode. WordPress provides a secure generator for these keys to generate them use the below command. |
| 370 | |
| 371 | curl -s https://api.wordpress.org/secret-key/1.1/salt/ |
| 372 | |
| 373 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web24.png)]] |
| 374 | |
| 375 | These lines can be directly copied into the WordPress configuration file. Open configuration file and replace the existing sample keys with them. |
| 376 | |
| 377 | nano /var/www/wp.your_domain.com/public_html/wp-config.php |
| 378 | |
| 379 | Now we will add the database connection settings as below. |
| 380 | |
| 381 | {{{ |
| 382 | // ** MySQL settings - You can get this info from your web host ** // |
| 383 | /** The name of the database for WordPress */ |
| 384 | define( 'DB_NAME', 'wordpress' ); |
| 385 | |
| 386 | /** MySQL database username */ |
| 387 | define( 'DB_USER', 'wordpressuser' ); |
| 388 | |
| 389 | /** MySQL database password */ |
| 390 | define( 'DB_PASSWORD', '********' ); |
| 391 | |
| 392 | /** MySQL hostname */ |
| 393 | define( 'DB_HOST', 'localhost' ); |
| 394 | |
| 395 | /** Database Charset to use in creating database tables. */ |
| 396 | define( 'DB_CHARSET', 'utf8' ); |
| 397 | |
| 398 | /** The Database Collate type. Don't change this if in doubt. */ |
| 399 | define( 'DB_COLLATE', '' ); |
| 400 | }}} |
| 401 | |
| 402 | The other change we need to make is to set the method that WordPress should use to write to the filesystem. Since we’ve given the web server permission to write where it needs to, we can explicitly set the filesystem method to “direct”. |
| 403 | |
| 404 | define('FS_METHOD', 'direct'); |
| 405 | |
| 406 | Now we are done with configuration of the WordPress. To begin the installation you have to access the WordPress URL from the web browser. Enter the http://wp.your_domain.com/ on the browser and we need to follow the steps as below. |
| 407 | |
| 408 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web18.png)]] |
| 409 | |
| 410 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web19.png)]] |
| 411 | |
| 412 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web20.png)]] |
| 413 | |
| 414 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web21.png)]] |
| 415 | |
| 416 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web22.png)]] |
| 417 | |
| 418 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web23.png)]] |
| 419 | |